From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Marco d'Itri" Date: Sun, 07 Mar 2004 12:49:52 +0000 Subject: hotplug patches: fixes and sysfs support 5/5 Message-Id: <20040307124952.GC4345@wonderland.linux.it> MIME-Version: 1 Content-Type: multipart/mixed; boundary="32u276st3Jlj2kUU" List-Id: References: <20040205010507.GA12825@wonderland.linux.it> In-Reply-To: <20040205010507.GA12825@wonderland.linux.it> To: linux-hotplug@vger.kernel.org --32u276st3Jlj2kUU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 004_2.6_usb_sysfs: improved sysfs support in the USB scripts. Please review the changes marked with the FIXME comment: this works on my system and others, but I'm not sure that it's the proper way. -- ciao, | Marco | [4960 afL/bBUW.i/og] --32u276st3Jlj2kUU Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="004_2.6_usb_sysfs" diff -ruN hotplug-2004_01_05.orig/etc/hotplug/usb.agent hotplug-2004_01_05/etc/hotplug/usb.agent --- hotplug-2004_01_05.orig/etc/hotplug/usb.agent 2004-02-01 18:00:45.000000000 +0100 +++ hotplug-2004_01_05/etc/hotplug/usb.agent 2004-02-01 18:00:32.000000000 +0100 @@ -361,7 +361,11 @@ usb_convert_vars FOUND=false - LABEL="USB product $PRODUCT" + if [ -f $SYSFS/$DEVPATH/manufacturer ]; then + LABEL="USB `cat $SYSFS/$DEVPATH/manufacturer` `cat $SYSFS/$DEVPATH/product`" + else + LABEL="USB product $PRODUCT" + fi if [ -e "$REMOVER" ]; then rm -f "$REMOVER" diff -ruN hotplug-2004_01_05.orig/etc/hotplug/usb.rc hotplug-2004_01_05/etc/hotplug/usb.rc --- hotplug-2004_01_05.orig/etc/hotplug/usb.rc 2004-02-01 18:00:45.000000000 +0100 +++ hotplug-2004_01_05/etc/hotplug/usb.rc 2004-02-01 17:57:41.000000000 +0100 @@ -80,11 +80,12 @@ # make sure the usb agent will run ACTION=add PRODUCT=0/0/0 - export ACTION PRODUCT - + TYPE= + INTERFACE= + DEVPATH= DEVFS=/proc/bus/usb DEVICE= - export DEVFS DEVICE + export ACTION PRODUCT TYPE INTERFACE DEVPATH DEVFS DEVICE # these notifications will be handled by usbmodules # NOTE: we're not providing a full set of hotplug @@ -95,10 +96,26 @@ # FIXME usbmodules, or something, should set real # PRODUCT and DEVICE strings so /etc/hotplug/usb/* # scripts can rely on them ... - for DEVICE in /proc/bus/usb/*/* - do + # FIXME: this comment is out of date. + if [ -d /sys/bus/usb/devices ]; then + cd /sys/bus/usb/devices + # XXX FIXME this is not the right way... + for device in /sys/bus/usb/devices/[0-9]*; do + DEVPATH=${device#/sys/} + if [ -f $device/idVendor ]; then + PRODUCT="`cat $device/idVendor`/`cat $device/idProduct`/`cat $device/bcdDevice`" +# class=`cat $device/bDeviceClass` +# TYPE="$class/`cat $device/bDeviceSubClass`/`cat $device/bDeviceProtocol`" + fi +# if [ "$class" -eq 0 -a -f $device/bInterfaceClass ]; then +# INTERFACE="`cat $device/bInterfaceClass`/`cat $device/bInterfaceSubClass`/`cat $device/bInterfaceProtocol`" +# fi + done + else + for DEVICE in /proc/bus/usb/*/*; do /etc/hotplug/usb.agent - done + done + fi } @@ -130,12 +147,14 @@ if [ -d /proc/bus/usb ]; then # if it's not mounted, try to mount it if [ ! -f /proc/bus/usb/devices ]; then - if grep -q "[ ]/proc/bus/usb[ ]" /etc/fstab ; then + if grep -q -E "^[^#][^[:space:]]+[[:space:]]+/proc/bus/usb/?[[:space:]]" /etc/fstab; then mount /proc/bus/usb else - # NOTE: name is changing to "usbfs" from "usbdevfs" - # NOTE: some versions don't create empty 'devices' files - mount -t usbdevfs usbdevfs /proc/bus/usb + if grep -q usbfs /proc/filesystems; then + mount -t usbfs usbfs /proc/bus/usb + else + mount -t usbdevfs usbdevfs /proc/bus/usb + fi fi fi fi --32u276st3Jlj2kUU-- ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel