ref: 6f3039351a35eb4310cfa1fc5dec802e74ad73f8
parent: b43de8eb1fb64d545b12b987646a5823d2e42caf
author: cinap_lenrek <cinap_lenrek@localhost>
date: Sun Jul 31 22:55:39 EDT 2011
nusb: add /rc/bin/nusbrc
--- a/rc/bin/cpurc
+++ b/rc/bin/cpurc
@@ -7,7 +7,9 @@
bind -a '#'^$i /dev >/dev/null >[2=1]
mount -qb /srv/cons /dev
-mount -qa /srv/usb /dev
+
+# usb listener
+nusbrc
# mount points
mntgen -s slashn && chmod 666 /srv/slashn
--- /dev/null
+++ b/rc/bin/nusbrc
@@ -1,0 +1,31 @@
+#!/bin/rc
+
+if(! test -e '#σ/usb/usbevent')
+ exit
+if(! bind -a '#u' /dev)
+ exit
+
+@{
+ rfork ne
+ fn attach {
+ switch($4){
+ case *01
+ nusb/audio $1
+ case *02
+ # serial and ethernet
+ nusb/serial $1
+ case *03
+ # handled /sys/src/9/boot/nusbrc
+ # nusb/kb $1
+ case *08
+ # handled /sys/src/9/boot/nusbrc
+ # nusb/disk $1
+ }
+ }
+ fn detach {
+ # handled /sys/src/9/boot/nusbrc
+ }
+ rc < '#σ/usb/usbevent' &
+}
+
+bind -a '#σ/usb' /dev
--- a/rc/bin/termrc
+++ b/rc/bin/termrc
@@ -10,7 +10,9 @@
rm -f /env/i
mount -qb /srv/cons /dev
-mount -qa /srv/usb /dev
+
+# usb listener
+nusbrc
# set up any partitions
diskparts