summaryrefslogtreecommitdiff
path: root/sys/src/9/boot
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2014-06-28 18:09:43 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2014-06-28 18:09:43 +0200
commit4275c49e72544d5b92512e41ddecbd6af5bee6c3 (patch)
tree22d66cc1e3286e69f50cc676e3c8e7fbd4b0636a /sys/src/9/boot
parentd8c75e45de9483881f782be0b5e7113e625db571 (diff)
nusb: implement aijus stable uniqueue device names
instead of naming devices by ther dynamically assigned device address, we hash device uniqueue fields from the device descriptor and produce a 5 digit hex string that will identify the device across machines. when there is a collision (less than 1% chance with 100 devices), usbd will append the device address to the name to make it uniqueue for this machine. the hname is passed to drivers in the devid argument, which now has the form addr:hname, where the colon and hname can be omited (for backwards compatibility). when the new behaviour isnt desired, nousbhname= environment variable can be defined giving the old behaviour.
Diffstat (limited to 'sys/src/9/boot')
-rwxr-xr-xsys/src/9/boot/nusbrc27
1 files changed, 16 insertions, 11 deletions
diff --git a/sys/src/9/boot/nusbrc b/sys/src/9/boot/nusbrc
index 811f7beeb..29a2d8b56 100755
--- a/sys/src/9/boot/nusbrc
+++ b/sys/src/9/boot/nusbrc
@@ -11,29 +11,33 @@ if(! nusb/usbd)
@{
rfork ne
fn attach {
+ id=$1
+ if(~ $#* 5 && ! test -e /env/nousbhname)
+ id=$1:$5
switch($2$3){
case 0b957720 0b95772a 0db0a877 13b10018 15577720 20013c05 07d13c05 05ac1402
- nusb/ether -t a88772 $etherargs $1
+ nusb/ether -t a88772 $etherargs $id
case 0b951780 14eaab11 17370039 0411006e 050d5055
- nusb/ether -t a88178 $etherargs $1
+ nusb/ether -t a88178 $etherargs $id
case 2001abc1
- nusb/ether -t aue $etherargs $1
+ nusb/ether -t aue $etherargs $id
case 0bda8150
- nusb/ether -t url $etherargs $1
+ nusb/ether -t url $etherargs $id
case 18d14ee3 0bb40003
- nusb/ether -t rndis $etherargs $1
+ nusb/ether -t rndis $etherargs $id
case *
switch($4){
case *03
- nusb/kb $1
+ nusb/kb $id
case *02
# CDC ethernet
- nusb/ether $etherargs $1
+ nusb/ether $etherargs $id
case *08
- if(nusb/disk $1) {@{
+ if(nusb/disk $id) {@{
rfork ne
cd '#σ/usb'
- for(dev in sdU^$1.*) if(test -d $dev) {
+ devs=sdU^($1 $5)
+ for(dev in $devs $devs.*) if(test -d $dev) {
diskparts $dev
for(part in $dev/dos* $dev/9fat) if(test -r $part) {
mkdir -m 0700 '#σc/'^$dev || exit
@@ -45,12 +49,13 @@ if(! nusb/usbd)
}&}
case *
if(~ $2 0424)
- nusb/ether -t smsc $etherargs $1
+ nusb/ether -t smsc $etherargs $id
}
}
}
fn detach {
- rm -rf '#σc/usb/'^$1.* '#σc/sdU'^$1.* '#σc/usbnet/'^$1.*
+ devs='#σc/sdU'^($1 $5)
+ rm -rf '#σc/usb/'^$1.* '#σc/usbnet/'^$1.* $devs $devs.*
}
rc < '#σ/usb/usbevent' &
}