I've got a problem with usb_modeswitch_dispatcher not properly detecting the top-directory.
http://www.draisberghof.de/usb_modeswit ... f=2&t=2601 might relate.
The log contains:
Code: Select all
greyscale ~ # cat /var/log/usb_modeswitch_3-1\:1.0
USB_ModeSwitch log from Wed Jan 04 13:22:09 SAST 2017
Use global config file: /etc/usb_modeswitch.conf
Raw args from udev: 0000:00:14.0/3-1:1.0
argList: 0000:00:14.0
argList: 3-1:1.0
Top device directory not found (/sys/bus/usb/devices/0000)! Exit
greyscale ~ #
Code: Select all
# arg 0: the bus id for the device (udev: %b), often ommitted
# arg 1: the "kernel name" for the device (udev: %k)
#
# Used to determine the top directory for the device in sysfs
set ifChk 0
if {[string length [lindex $argList 0]] == 0} {
if {[string length [lindex $argList 1]] == 0} {
Log "No device number values given from udev! Exit"
SafeExit
} else {
if {![regexp {(.*?):} [lindex $argList 1] d dev_top]} {
if {![regexp {([0-9]+-[0-9]+\.?[0-9]*.*)} [lindex $argList 1] d dev_top]} {
Log "Could not determine device dir from udev values! Exit"
SafeExit
}
}
}
} else {
Log "argList: [lindex $argList 0]"
Log "argList: [lindex $argList 1]"
set dev_top [lindex $argList 0]
regexp {(.*?):} $dev_top d dev_top
}
set devdir /sys/bus/usb/devices/$dev_top
For now I've simply modified the above code to read as:
Code: Select all
# arg 0: the bus id for the device (udev: %b), often ommitted
# arg 1: the "kernel name" for the device (udev: %k)
#
# Used to determine the top directory for the device in sysfs
set ifChk 0if {[string length [lindex $argList 1]] > 0} {
if {![regexp {(.*?):} [lindex $argList 1] d dev_top]} {
if {![regexp {([0-9]+-[0-9]+\.?[0-9]*.*)} [lindex $argList 1] d dev_top]} {
Log "Could not determine device dir from udev values! Exit"
SafeExit
}
}
} else {
set dev_top [lindex $argList 0]
regexp {(.*?):} $dev_top d dev_top
}
With this change it works for me, having said that the amount of testing is minimal and I suspect someone with a better understanding of the names/values being passed, and why %k might be unusable in some cases (if any) should probably eyeball this before it goes into any kind of distribution.
Looking at the udev man page the question as to whether %p might be useful also arises. My expectation would be that %p will (in my case above) give:
Code: Select all
/sys/devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0
Code: Select all
greyscale devices # pwd
/sys/bus/usb/devices
greyscale devices # ls -la 3-1*
lrwxrwxrwx 1 root root 0 Jan 4 14:35 3-1 -> ../../../devices/pci0000:00/0000:00:14.0/usb3/3-1
lrwxrwxrwx 1 root root 0 Jan 4 14:40 3-1:1.0 -> ../../../devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0
lrwxrwxrwx 1 root root 0 Jan 4 14:40 3-1:1.1 -> ../../../devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.1
lrwxrwxrwx 1 root root 0 Jan 4 14:40 3-1:1.2 -> ../../../devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.2
lrwxrwxrwx 1 root root 0 Jan 4 14:40 3-1:1.3 -> ../../../devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.3
lrwxrwxrwx 1 root root 0 Jan 4 14:40 3-1:1.4 -> ../../../devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.4