linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* the match_flags support
@ 2001-03-09 15:39 Gioele Barabucci
  2001-03-09 22:43 ` Matthew Dharm
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Gioele Barabucci @ 2001-03-09 15:39 UTC (permalink / raw)
  To: linux-hotplug

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

And also this is done...
As always test and retest, I have only one USB device (a non working HP 
scanner) untill I will take that ZIP100.

-- 
Gioele Barabucci (Gb]) 
) mailto:gioele@gioelebarabucci.com
) http://www.gioelebarabucci.com
) ) I've been and now I've gone
) )          /Magic Pie^Oasis


[-- Attachment #2: Patch with match_flags support --]
[-- Type: text/x-c++, Size: 11205 bytes --]

Index: etc/hotplug/blacklist
===================================================================
RCS file: /cvsroot/linux-hotplug/admin/etc/hotplug/blacklist,v
retrieving revision 1.1
diff -u -3 -p -r1.1 blacklist
--- etc/hotplug/blacklist	2001/02/27 01:47:43	1.1
+++ etc/hotplug/blacklist	2001/03/09 15:36:17
@@ -4,7 +4,8 @@
 # no matter which driver happens to get probed first.  Sometimes user
 # mode tools can also control driver binding.
 #
-# Syntax:  driver name alone on a line.  Other lines are ignored.
+# Syntax:  driver name alone (without any ending spaces) on a line. Other
+# lines are ignored.
 #
 
 # uhci ... usb-uhci handles the same pci class
Index: etc/hotplug/hotplug.functions
===================================================================
RCS file: /cvsroot/linux-hotplug/admin/etc/hotplug/hotplug.functions,v
retrieving revision 1.3
diff -u -3 -p -r1.3 hotplug.functions
--- etc/hotplug/hotplug.functions	2001/02/27 01:48:44	1.3
+++ etc/hotplug/hotplug.functions	2001/03/09 15:36:18
@@ -114,15 +114,12 @@ load_drivers ()
     # maybe driver modules need loading and configuring
     for MODULE in $DRIVERS
     do
-	if ! lsmod | grep -q "^$MODULE "
-	then
-	    if grep -q "^$MODULE\$" /etc/hotplug/blacklist >/dev/null 2>&1
-	    then
+	if ! lsmod | grep -q "^$MODULE "; then
+	    if grep -q "^$MODULE\$" /etc/hotplug/blacklist >/dev/null 2>&1; then
 		if [ "$DEBUG" != "" ]; then
 		    mesg "... blacklisted module:  $MODULE"
 		fi
-	    elif ! $MODPROBE $MODULE >/dev/null 2>&1
-	    then
+	    elif ! $MODPROBE $MODULE >/dev/null 2>&1; then
 		mesg "... can't load module $MODULE"
 	    elif [ -x /etc/hotplug/$TYPE/$MODULE ]; then
 		if [ "$DEBUG" != "" ]; then
Index: etc/hotplug/pci.rc
===================================================================
RCS file: /cvsroot/linux-hotplug/admin/etc/hotplug/pci.rc,v
retrieving revision 1.3
diff -u -3 -p -r1.3 pci.rc
--- etc/hotplug/pci.rc	2001/02/23 22:05:59	1.3
+++ etc/hotplug/pci.rc	2001/03/09 15:36:18
@@ -27,7 +27,7 @@ fi
 pci_boot_events ()
 {
     LISTER=`type -p pcimodules`
-    if [ x$LISTER = x -o ! -f /proc/bus/pci/devices -o ! -x pci.agent ]; then
+    if [ "$LISTER" = "" -o ! -f /proc/bus/pci/devices -o ! -x pci.agent ]; then
 	    echo $"** can't synthesize pci hotplug events"
 	    return
     fi
@@ -46,10 +46,8 @@ pci_boot_events ()
     # least PCI_CLASS is used by common drivers (USB hcds).
 
     # these notifications will be handled by pcimodules
-    for BUS in `cd /proc/bus/pci;find * -type d -print`
-    do
-	for SLOT_FUNC in `cd /proc/bus/pci/$BUS; echo *`
-	do
+    for BUS in `cd /proc/bus/pci;find * -type d -print`; do
+	for SLOT_FUNC in `cd /proc/bus/pci/$BUS; echo *`; do
 	    PCI_SLOT=$BUS:$SLOT_FUNC
 	    : hotplug pci for $PCI_SLOT
 	    /sbin/hotplug pci
Index: etc/hotplug/usb.agent
===================================================================
RCS file: /cvsroot/linux-hotplug/admin/etc/hotplug/usb.agent,v
retrieving revision 1.9
diff -u -3 -p -r1.9 usb.agent
--- etc/hotplug/usb.agent	2001/02/28 01:03:59	1.9
+++ etc/hotplug/usb.agent	2001/03/09 15:36:19
@@ -76,7 +76,7 @@ MAP_USERMAP=$HOTPLUG_DIR/usb.usermap
 
 
 # accumulates list of modules we may care about
-DRIVERS=
+DRIVERS=""
 
 if [ "$PRODUCT" = "" -o "$ACTION" = "" ]; then
     mesg Bad USB agent invocation
@@ -84,8 +84,11 @@ if [ "$PRODUCT" = "" -o "$ACTION" = "" ]
 fi
 
 # we can't "unset IFS" on bash1, so we save a
-DEFAULT_IFS=' 	
-'
+# and if someone has a different IFS? this is safer
+#DEFAULT_IFS=' 	
+#'
+DEFAULT_IFS="$IFS"
+
 #
 # Each modules.usbmap format line corresponds to one entry in a
 # MODULE_DEVICE_TABLE(usb,...) declaration in a kernel file.
@@ -150,6 +153,18 @@ USB_ANY=0
 #
 usb_map_modules ()
 {
+    # should this go outside this routine?
+    declare -i USB_MATCH_VENDOR=0x0001
+    declare -i USB_MATCH_PRODUCT=0x0002
+    declare -i USB_MATCH_DEV_LO=0x0004 		#it is not used...
+    declare -i USB_MATCH_DEV_HI=0x0008
+    declare -i USB_MATCH_DEV_CLASS=0x0010
+    declare -i USB_MATCH_DEV_SUBCLASS=0x0020
+    declare -i USB_MATCH_DEV_PROTOCOL=0x0040
+    declare -i USB_MATCH_INT_CLASS=0x0080
+    declare -i USB_MATCH_INT_SUBCLASS=0x0100
+    declare -i USB_MATCH_INT_PROTOCOL=0x0200
+
     # convert the usb_device_id fields to integers as we read them 
     local module ignored
     declare -i match_flags
@@ -157,9 +172,6 @@ usb_map_modules ()
     declare -i bDeviceClass bDeviceSubClass bDeviceProtocol
     declare -i bInterfaceClass bInterfaceSubClass bInterfaceProtocol
 
-    # comment line lists (current) usb_device_id field names
-    # is this still needed?
-    read ignored
 
     # look at each usb_device_id entry
     # collect all matches in $DRIVERS
@@ -179,34 +191,41 @@ usb_map_modules ()
 # ... if it's there, and nonzero
 
 	: idVendor $idVendor $usb_idVendor
-	if [ $idVendor -ne $USB_ANY -a $idVendor -ne $usb_idVendor ]; then
+        if [ $(( $match_flags & $USB_MATCH_VENDOR )) ] && 
+	   [ $idVendor -ne $usb_idVendor ]; then
 	    continue
 	fi
 	# NOTE: some vendors actually use zero as a product code,
 	# so their driver probe routines must filter further
 	: idProduct $idProduct $usb_idProduct
-	if [ $idProduct -ne $USB_ANY -a $idProduct -ne $usb_idProduct ]; then
+	if [ $(( $match_flags & $USB_MATCH_PRODUCT )) ] &&
+	   [ $idProduct -ne $usb_idProduct ]; then
 	    continue
 	fi
 
+	# why is there no need to test this??
 	: bcdDevice range $bcdDevice_hi $bcdDevice_lo actual $usb_bcdDevice
 	if [ $bcdDevice_lo -gt $usb_bcdDevice ]; then
 	    continue
 	fi
-	if [ $bcdDevice_hi -ne $USB_ANY -a $usb_bcdDevice -le $bcdDevice_hi ]; then
+	if [ $(( $match_flags & $USB_MATCH_DEV_HI )) ] &&
+	   [ $usb_bcdDevice -le $bcdDevice_hi ]; then
 	    continue
 	fi
 
 	: bDeviceClass $bDeviceClass $usb_bDeviceClass
-	if [ $bDeviceClass -ne $USB_ANY -a $bDeviceClass -ne $usb_bDeviceClass ]; then
+	if [ $(( $match_flags & $USB_MATCH_DEV_CLASS )) ] &&
+	   [ $bDeviceClass -ne $usb_bDeviceClass ]; then
 	    continue
 	fi
 	: bDeviceSubClass $bDeviceSubClass $usb_bDeviceSubClass
-	if [ $bDeviceSubClass -ne $USB_ANY -a $bDeviceSubClass -ne $usb_bDeviceSubClass ]; then
+	if [ $(( $match_flags & $USB_MATCH_DEV_SUBCLASS )) ] &&
+	   [ $bDeviceSubClass -ne $usb_bDeviceSubClass ]; then
 	    continue
 	fi
 	: bDeviceProtocol $bDeviceProtocol $usb_bDeviceProtocol
-	if [ $bDeviceProtocol -ne $USB_ANY -a $bDeviceProtocol -ne $usb_bDeviceProtocol ]; then
+	if [ $(( $match_flags & $USB_MATCH_DEV_PROTOCOL )) ] &&
+	   [ $bDeviceProtocol -ne $usb_bDeviceProtocol ]; then
 	    continue
 	fi
 
@@ -214,15 +233,18 @@ usb_map_modules ()
 	# several interfaces for this device.
 
 	: bInterfaceClass $bInterfaceClass $usb_bInterfaceClass
-	if [ $bInterfaceClass -ne $USB_ANY -a $bInterfaceClass -ne $usb_bInterfaceClass ]; then
+	if [ $(( $match_flags & $USB_MATCH_INT_CLASS )) ] &&
+	   [ $bInterfaceClass -ne $usb_bInterfaceClass ]; then
 	    continue
 	fi
 	: bInterfaceSubClass $bInterfaceSubClass $usb_bInterfaceSubClass
-	if [ $bInterfaceSubClass -ne $USB_ANY -a $bInterfaceSubClass -ne $usb_bInterfaceSubClass ]; then
+	if [ $(( $match_flags & $USB_MATCH_INT_SUBCLASS )) ] &&
+	   [ $bInterfaceSubClass -ne $usb_bInterfaceSubClass ]; then
 	    continue
 	fi
 	: bInterfaceProtocol $bInterfaceProtocol $usb_bInterfaceProtocol
-	if [ $bInterfaceProtocol -ne $USB_ANY -a $bInterfaceProtocol -ne $usb_bInterfaceProtocol ]; then
+	if [ $(( $match_flags & $USB_MATCH_INT_PROTOCOL )) ] &&
+	   [ $bInterfaceProtocol -ne $usb_bInterfaceProtocol ]; then
 	    continue
 	fi
 
@@ -270,7 +292,7 @@ add)
     fi
 
     # some devices have user-mode drivers (no kernel module, but config)
-    if [ $FOUND = false -a -r $MAP_USERMAP ]; then
+    if [ "$FOUND" = "false" -a -r $MAP_USERMAP ]; then
 	MODPROBE=:
     	load_drivers usb $MAP_USERMAP "$LABEL"
 	if [ "$DRIVERS" != "" ]; then
Index: etc/hotplug/usb.rc
===================================================================
RCS file: /cvsroot/linux-hotplug/admin/etc/hotplug/usb.rc,v
retrieving revision 1.7
diff -u -3 -p -r1.7 usb.rc
--- etc/hotplug/usb.rc	2001/02/28 18:22:03	1.7
+++ etc/hotplug/usb.rc	2001/03/09 15:36:19
@@ -94,8 +94,7 @@ maybe_start_usb ()
     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 "[	 ]/proc/bus/usb[	 ]" /etc/fstab ; then
 		mount /proc/bus/usb
 	    else
 		mount -t usbdevfs usbdevfs /proc/bus/usb
@@ -131,8 +130,7 @@ maybe_start_usb ()
 
     # if USB is fully modular and yet can clean up,
     # we know init failed without needing usbdevfs
-    elif rmmod usbcore >/dev/null 2>&1
-    then
+    elif rmmod usbcore >/dev/null 2>&1; then
 	return 1
     fi
 
@@ -145,8 +143,7 @@ maybe_start_usb ()
 
     # Some modules are statically loaded, perhaps because they are
     # needed to activate filesystem device nodes.
-    for MODULE in $STATIC_MODULE_LIST
-    do
+    for MODULE in $STATIC_MODULE_LIST; do
 	modprobe $MODULE
     done
 
@@ -223,8 +220,7 @@ case "$1" in
 	    cat /proc/bus/usb/drivers
 	else
 	    echo $"USB-devfs is unavailable. "
-	    if test -f /proc/modules && fgrep -q usbcore /proc/modules
-	    then
+	    if [ -f /proc/modules ] && fgrep -q usbcore /proc/modules; then
 		echo $"USB module is loaded. "
 	    else
 		echo $"USB may be statically linked. "
Index: etc/rc.d/init.d/hotplug
===================================================================
RCS file: /cvsroot/linux-hotplug/admin/etc/rc.d/init.d/hotplug,v
retrieving revision 1.2
diff -u -3 -p -r1.2 hotplug
--- etc/rc.d/init.d/hotplug	2001/02/23 22:05:59	1.2
+++ etc/rc.d/init.d/hotplug	2001/03/09 15:36:19
@@ -13,23 +13,25 @@
 
 # source function library
 if [ -f /etc/init.d/functions ]; then
-	. /etc/init.d/functions
+    . /etc/init.d/functions
 elif [ -f /etc/rc.d/init.d/functions ]; then
-	. /etc/rc.d/init.d/functions
+    . /etc/rc.d/init.d/functions
 fi
 
 case "$1" in
     start|restart|status)
-	for RC in /etc/hotplug/*.rc
-	do
-	    $RC $1
+	for RC in /etc/hotplug/*.rc; do
+	    if [ -x $RC ]; then
+		$RC $1 
+	    fi
 	done
 	touch /var/lock/subsys/hotplug
 	;;
     stop)
-	for RC in /etc/hotplug/*.rc
-        do
-            $RC stop
+	for RC in /etc/hotplug/*.rc; do
+	    if [ -x $RC ]; then
+		$RC stop
+	    fi
         done
         rm -f /var/lock/subsys/hotplug
         ;;
@@ -39,3 +41,4 @@ case "$1" in
     exit 1
     ;;
 esac
+
Index: sbin/hotplug
===================================================================
RCS file: /cvsroot/linux-hotplug/admin/sbin/hotplug,v
retrieving revision 1.5
diff -u -3 -p -r1.5 hotplug
--- sbin/hotplug	2001/02/27 02:11:22	1.5
+++ sbin/hotplug	2001/03/09 15:36:20
@@ -35,7 +35,7 @@ fi
 #
 if [ $# -lt 1 -o "$1" = "help" -o "$1" = "--help" ]; then
     if [ -t ]; then
-	echo "Usage: $0 AgentName ..."
+	echo "Usage: $0 AgentName [AgentArguments]"
 
 	AGENTS=""
 	for AGENT in /etc/hotplug/*.agent ; do
@@ -63,7 +63,7 @@ AGENT=/etc/hotplug/$1.agent
 if [ -x $AGENT ]; then
     shift
     if [ "$DEBUG" != "" ]; then
-	mesg "invoke $AGENT"
+	mesg "invoke $AGENT ($@)"
     fi
     exec $AGENT "$@"
     mesg "couldn't exec $AGENT"

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-03-24  2:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-03-09 15:39 the match_flags support Gioele Barabucci
2001-03-09 22:43 ` Matthew Dharm
2001-03-10 12:44 ` Gioele Barabucci
2001-03-24  2:49 ` David Brownell

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).