summaryrefslogtreecommitdiff
path: root/rc/bin/nusbrc
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 /rc/bin/nusbrc
parentd8c75e45de9483881f782be0b5e7113e625db571 (diff)
downloadplan9front-4275c49e72544d5b92512e41ddecbd6af5bee6c3.tar.xz
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 'rc/bin/nusbrc')
-rwxr-xr-xrc/bin/nusbrc17
1 files changed, 10 insertions, 7 deletions
diff --git a/rc/bin/nusbrc b/rc/bin/nusbrc
index 546803a4b..1bff5073b 100755
--- a/rc/bin/nusbrc
+++ b/rc/bin/nusbrc
@@ -7,22 +7,25 @@ if(! bind -a '#u' /dev)
@{
rfork ne
fn attach {
+ id=$1
+ if(~ $#* 5 && ! test -e /env/nousbhname)
+ id=$1:$5
switch($4){
case *01
- nusb/audio $1
+ nusb/audio $id
case *02
# serial and ethernet
- nusb/serial $1
+ nusb/serial $id
# handled /sys/src/9/boot/nusbrc
- # nusb/ether $1
+ # nusb/ether $id
case *03
# handled /sys/src/9/boot/nusbrc
- # nusb/kb $1
+ # nusb/kb $id
case *08
# handled /sys/src/9/boot/nusbrc
- # nusb/disk $1
- case *10106
- nusb/ptp $1
+ # nusb/disk $id
+ case 010106
+ nusb/ptp $id
}
}
fn detach {