Plan 9 from Bell Labs’s /usr/web/sources/plan9/386/bin/usb/probe

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/rc
# usb/probe [-h] - list all usb devices, including hubs
rfork e
test -e /dev/usb || bind -a '#u' /dev || {
	echo no '#u/usb' >[1=2]
	exit nousb
}

filter = cat
if (~ $1 -h)
	filter = (grep -v ' (root)?hub ')

awk 'BEGIN	{ ep = "" }
$1 ~ /ep[0-9]+\.0/ && $2 == "enabled" && $NF ~ /busy|idle/ {
	ep=$1
	next
}
{
	if(ep != ""){
		printf "%s %s\n", ep, $0
		ep = ""
	}
}
' /dev/usb/ctl | $filter

exit ''

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].