usb.agent - fix interpretation of hex values (PRODUCT and sysfs)
PATCH 1/1 usb.agent - fix interpretation of hex values (PRODUCT and sysfs)
Both PRODUCT and all values in sysfs are passed as hex while bash attempts to evaluate them as decimal by default.
regards
-andrey
etc/hotplug/usb.agent renamed from etc/hotplug/usb.agent.sysfs_is_hex +9 -9
@@ -183,9 +183,9 @@ -e "s+/\([0-9]\)\.\([0-9][0-9]\)+/0\1\2+" \ -e "s+/\([0-9][0-9]\)\.\([0-9][0-9]\)+/\1\2+"` set `echo $PRODUCT | $AWK -F/ '{print "0x" $1, "0x" $2, "0x" $3 }'` '' - usb_idVendor=$1 - usb_idProduct=$2 - usb_bcdDevice=$3 + usb_idVendor=0x$1 + usb_idProduct=0x$2 + usb_bcdDevice=0x$3 if [ "$TYPE" != "" ]; then IFS=/
@@ -195,9 +195,9 @@ usb_bDeviceProtocol=$3 IFS="$DEFAULT_IFS" elif [ -r $SYSFS/$DEVPATH/bDeviceClass ]; then - usb_bDeviceClass=$(cat $SYSFS/$DEVPATH/bDeviceClass) - usb_bDeviceSubClass=$(cat $SYSFS/$DEVPATH/bDeviceSubClass) - usb_bDeviceProtocol=$(cat $SYSFS/$DEVPATH/bDeviceProtocol) + usb_bDeviceClass=0x$(cat $SYSFS/$DEVPATH/bDeviceClass) + usb_bDeviceSubClass=0x$(cat $SYSFS/$DEVPATH/bDeviceSubClass) + usb_bDeviceProtocol=0x$(cat $SYSFS/$DEVPATH/bDeviceProtocol) else # out-of-range values usb_bDeviceClass=1000
@@ -213,9 +213,9 @@ usb_bInterfaceProtocol=$3 IFS="$DEFAULT_IFS" elif [ -r $SYSFS/$DEVPATH/bInterfaceClass ]; then - usb_bInterfaceClass=$(cat $SYSFS/$DEVPATH/bInterfaceClass) - usb_bInterfaceSubClass=$(cat $SYSFS/$DEVPATH/bInterfaceSubClass) - usb_bInterfaceProtocol=$(cat $SYSFS/$DEVPATH/bInterfaceProtocol) + usb_bInterfaceClass=0x$(cat $SYSFS/$DEVPATH/bInterfaceClass) + usb_bInterfaceSubClass=0x$(cat $SYSFS/$DEVPATH/bInterfaceSubClass) + usb_bInterfaceProtocol=0x$(cat $SYSFS/$DEVPATH/bInterfaceProtocol) else # out-of-range values usb_bInterfaceClass=1000
Quoted 3 lines · Andrey Borzenkov
Both PRODUCT and all values in sysfs are passed as hex while bash attempts to evaluate them as decimal by default.
oops, it sneaked in by mistake from some unrelated experiments. PRODUCT is already OK of course, sorry.
updated patch attached
-andrey
etc/hotplug/usb.agent renamed from etc/hotplug/usb.agent.sysfs_is_hex +6 -6
@@ -195,9 +195,9 @@ usb_bDeviceProtocol=$3 IFS="$DEFAULT_IFS" elif [ -r $SYSFS/$DEVPATH/bDeviceClass ]; then - usb_bDeviceClass=$(cat $SYSFS/$DEVPATH/bDeviceClass) - usb_bDeviceSubClass=$(cat $SYSFS/$DEVPATH/bDeviceSubClass) - usb_bDeviceProtocol=$(cat $SYSFS/$DEVPATH/bDeviceProtocol) + usb_bDeviceClass=0x$(cat $SYSFS/$DEVPATH/bDeviceClass) + usb_bDeviceSubClass=0x$(cat $SYSFS/$DEVPATH/bDeviceSubClass) + usb_bDeviceProtocol=0x$(cat $SYSFS/$DEVPATH/bDeviceProtocol) else # out-of-range values usb_bDeviceClass=1000
@@ -213,9 +213,9 @@ usb_bInterfaceProtocol=$3 IFS="$DEFAULT_IFS" elif [ -r $SYSFS/$DEVPATH/bInterfaceClass ]; then - usb_bInterfaceClass=$(cat $SYSFS/$DEVPATH/bInterfaceClass) - usb_bInterfaceSubClass=$(cat $SYSFS/$DEVPATH/bInterfaceSubClass) - usb_bInterfaceProtocol=$(cat $SYSFS/$DEVPATH/bInterfaceProtocol) + usb_bInterfaceClass=0x$(cat $SYSFS/$DEVPATH/bInterfaceClass) + usb_bInterfaceSubClass=0x$(cat $SYSFS/$DEVPATH/bInterfaceSubClass) + usb_bInterfaceProtocol=0x$(cat $SYSFS/$DEVPATH/bInterfaceProtocol) else # out-of-range values usb_bInterfaceClass=1000
Greg KH
AppliedQuoted 9 lines · Andrey Borzenkov
Quoted 3 lines · Andrey Borzenkov
Both PRODUCT and all values in sysfs are passed as hex while bash attempts to evaluate them as decimal by default.
oops, it sneaked in by mistake from some unrelated experiments. PRODUCT is already OK of course, sorry.
updated patch attached
Sorry for the very long delay.
I've applied the patch, thanks.
greg k-h
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program. SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel