linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Marco d'Itri" <md@Linux.IT>
To: linux-hotplug@vger.kernel.org
Subject: hotplug patches: fixes and sysfs support 5/5
Date: Sun, 07 Mar 2004 12:49:52 +0000	[thread overview]
Message-ID: <20040307124952.GC4345@wonderland.linux.it> (raw)
In-Reply-To: <20040205010507.GA12825@wonderland.linux.it>

[-- Attachment #1: Type: text/plain, Size: 240 bytes --]

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]

[-- Attachment #2: 004_2.6_usb_sysfs --]
[-- Type: text/plain, Size: 2854 bytes --]

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

  parent reply	other threads:[~2004-03-07 12:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-05  1:05 hotplug patches: fixes and sysfs support Marco d'Itri
2004-02-13 11:01 ` Marco d'Itri
2004-02-21 17:48 ` Marco d'Itri
2004-02-28 14:50 ` Marco d'Itri
2004-03-07 12:42 ` hotplug patches: fixes and sysfs support 1/5 Marco d'Itri
2004-03-07 12:43 ` hotplug patches: fixes and sysfs support 2/5 Marco d'Itri
2004-03-07 12:44 ` hotplug patches: fixes and sysfs support 3/5 Marco d'Itri
2004-03-07 12:48 ` hotplug patches: fixes and sysfs support 4/5 Marco d'Itri
2004-03-07 12:49 ` Marco d'Itri [this message]
2004-03-11 23:24 ` hotplug patches: fixes and sysfs support 1/5 Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040307124952.GC4345@wonderland.linux.it \
    --to=md@linux.it \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).