Am 19.11.2015 um 01:00 schrieb Blake Miner:
The catch-all udev rule does not work:

​# Generic entry for all Huawei devices
ATTRS{idVendor}=="12d1", ATTR{bInterfaceNumber}=="00", ATTR{bInterfaceClass}=="08", 
RUN+="usb_modeswitch '%b/%k'"​

Thanks for the report. Upstream dev here.

This has been a puzzle for some time now. Most people don't have any problems 
with this rule, but there are occasional hiccups like your's.

There is an educated guess that it's not the rule itself that is to blame. It's 
very likely that the installed systemd version affects the respective outcome.
The problem is related to the creation of "instance units" for systemd. 
USB_ModeSwitch requires this as there are possibly several instances started in parallel 
(if there is more than one device connected which needs a mode switch).
These instances are defined by the *filename*, meaning that the template unit file 
"[email protected]" will be instantiated as 
"usb_modeswitch@<bus/kernel_name>.service".

Originally, the unchanged parameter from the RUN directive was used to name the instance. 
At the time of testing, systemd translated the "/" character transparently. 
However, there seems to have been a change so that re-translation did not work as before, 
and subsequently the dispatcher script failed to recognize the parameter when the 
instance name was passed on by the unit.

In usb-modeswitch 2.2.2, the parameter format was altered: "/" is replaced by 
"_" *before* the systemd service unit is started. The dispatcher was modified accordingly.

I'm not sure if a version update is possible for Debian. Anyway, here is a 
little patch that you can try (after restoring the 'catch-all' rule to its 
original form). The patch is against 2.2.1 in the upstream version but should 
be easy to apply to the Debian source manually.

Best regards,
Josh


diff -u u1/usb_modeswitch.sh u2/usb_modeswitch.sh
--- u1/usb_modeswitch.sh	2015-01-14 21:14:51.000000000 +0100
+++ u2/usb_modeswitch.sh	2015-11-19 10:09:47.128165935 +0100
@@ -74,6 +74,9 @@
 		;;
 esac
 exec 1<&- 2<&- 5<&- 7<&-
+IFS='/' read -r p1 p2 <<EOF
+$1
+EOF
 (
 count=20
 while [ $count != 0 ]; do
@@ -84,7 +87,7 @@
 		if [ -e "/etc/init/usb-modeswitch-upstart.conf" ]; then
 			exec /sbin/initctl emit --no-wait usb-modeswitch-upstart UMS_PARAM=$1
 		elif [ -e "/etc/systemd/system/[email protected]" ]; then
-			exec /usr/bin/systemctl --no-block start usb_modeswitch@$1.service
+			exec /usr/bin/systemctl --no-block start usb_modeswitch@$p1'_'$p2.service
 		else
 			exec /usr/sbin/usb_modeswitch_dispatcher --switch-mode $1 &
 		fi
diff -u u1/usb_modeswitch.tcl u2/usb_modeswitch.tcl
--- u1/usb_modeswitch.tcl	2015-01-14 21:15:10.000000000 +0100
+++ u2/usb_modeswitch.tcl	2015-11-19 10:14:32.898383172 +0100
@@ -54,9 +54,7 @@
 }
 
 if {[lindex $argv 0] == "--switch-systemd"} {
-	set device [string trim [lindex $argv 1] "/-"]
-	set device [regsub {/} $device "-"]
-	set argList [list "" $device]
+	set argList [split [lindex $argv 1] _]
 	Log "\nStarted via systemd"
 } else {
 	if {[lindex $argv 0] == "--switch-upstart"} {

Reply via email to