d1799f65ca
have to create process, not a thread in ftdi code so main process can exit after posting fs service.
45 lines
744 B
Bash
Executable file
45 lines
744 B
Bash
Executable file
#!/bin/rc
|
||
|
||
if(! test -e '#σ/usb/usbevent')
|
||
exit
|
||
if(! bind -a '#u' /dev)
|
||
exit
|
||
@{
|
||
rfork ne
|
||
fn attach {
|
||
id=$1
|
||
if(~ $#* 5 && ! test -e /env/nousbhname)
|
||
id=$1:$5
|
||
switch($4){
|
||
case *01
|
||
nusb/audio $id
|
||
case *02
|
||
# serial and ethernet
|
||
nusb/serial $id
|
||
# handled /sys/src/9/boot/nusbrc
|
||
# nusb/ether $id
|
||
case *03
|
||
# handled /sys/src/9/boot/nusbrc
|
||
# nusb/kb $id
|
||
case *08
|
||
# handled /sys/src/9/boot/nusbrc
|
||
# nusb/disk $id
|
||
case 010106
|
||
nusb/ptp $id
|
||
case *
|
||
# HUAWEI E220 modem
|
||
if(~ $2$3 12d11003)
|
||
nusb/serial $id
|
||
# FTDI
|
||
if(~ $2 0403)
|
||
nusb/serial $id
|
||
}
|
||
}
|
||
fn detach {
|
||
# handled /sys/src/9/boot/nusbrc
|
||
}
|
||
rc < '#σ/usb/usbevent' &
|
||
}
|
||
|
||
bind -qa '#σ/usb' /dev
|
||
bind -qa '#σ/usbnet' /net
|