linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* hotplug patches: fixes and sysfs support
@ 2004-02-05  1:05 Marco d'Itri
  2004-02-13 11:01 ` Marco d'Itri
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Marco d'Itri @ 2004-02-05  1:05 UTC (permalink / raw)
  To: linux-hotplug

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

000_small_fixes: fixes for some small bugs.
001_no_bashisms: removes bashisms from all scripts.
003_no_useless_includes: remove some unused code.
004_2.6_pci_synthesis: adds sysfs support to pci.rc. Please review the
	usb.rc changes, there are some FIXME comments.

-- 
ciao, |
Marco | [4466 diwYqAwSWjuYU]

[-- Attachment #2: 000_small_fixes --]
[-- Type: text/plain, Size: 3433 bytes --]

diff -ruN hotplug-2004_01_05.orig/etc/hotplug/ieee1394.agent hotplug-2004_01_05/etc/hotplug/ieee1394.agent
--- hotplug-2004_01_05.orig/etc/hotplug/ieee1394.agent	2003-09-16 21:42:17.000000000 +0200
+++ hotplug-2004_01_05/etc/hotplug/ieee1394.agent	2004-02-04 20:53:28.000000000 +0100
@@ -98,7 +98,7 @@
     	load_drivers ieee1394 $MAP_CURRENT "$LABEL"
     fi
 
-    if [ "$DRIVERS" == "" ]; then
+    if [ "$DRIVERS" = "" ]; then
 	mesg "... no drivers for $LABEL"
 	exit 2
     fi
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/input.agent hotplug-2004_01_05/etc/hotplug/input.agent
--- hotplug-2004_01_05.orig/etc/hotplug/input.agent	2003-10-14 01:46:58.000000000 +0200
+++ hotplug-2004_01_05/etc/hotplug/input.agent	2004-02-04 20:58:05.000000000 +0100
@@ -154,7 +154,7 @@
     declare -i matchBits
     declare -i bustype vendor product version
     declare -i evBits driverInfo 
-    declare relBits mscBits ledBits sndBitskeyBits absBits ffBits
+    declare relBits mscBits ledBits sndBits keyBits absBits ffBits
 
     while read line
     do
@@ -172,7 +172,7 @@
 	bustype="$3"
 	vendor="$4"
 	product="$5"
-	product="$6"
+	version="$6"
 
 	evBits="$7"
 	keyBits="$8"
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/pci.agent hotplug-2004_01_05/etc/hotplug/pci.agent
--- hotplug-2004_01_05.orig/etc/hotplug/pci.agent	2003-09-16 21:42:17.000000000 +0200
+++ hotplug-2004_01_05/etc/hotplug/pci.agent	2004-02-04 20:53:28.000000000 +0100
@@ -154,7 +154,7 @@
     	load_drivers pci $MAP_CURRENT "$LABEL"
     fi
 
-    if [ "$DRIVERS" == "" ]; then
+    if [ "$DRIVERS" = "" ]; then
 	mesg "... no modules for $LABEL"
 	exit 2
     fi
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	2003-10-14 01:52:54.000000000 +0200
+++ hotplug-2004_01_05/etc/hotplug/usb.agent	2004-02-04 20:53:28.000000000 +0100
@@ -195,9 +195,9 @@
         usb_bDeviceProtocol=$3
 	IFS="$DEFAULT_IFS"
     elif [ -r $SYSFS/$DEVPATH/bDeviceClass ]; then
-	usb_bDeviceClass=0x$(cat $SYSFS/$DEVPATH/bDeviceClass)
-	usb_bDeviceSubClass=0x$(cat $SYSFS/$DEVPATH/bDeviceSubClass)
-	usb_bDeviceProtocol=0x$(cat $SYSFS/$DEVPATH/bDeviceProtocol)
+	usb_bDeviceClass=$(cat $SYSFS/$DEVPATH/bDeviceClass)
+	usb_bDeviceSubClass=$(cat $SYSFS/$DEVPATH/bDeviceSubClass)
+	usb_bDeviceProtocol=$(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=0x$(cat $SYSFS/$DEVPATH/bInterfaceClass)
-	usb_bInterfaceSubClass=0x$(cat $SYSFS/$DEVPATH/bInterfaceSubClass)
-	usb_bInterfaceProtocol=0x$(cat $SYSFS/$DEVPATH/bInterfaceProtocol)
+	usb_bInterfaceClass=$(cat $SYSFS/$DEVPATH/bInterfaceClass)
+	usb_bInterfaceSubClass=$(cat $SYSFS/$DEVPATH/bInterfaceSubClass)
+	usb_bInterfaceProtocol=$(cat $SYSFS/$DEVPATH/bInterfaceProtocol)
     else
 	# out-of-range values
 	usb_bInterfaceClass=1000
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	2003-09-25 02:09:08.000000000 +0200
+++ hotplug-2004_01_05/etc/hotplug/usb.rc	2004-02-04 20:53:28.000000000 +0100
@@ -21,6 +21,9 @@
 
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 
+unset I_WANT_A_BROKEN_PS
+PS_PERSONALITY=linux
+
 STATIC_MODULE_LIST=
 X11_USBMICE_HACK=false
 

[-- Attachment #3: 001_no_bashisms --]
[-- Type: text/plain, Size: 16004 bytes --]

diff -ruN hotplug-2004_01_05.orig/etc/hotplug/firmware.agent hotplug-2004_01_05/etc/hotplug/firmware.agent
--- hotplug-2004_01_05.orig/etc/hotplug/firmware.agent	2003-10-07 21:34:19.000000000 +0200
+++ hotplug-2004_01_05/etc/hotplug/firmware.agent	2004-02-03 01:21:16.000000000 +0100
@@ -16,7 +16,7 @@
 #
 
 cd /etc/hotplug
-. hotplug.functions
+. ./hotplug.functions
 # DEBUG=yes export DEBUG
 
 # directory of the firmware files
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/hotplug.functions hotplug-2004_01_05/etc/hotplug/hotplug.functions
--- hotplug-2004_01_05.orig/etc/hotplug/hotplug.functions	2003-10-07 23:15:38.000000000 +0200
+++ hotplug-2004_01_05/etc/hotplug/hotplug.functions	2004-02-03 01:21:19.000000000 +0100
@@ -32,7 +32,7 @@
 #
 # for diagnostics
 #
-if [ -t -o -z "$LOGGER" ]; then
+if [ -t 1 -o -z "$LOGGER" ]; then
     mesg () {
 	echo "$@"
     }
@@ -47,17 +47,6 @@
     mesg "$@"
 }
 
-#
-# The modules.*map parsing uses BASH ("declare -i") and some version
-# of AWK, typically /bin/gawk.  Most GNU/Linux distros have these,
-# but some specialized ones (floppy based, etc) may not.  ("type -p"
-# is also a bash-ism, more robust than "which".)
-#
-AWK=`type -p gawk`
-if [ "$AWK" = "" ]; then
-    AWK=`type -p awk`
-fi
-
 
 #
 # Not "modprobe --autoclean" ... one driver module can handle many
@@ -92,7 +81,7 @@
     # ought to expose the data we need to find all candidate drivers.
     # (on 2.5.48 it does for usb; but maybe not yet for pci.)
     case "$KERNEL" in
-    2.2*|2.3*|2.4*)	LISTER=`type -p ${TYPE}modules` ;;
+    2.2*|2.3*|2.4*)	LISTER=`which ${TYPE}modules` ;;
     *)			LISTER="" ;;
     esac
 
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/ieee1394.agent hotplug-2004_01_05/etc/hotplug/ieee1394.agent
--- hotplug-2004_01_05.orig/etc/hotplug/ieee1394.agent	2004-02-03 01:21:26.000000000 +0100
+++ hotplug-2004_01_05/etc/hotplug/ieee1394.agent	2004-02-03 01:21:16.000000000 +0100
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 # IEEE1394-specific hotplug policy agent.
 #
@@ -24,7 +24,7 @@
 #
 
 cd /etc/hotplug
-. hotplug.functions
+. ./hotplug.functions
 # DEBUG=yes export DEBUG
 
 # generated by modutils 2.4.9 or later, for 2.4.10 and later kernels
@@ -39,12 +39,10 @@
 fi
 
 
-declare -i device_vendor_id device_specifier_id device_version
-device_vendor_id="0x$VENDOR_ID"
-device_specifier_id="0x$SPECIFIER_ID"
-device_version="0x$VERSION"
+device_vendor_id=$((0x$VENDOR_ID))
+device_specifier_id=$((0x$SPECIFIER_ID))
+device_version=$((0x$VERSION))
 
-declare -i MATCH_VENDOR_ID MATCH_SPECIFIER_ID MATCH_VERSION
 MATCH_VENDOR_ID=0x0001
 MATCH_SPECIFIER_ID=0x0004
 MATCH_VERSION=0x0008
@@ -56,8 +54,11 @@
 ieee1394_map_modules ()
 {
     local module ignored
-    declare -i match_flags vendor_id model_id
-    declare -i specifier_id version
+
+    # convert from hex to dec
+    match_flags=$(($match_flags))
+    vendor_id=$(($vendor_id)); model_id=$(($model_id))
+    specifier_id=$(($specifier_id)); version=$(($version))
 
     # comment line lists (current) pci_device_id field names
     read ignored
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/input.agent hotplug-2004_01_05/etc/hotplug/input.agent
--- hotplug-2004_01_05.orig/etc/hotplug/input.agent	2003-10-14 01:46:58.000000000 +0200
+++ hotplug-2004_01_05/etc/hotplug/input.agent	2004-02-03 01:21:21.000000000 +0100
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 # input-specific hotplug policy agent.
 #
@@ -30,7 +30,7 @@
 #
 
 cd /etc/hotplug
-. hotplug.functions
+. ./hotplug.functions
 # DEBUG=yes export DEBUG
 
 # generated by module-init-tools
@@ -51,21 +51,18 @@
 # Each modules.inputmap format line corresponds to one entry in a
 # MODULE_DEVICE_TABLE(input,...) declaration in a kernel file.
 #
-declare -i matchBits=0
-declare -i i_bustype=0 i_vendor=0 i_product=0 i_version=0
-declare -i i_evBits=0
-declare i_keyBits i_relBits i_absBits i_mscBits i_ledBits i_sndBits i_ffBits
+matchBits=0; i_bustype=0; i_vendor=0; i_product=0; i_version=0; i_evBits=0
 
 input_join_words ()
 {
-    declare name=$1 array=$2 tmp
+    local name="$1" array="$2" tmp
     if [ "$array" = '' ]; then
 	return
     fi
 
     set $array
 
-    tmp=$1
+    tmp="$1"
     shift
     while [ "$#" -gt 0 ]; do
 	tmp="$tmp:$1"
@@ -81,14 +78,14 @@
 	IFS=/
 	set $PRODUCT ''
 	IFS="$DEFAULT_IFS"
-	i_bustype=0x$1
-	i_vendor=0x$2
-	i_product=0x$3
-	i_version=0x$4
+	i_bustype=$((0x$1))
+	i_vendor=$((0x$2))
+	i_product=$((0x$3))
+	i_version=$((0x$4))
     fi
 
     if [ "$EV" != "" ]; then
-	i_evBits=0x$EV
+	i_evBits=$((0x$EV))
     fi
 
     input_join_words i_keyBits "$KEY"
@@ -100,27 +97,26 @@
     input_join_words i_ffBits  "$FF"
 }
 
-declare -i INPUT_DEVICE_ID_MATCH_BUS=1
-declare -i INPUT_DEVICE_ID_MATCH_VENDOR=2
-declare -i INPUT_DEVICE_ID_MATCH_PRODUCT=4
-declare -i INPUT_DEVICE_ID_MATCH_VERSION=8
-declare -i INPUT_DEVICE_ID_MATCH_EVBIT=0x010
-declare -i INPUT_DEVICE_ID_MATCH_KEYBIT=0x020
-declare -i INPUT_DEVICE_ID_MATCH_RELBIT=0x040
-declare -i INPUT_DEVICE_ID_MATCH_ABSBIT=0x080
-declare -i INPUT_DEVICE_ID_MATCH_MSCBIT=0x100
-declare -i INPUT_DEVICE_ID_MATCH_LEDBIT=0x200
-declare -i INPUT_DEVICE_ID_MATCH_SNDBIT=0x400
-declare -i INPUT_DEVICE_ID_MATCH_FFBIT=0x800
+INPUT_DEVICE_ID_MATCH_BUS=1
+INPUT_DEVICE_ID_MATCH_VENDOR=2
+INPUT_DEVICE_ID_MATCH_PRODUCT=4
+INPUT_DEVICE_ID_MATCH_VERSION=8
+INPUT_DEVICE_ID_MATCH_EVBIT=$((0x010))
+INPUT_DEVICE_ID_MATCH_KEYBIT=$((0x020))
+INPUT_DEVICE_ID_MATCH_RELBIT=$((0x040))
+INPUT_DEVICE_ID_MATCH_ABSBIT=$((0x080))
+INPUT_DEVICE_ID_MATCH_MSCBIT=$((0x100))
+INPUT_DEVICE_ID_MATCH_LEDBIT=$((0x200))
+INPUT_DEVICE_ID_MATCH_SNDBIT=$((0x400))
+INPUT_DEVICE_ID_MATCH_FFBIT=$((0x800))
 
 
 input_match_bits ()
 {
-    declare mod_bits=$1 dev_bits=$2
-    declare -i mword dword
+    local mod_bits=$1 dev_bits=$2
 
-    mword=0x${mod_bits##*:}
-    dword=0x${dev_bits##*:}
+    mword=$((0x${mod_bits##*:}))
+    dword=$((0x${dev_bits##*:}))
 
     while true; do
 	if [ $(( $mword & $dword != $mword )) -eq 1 ]; then
@@ -151,10 +147,7 @@
 input_map_modules ()
 {
     local line module
-    declare -i matchBits
-    declare -i bustype vendor product version
-    declare -i evBits driverInfo 
-    declare relBits mscBits ledBits sndBits keyBits absBits ffBits
+    local relBits mscBits ledBits sndBits keyBits absBits ffBits
 
     while read line
     do
@@ -167,24 +160,24 @@
 	set $line
 
 	module="$1"
-	matchBits="$2"
+	matchBits=$(($2))
 
-	bustype="$3"
-	vendor="$4"
-	product="$5"
-	version="$6"
-
-	evBits="$7"
-	keyBits="$8"
-	relBits="$9"
+	bustype=$(($3))
+	vendor=$(($4))
+	product=$(($5))
+	version=$(($6))
+
+	evBits=$(($7))
+	keyBits=$(($8))
+	relBits=$(($9))
 
 	shift 9
-	absBits="$1"
-	cbsBits="$2"
-	ledBits="$3"
-	sndBits="$4"
-	ffBits="$5"
-	driverInfo="$6"
+	absBits=$(($1))
+	cbsBits=$(($2))
+	ledBits=$(($3))
+	sndBits=$(($4))
+	ffBits=$(($5))
+	driverInfo=$(($6))
 
 	: checkmatch $module
 
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/input.rc hotplug-2004_01_05/etc/hotplug/input.rc
--- hotplug-2004_01_05.orig/etc/hotplug/input.rc	2003-10-14 01:46:58.000000000 +0200
+++ hotplug-2004_01_05/etc/hotplug/input.rc	2004-02-03 01:21:16.000000000 +0100
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 # input.rc	This loads handlers for those input devices
 #		that have drivers compiled in kernel
@@ -61,7 +61,7 @@
     export PRODUCT NAME PHYS EV KEY REL ABS MSC LED SND FF
     input_reset_state
 
-    declare line
+    local line
 
     #
     # the following reads from /proc/bus/input/devices. It is inherently
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/net.agent hotplug-2004_01_05/etc/hotplug/net.agent
--- hotplug-2004_01_05.orig/etc/hotplug/net.agent	2003-10-07 21:56:24.000000000 +0200
+++ hotplug-2004_01_05/etc/hotplug/net.agent	2004-02-03 01:21:16.000000000 +0100
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 # Network hotplug policy agent for Linux 2.4 kernels
 #
@@ -17,7 +17,7 @@
 #
 
 cd /etc/hotplug
-. hotplug.functions
+. ./hotplug.functions
 # DEBUG=yes export DEBUG
 
 if [ "$INTERFACE" = "" ]; then
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/pci.agent hotplug-2004_01_05/etc/hotplug/pci.agent
--- hotplug-2004_01_05.orig/etc/hotplug/pci.agent	2004-02-03 01:21:26.000000000 +0100
+++ hotplug-2004_01_05/etc/hotplug/pci.agent	2004-02-03 01:21:16.000000000 +0100
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 # PCI-specific hotplug policy agent.
 #
@@ -33,7 +33,7 @@
 #
 
 cd /etc/hotplug
-. hotplug.functions
+. ./hotplug.functions
 
 # generated by modutils, for current 2.4.x kernels
 MAP_CURRENT=$MODULE_DIR/modules.pcimap
@@ -57,31 +57,20 @@
 # extra filtering.
 #
 
-# inputs to the match algorithm, from kernel by way of /sbin/hotplug
-declare -i pci_class
-declare -i pci_id_vendor pci_id_device
-declare -i pci_subid_vendor pci_subid_device
-
 pci_convert_vars ()
 {
-    if [ "$AWK" = "" ]; then
-	mesg "can't find awk!"
-	exit 1
-    fi
+    pci_class=$((0x$PCI_CLASS))
 
-    pci_class=0x$PCI_CLASS
-
-    set `echo $PCI_ID | $AWK -F: '{print "0x" $1, "0x" $2 }'` ''
-    pci_id_vendor=$1
-    pci_id_device=$2
-
-    set `echo $PCI_SUBSYS_ID | $AWK -F: '{print "0x" $1, "0x" $2 }'` ''
-    pci_subid_vendor=$1
-    pci_subid_device=$2
+    set $(echo $PCI_ID | sed -e 's/\([^:]*\):\(.*\)/\1 \2/')
+    pci_id_vendor=$((0x$1))
+    pci_id_device=$((0x$2))
+
+    set $(echo $PCI_SUBSYS_ID | sed -e 's/\([^:]*\):\(.*\)/\1 \2/')
+    pci_subid_vendor=$((0x$1))
+    pci_subid_device=$((0x$2))
 }
 
-declare -i PCI_ANY
-PCI_ANY=0xffffffff
+PCI_ANY=$((0xffffffff))
 
 
 #
@@ -90,12 +79,7 @@
 #
 pci_map_modules ()
 {
-    # convert the usb_device_id fields to integers as we read them 
     local module ignored
-    declare -i vendor device
-    declare -i subvendor subdevice
-    declare -i class class_mask
-    declare -i class_temp
 
     # comment line lists (current) pci_device_id field names
     read ignored
@@ -110,6 +94,11 @@
 	\#*) continue ;;
 	esac
 
+	# convert the fields from hex to dec
+	vendor=$(($vendor)); device=$(($device))
+	subvendor=$(($subvendor)); subdevice=$(($subdevice))
+	class=$(($class)); class_mask=$(($class_mask))
+
 	: checkmatch $module
 
 	: vendor $vendor $pci_id_vendor
@@ -129,7 +118,7 @@
 	    continue
 	fi
 
-	class_temp="$pci_class & $class_mask"
+	class_temp=$(($pci_class & $class_mask))
 	if [ $class_temp -eq $class ]; then
 	    DRIVERS="$module $DRIVERS"
 	    : drivers $DRIVERS
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/pci.rc hotplug-2004_01_05/etc/hotplug/pci.rc
--- hotplug-2004_01_05.orig/etc/hotplug/pci.rc	2003-06-28 02:13:10.000000000 +0200
+++ hotplug-2004_01_05/etc/hotplug/pci.rc	2004-02-03 01:21:16.000000000 +0100
@@ -17,7 +17,7 @@
 	. /etc/rc.d/init.d/functions
 fi
 
-. hotplug.functions
+. ./hotplug.functions
 
 
 # # override any of the defaults?
@@ -32,7 +32,7 @@
     # information, and more can be gotten with 'lspci'.
     # don't expect pcimodules to exist!!
     #
-    LISTER=`type -p pcimodules`
+    LISTER=`which pcimodules`
     if [ "$LISTER" = "" -o ! -f /proc/bus/pci/devices -o ! -x pci.agent ]; then
 	    echo $"** can't synthesize pci hotplug events"
 	    return
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/scsi.agent hotplug-2004_01_05/etc/hotplug/scsi.agent
--- hotplug-2004_01_05.orig/etc/hotplug/scsi.agent	2002-12-11 23:05:06.000000000 +0100
+++ hotplug-2004_01_05/etc/hotplug/scsi.agent	2004-02-03 01:21:16.000000000 +0100
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 # SCSI hotplug agent for 2.5 kernels 
 #
@@ -7,7 +7,7 @@
 #
 
 cd /etc/hotplug
-. hotplug.functions
+. ./hotplug.functions
 
 case $ACTION in
 
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-03 01:21:26.000000000 +0100
+++ hotplug-2004_01_05/etc/hotplug/usb.agent	2004-02-03 01:21:16.000000000 +0100
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 # USB-specific hotplug policy agent.
 #
@@ -79,7 +79,7 @@
 fi
 
 cd /etc/hotplug
-. hotplug.functions
+. ./hotplug.functions
 # DEBUG=yes export DEBUG
 
 # generated by modutils, for current 2.4.x (and later) kernels
@@ -165,27 +165,19 @@
 # mechanism, but some driver probe() routines need to provide
 # extra filtering.
 #
-declare -i usb_idVendor usb_idProduct usb_bcdDevice
-declare -i usb_bDeviceClass usb_bDeviceSubClass usb_bDeviceProtocol
-declare -i usb_bInterfaceClass usb_bInterfaceSubClass usb_bInterfaceProtocol
 
 usb_convert_vars ()
 {
-    if [ "$AWK" = "" ]; then
-	mesg "can't find awk!"
-	exit 1
-    fi
-
     # work around 2.2.early brokenness
     # munges the usb_bcdDevice such that it is a integer rather
     # than a float: e.g. 1.0 become 0100
     PRODUCT=`echo $PRODUCT | sed -e "s+\.\([0-9]\)$+.\10+" -e "s/\.$/00/" \
                                   -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
+    set $(echo $PRODUCT | sed -e 's+\([^/]*\)/\([^/]*\)/\(.*\)+\1 \2 \3+')
+    usb_idVendor=$((0x$1))
+    usb_idProduct=$((0x$2))
+    usb_bcdDevice=$((0x$3))
 
     if [ "$TYPE" != "" ]; then
     	IFS=/
@@ -224,16 +216,16 @@
     fi
 }
 
-declare -i USB_MATCH_VENDOR=0x0001
-declare -i USB_MATCH_PRODUCT=0x0002
-declare -i USB_MATCH_DEV_LO=0x0004
-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
+USB_MATCH_VENDOR=$((0x0001))
+USB_MATCH_PRODUCT=$((0x0002))
+USB_MATCH_DEV_LO=$((0x0004))
+USB_MATCH_DEV_HI=$((0x0008))
+USB_MATCH_DEV_CLASS=$((0x0010))
+USB_MATCH_DEV_SUBCLASS=$((0x0020))
+USB_MATCH_DEV_PROTOCOL=$((0x0040))
+USB_MATCH_INT_CLASS=$((0x0080))
+USB_MATCH_INT_SUBCLASS=$((0x0100))
+USB_MATCH_INT_PROTOCOL=$((0x0200))
 
 #
 # stdin is "modules.usbmap" syntax
@@ -241,12 +233,7 @@
 #
 usb_map_modules ()
 {
-    # convert the usb_device_id fields to integers as we read them 
     local line module
-    declare -i match_flags
-    declare -i idVendor idProduct bcdDevice_lo bcdDevice_hi
-    declare -i bDeviceClass bDeviceSubClass bDeviceProtocol
-    declare -i bInterfaceClass bInterfaceSubClass bInterfaceProtocol
 
     # look at each usb_device_id entry
     # collect all matches in $DRIVERS
@@ -262,21 +249,21 @@
 	set $line
 
 	module=$1
-	match_flags=$2
+	match_flags=$(($2))
 
-	idVendor=$3
-	idProduct=$4
-	bcdDevice_lo=$5
-	bcdDevice_hi=$6
-
-	bDeviceClass=$7
-	bDeviceSubClass=$8
-	bDeviceProtocol=$9
+	idVendor=$(($3))
+	idProduct=$(($4))
+	bcdDevice_lo=$(($5))
+	bcdDevice_hi=$(($6))
+
+	bDeviceClass=$(($7))
+	bDeviceSubClass=$(($8))
+	bDeviceProtocol=$(($9))
 
 	shift 9
-	bInterfaceClass=$1
-	bInterfaceSubClass=$2
-	bInterfaceProtocol=$3
+	bInterfaceClass=$(($1))
+	bInterfaceSubClass=$(($2))
+	bInterfaceProtocol=$(($3))
 
 	: checkmatch $module
 
@@ -350,10 +337,11 @@
 # remover, or that the remove action can use to execute a remover.
 #
 if [ "$DEVICE" = "" ]; then
-  declare -rx REMOVER=/var/run/usb/`echo "$INTERFACE/$PRODUCT/$TYPE" | sed -e 's;/;%;g'`
+  REMOVER=/var/run/usb/`echo "$INTERFACE/$PRODUCT/$TYPE" | sed -e 's;/;%;g'`
 else
-  declare -rx REMOVER=/var/run/usb/`echo $DEVICE | sed -e 's;/;%;g'`
+  REMOVER=/var/run/usb/`echo $DEVICE | sed -e 's;/;%;g'`
 fi
+export REMOVER
 
 #
 # What to do with this USB hotplug event?
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-03 01:21:26.000000000 +0100
+++ hotplug-2004_01_05/etc/hotplug/usb.rc	2004-02-03 01:21:16.000000000 +0100
@@ -79,7 +79,7 @@
 
 	# synthesize hotplug events if we can 
 	# we need (non-bash) programs to parse descriptors.
-	LISTER=`type -p usbmodules`
+	LISTER=`which usbmodules`
 	if [ "$LISTER" = "" -o ! -f /proc/bus/usb/devices ]; then
 		echo $"** can't synthesize root hub events"
 		return

[-- Attachment #4: 003_no_useless_includes --]
[-- Type: text/plain, Size: 1263 bytes --]

diff -ruN hotplug-2004_01_05.orig/etc/hotplug/pci.rc hotplug-2004_01_05/etc/hotplug/pci.rc
--- hotplug-2004_01_05.orig/etc/hotplug/pci.rc	2004-02-01 17:36:26.000000000 +0100
+++ hotplug-2004_01_05/etc/hotplug/pci.rc	2004-02-01 17:34:59.000000000 +0100
@@ -9,22 +9,8 @@
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 
 cd /etc/hotplug
-
-# source function library
-if [ -f /etc/init.d/functions ]; then
-	. /etc/init.d/functions
-elif [ -f /etc/rc.d/init.d/functions ]; then
-	. /etc/rc.d/init.d/functions
-fi
-
 . ./hotplug.functions
 
-
-# # override any of the defaults?
-# if [ -f /etc/sysconfig/pci ]; then
-#     . /etc/sysconfig/pci
-# fi
-
 pci_boot_events ()
 {
     #
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 17:36:26.000000000 +0100
+++ hotplug-2004_01_05/etc/hotplug/usb.rc	2004-02-01 17:36:19.000000000 +0100
@@ -27,14 +27,6 @@
 STATIC_MODULE_LIST=
 X11_USBMICE_HACK=false
 
-# source function library
-if [ -f /etc/init.d/functions ]; then
-	. /etc/init.d/functions
-elif [ -f /etc/rc.d/init.d/functions ]; then
-	. /etc/rc.d/init.d/functions
-fi
-
-
 # override any of the defaults above?
 if [ -f /etc/sysconfig/usb ]; then
     . /etc/sysconfig/usb

[-- Attachment #5: 004_2.6_pci_synthesis --]
[-- Type: text/plain, Size: 5194 bytes --]

diff -ruN hotplug-2004_01_05.orig/etc/hotplug/pci.rc hotplug-2004_01_05/etc/hotplug/pci.rc
--- hotplug-2004_01_05.orig/etc/hotplug/pci.rc	2004-02-01 18:00:45.000000000 +0100
+++ hotplug-2004_01_05/etc/hotplug/pci.rc	2004-02-01 17:49:59.000000000 +0100
@@ -13,33 +13,51 @@
 
 pci_boot_events ()
 {
-    #
-    # FIXME on 2.5, /sys/bus/pci/devices gives some of this
-    # information, and more can be gotten with 'lspci'.
-    # don't expect pcimodules to exist!!
-    #
-    LISTER=`which pcimodules`
-    if [ "$LISTER" = "" -o ! -f /proc/bus/pci/devices -o ! -x pci.agent ]; then
-	    echo $"** can't synthesize pci hotplug events"
-	    return
-    fi
-
     # make sure the pci agent will run
     ACTION=add
     PCI_CLASS=0
     PCI_ID=0:0
     PCI_SLOT=0:0.0
+    PCI_SLOT_NAME=0:0.0
     PCI_SUBSYS_ID=0:0
-    export ACTION PCI_CLASS PCI_ID PCI_SLOT PCI_SUBSYS_ID
+    export ACTION PCI_CLASS PCI_ID PCI_SLOT PCI_SLOT_NAME PCI_SUBSYS_ID
 
-    # 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
-	    PCI_SLOT=$BUS:$SLOT_FUNC
-	    : hotplug pci for $PCI_SLOT
+    if [ -d /sys/bus/pci/devices/ ]; then
+	# 2.6 kernels
+	cd /sys/bus/pci/devices/
+	for PCI_DEVICE in *; do
+	    set `echo $PCI_DEVICE \
+		| sed -e 's/\([^:]*\):\(.*\):\(.*\)\.\(.*\)/\1 \2 \3 \4/'`
+	    PCI_SLOT_NAME=$2:$3.$4
+	    PCI_CLASS="`cat $PCI_DEVICE/class`"
+	    PCI_CLASS=${PCI_CLASS#0x}
+	    vendor_id=`cat $PCI_DEVICE/vendor`
+	    device_id=`cat $PCI_DEVICE/device`
+	    PCI_ID="${vendor_id#0x}:${device_id#0x}"
+	    sub_vendor_id=`cat $PCI_DEVICE/subsystem_vendor`
+	    sub_device_id=`cat $PCI_DEVICE/subsystem_device`
+	    PCI_SUBSYS_ID="${sub_vendor_id#0x}:${sub_device_id#0x}"
 	    /sbin/hotplug pci
 	done
-    done
+    else
+	# 2.4 kernels
+	LISTER=`which pcimodules`
+	if [ "$LISTER" = "" -o ! -f /proc/bus/pci/devices
+		 -o ! -x pci.agent ]; then
+	    echo $"** can't synthesize pci hotplug events"
+	    return
+	fi
+
+	# 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
+		PCI_SLOT=$BUS:$SLOT_FUNC
+		/sbin/hotplug pci
+	    done
+	done
+    fi
+
+    return 0
 }
 
 # See how we were called.
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

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

* Re: hotplug patches: fixes and sysfs support
  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
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Marco d'Itri @ 2004-02-13 11:01 UTC (permalink / raw)
  To: linux-hotplug

On Feb 05, Marco d'Itri <md@Linux.IT> wrote:

 >000_small_fixes: fixes for some small bugs.
 >001_no_bashisms: removes bashisms from all scripts.
 >003_no_useless_includes: remove some unused code.
 >004_2.6_pci_synthesis: adds sysfs support to pci.rc. Please review the
 >	usb.rc changes, there are some FIXME comments.

Can somebody comment on my changes, please?

-- 
ciao, |
Marco | [4588 ig4lU9LGc0d5o]


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id\x1356&alloc_id438&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

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

* Re: hotplug patches: fixes and sysfs support
  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
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Marco d'Itri @ 2004-02-21 17:48 UTC (permalink / raw)
  To: linux-hotplug

On Feb 13, Marco d'Itri <md@Linux.IT> wrote:
 >On Feb 05, Marco d'Itri <md@Linux.IT> wrote:
 > >000_small_fixes: fixes for some small bugs.
 > >001_no_bashisms: removes bashisms from all scripts.
 > >003_no_useless_includes: remove some unused code.
 > >004_2.6_pci_synthesis: adds sysfs support to pci.rc. Please review the
 > >	usb.rc changes, there are some FIXME comments.
 >Can somebody comment on my changes, please?
Is anybody interested in this work?

-- 
ciao, |
Marco | [4694 das6uB.CJbQ56]


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id\x1356&alloc_id438&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

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

* Re: hotplug patches: fixes and sysfs support
  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
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Marco d'Itri @ 2004-02-28 14:50 UTC (permalink / raw)
  To: linux-hotplug

On Feb 21, Marco d'Itri <md@Linux.IT> wrote:
 >On Feb 13, Marco d'Itri <md@Linux.IT> wrote:
 > >On Feb 05, Marco d'Itri <md@Linux.IT> wrote:
 > > >000_small_fixes: fixes for some small bugs.
 > > >001_no_bashisms: removes bashisms from all scripts.
 > > >003_no_useless_includes: remove some unused code.
 > > >004_2.6_pci_synthesis: adds sysfs support to pci.rc. Please review the
 > > >	usb.rc changes, there are some FIXME comments.
 > >Can somebody comment on my changes, please?
 >Is anybody interested in this work?
Is anybody still interested in maintaining hotplug?

-- 
ciao, |
Marco | [4800 ri0G4EaUVs5OQ]


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id\x1356&alloc_id438&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

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

* hotplug patches: fixes and sysfs support 1/5
  2004-02-05  1:05 hotplug patches: fixes and sysfs support Marco d'Itri
                   ` (2 preceding siblings ...)
  2004-02-28 14:50 ` Marco d'Itri
@ 2004-03-07 12:42 ` Marco d'Itri
  2004-03-07 12:43 ` hotplug patches: fixes and sysfs support 2/5 Marco d'Itri
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Marco d'Itri @ 2004-03-07 12:42 UTC (permalink / raw)
  To: linux-hotplug

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

000_small_fixes: fixed some small bugs.

-- 
ciao, |
Marco | [4956 adXbsurXEy5zg]

[-- Attachment #2: 000_small_fixes --]
[-- Type: text/plain, Size: 3433 bytes --]

diff -ruN hotplug-2004_01_05.orig/etc/hotplug/ieee1394.agent hotplug-2004_01_05/etc/hotplug/ieee1394.agent
--- hotplug-2004_01_05.orig/etc/hotplug/ieee1394.agent	2003-09-16 21:42:17.000000000 +0200
+++ hotplug-2004_01_05/etc/hotplug/ieee1394.agent	2004-02-04 20:53:28.000000000 +0100
@@ -98,7 +98,7 @@
     	load_drivers ieee1394 $MAP_CURRENT "$LABEL"
     fi
 
-    if [ "$DRIVERS" == "" ]; then
+    if [ "$DRIVERS" = "" ]; then
 	mesg "... no drivers for $LABEL"
 	exit 2
     fi
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/input.agent hotplug-2004_01_05/etc/hotplug/input.agent
--- hotplug-2004_01_05.orig/etc/hotplug/input.agent	2003-10-14 01:46:58.000000000 +0200
+++ hotplug-2004_01_05/etc/hotplug/input.agent	2004-02-04 20:58:05.000000000 +0100
@@ -154,7 +154,7 @@
     declare -i matchBits
     declare -i bustype vendor product version
     declare -i evBits driverInfo 
-    declare relBits mscBits ledBits sndBitskeyBits absBits ffBits
+    declare relBits mscBits ledBits sndBits keyBits absBits ffBits
 
     while read line
     do
@@ -172,7 +172,7 @@
 	bustype="$3"
 	vendor="$4"
 	product="$5"
-	product="$6"
+	version="$6"
 
 	evBits="$7"
 	keyBits="$8"
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/pci.agent hotplug-2004_01_05/etc/hotplug/pci.agent
--- hotplug-2004_01_05.orig/etc/hotplug/pci.agent	2003-09-16 21:42:17.000000000 +0200
+++ hotplug-2004_01_05/etc/hotplug/pci.agent	2004-02-04 20:53:28.000000000 +0100
@@ -154,7 +154,7 @@
     	load_drivers pci $MAP_CURRENT "$LABEL"
     fi
 
-    if [ "$DRIVERS" == "" ]; then
+    if [ "$DRIVERS" = "" ]; then
 	mesg "... no modules for $LABEL"
 	exit 2
     fi
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	2003-10-14 01:52:54.000000000 +0200
+++ hotplug-2004_01_05/etc/hotplug/usb.agent	2004-02-04 20:53:28.000000000 +0100
@@ -195,9 +195,9 @@
         usb_bDeviceProtocol=$3
 	IFS="$DEFAULT_IFS"
     elif [ -r $SYSFS/$DEVPATH/bDeviceClass ]; then
-	usb_bDeviceClass=0x$(cat $SYSFS/$DEVPATH/bDeviceClass)
-	usb_bDeviceSubClass=0x$(cat $SYSFS/$DEVPATH/bDeviceSubClass)
-	usb_bDeviceProtocol=0x$(cat $SYSFS/$DEVPATH/bDeviceProtocol)
+	usb_bDeviceClass=$(cat $SYSFS/$DEVPATH/bDeviceClass)
+	usb_bDeviceSubClass=$(cat $SYSFS/$DEVPATH/bDeviceSubClass)
+	usb_bDeviceProtocol=$(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=0x$(cat $SYSFS/$DEVPATH/bInterfaceClass)
-	usb_bInterfaceSubClass=0x$(cat $SYSFS/$DEVPATH/bInterfaceSubClass)
-	usb_bInterfaceProtocol=0x$(cat $SYSFS/$DEVPATH/bInterfaceProtocol)
+	usb_bInterfaceClass=$(cat $SYSFS/$DEVPATH/bInterfaceClass)
+	usb_bInterfaceSubClass=$(cat $SYSFS/$DEVPATH/bInterfaceSubClass)
+	usb_bInterfaceProtocol=$(cat $SYSFS/$DEVPATH/bInterfaceProtocol)
     else
 	# out-of-range values
 	usb_bInterfaceClass=1000
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	2003-09-25 02:09:08.000000000 +0200
+++ hotplug-2004_01_05/etc/hotplug/usb.rc	2004-02-04 20:53:28.000000000 +0100
@@ -21,6 +21,9 @@
 
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 
+unset I_WANT_A_BROKEN_PS
+PS_PERSONALITY=linux
+
 STATIC_MODULE_LIST=
 X11_USBMICE_HACK=false
 

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

* hotplug patches: fixes and sysfs support 2/5
  2004-02-05  1:05 hotplug patches: fixes and sysfs support Marco d'Itri
                   ` (3 preceding siblings ...)
  2004-03-07 12:42 ` hotplug patches: fixes and sysfs support 1/5 Marco d'Itri
@ 2004-03-07 12:43 ` Marco d'Itri
  2004-03-07 12:44 ` hotplug patches: fixes and sysfs support 3/5 Marco d'Itri
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Marco d'Itri @ 2004-03-07 12:43 UTC (permalink / raw)
  To: linux-hotplug

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

001_no_bashisms: removed bashisms from all scripts.

-- 
ciao, |
Marco | [4957 raw4F0e.nH4kU]

[-- Attachment #2: 001_no_bashisms --]
[-- Type: text/plain, Size: 16004 bytes --]

diff -ruN hotplug-2004_01_05.orig/etc/hotplug/firmware.agent hotplug-2004_01_05/etc/hotplug/firmware.agent
--- hotplug-2004_01_05.orig/etc/hotplug/firmware.agent	2003-10-07 21:34:19.000000000 +0200
+++ hotplug-2004_01_05/etc/hotplug/firmware.agent	2004-02-03 01:21:16.000000000 +0100
@@ -16,7 +16,7 @@
 #
 
 cd /etc/hotplug
-. hotplug.functions
+. ./hotplug.functions
 # DEBUG=yes export DEBUG
 
 # directory of the firmware files
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/hotplug.functions hotplug-2004_01_05/etc/hotplug/hotplug.functions
--- hotplug-2004_01_05.orig/etc/hotplug/hotplug.functions	2003-10-07 23:15:38.000000000 +0200
+++ hotplug-2004_01_05/etc/hotplug/hotplug.functions	2004-02-03 01:21:19.000000000 +0100
@@ -32,7 +32,7 @@
 #
 # for diagnostics
 #
-if [ -t -o -z "$LOGGER" ]; then
+if [ -t 1 -o -z "$LOGGER" ]; then
     mesg () {
 	echo "$@"
     }
@@ -47,17 +47,6 @@
     mesg "$@"
 }
 
-#
-# The modules.*map parsing uses BASH ("declare -i") and some version
-# of AWK, typically /bin/gawk.  Most GNU/Linux distros have these,
-# but some specialized ones (floppy based, etc) may not.  ("type -p"
-# is also a bash-ism, more robust than "which".)
-#
-AWK=`type -p gawk`
-if [ "$AWK" = "" ]; then
-    AWK=`type -p awk`
-fi
-
 
 #
 # Not "modprobe --autoclean" ... one driver module can handle many
@@ -92,7 +81,7 @@
     # ought to expose the data we need to find all candidate drivers.
     # (on 2.5.48 it does for usb; but maybe not yet for pci.)
     case "$KERNEL" in
-    2.2*|2.3*|2.4*)	LISTER=`type -p ${TYPE}modules` ;;
+    2.2*|2.3*|2.4*)	LISTER=`which ${TYPE}modules` ;;
     *)			LISTER="" ;;
     esac
 
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/ieee1394.agent hotplug-2004_01_05/etc/hotplug/ieee1394.agent
--- hotplug-2004_01_05.orig/etc/hotplug/ieee1394.agent	2004-02-03 01:21:26.000000000 +0100
+++ hotplug-2004_01_05/etc/hotplug/ieee1394.agent	2004-02-03 01:21:16.000000000 +0100
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 # IEEE1394-specific hotplug policy agent.
 #
@@ -24,7 +24,7 @@
 #
 
 cd /etc/hotplug
-. hotplug.functions
+. ./hotplug.functions
 # DEBUG=yes export DEBUG
 
 # generated by modutils 2.4.9 or later, for 2.4.10 and later kernels
@@ -39,12 +39,10 @@
 fi
 
 
-declare -i device_vendor_id device_specifier_id device_version
-device_vendor_id="0x$VENDOR_ID"
-device_specifier_id="0x$SPECIFIER_ID"
-device_version="0x$VERSION"
+device_vendor_id=$((0x$VENDOR_ID))
+device_specifier_id=$((0x$SPECIFIER_ID))
+device_version=$((0x$VERSION))
 
-declare -i MATCH_VENDOR_ID MATCH_SPECIFIER_ID MATCH_VERSION
 MATCH_VENDOR_ID=0x0001
 MATCH_SPECIFIER_ID=0x0004
 MATCH_VERSION=0x0008
@@ -56,8 +54,11 @@
 ieee1394_map_modules ()
 {
     local module ignored
-    declare -i match_flags vendor_id model_id
-    declare -i specifier_id version
+
+    # convert from hex to dec
+    match_flags=$(($match_flags))
+    vendor_id=$(($vendor_id)); model_id=$(($model_id))
+    specifier_id=$(($specifier_id)); version=$(($version))
 
     # comment line lists (current) pci_device_id field names
     read ignored
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/input.agent hotplug-2004_01_05/etc/hotplug/input.agent
--- hotplug-2004_01_05.orig/etc/hotplug/input.agent	2003-10-14 01:46:58.000000000 +0200
+++ hotplug-2004_01_05/etc/hotplug/input.agent	2004-02-03 01:21:21.000000000 +0100
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 # input-specific hotplug policy agent.
 #
@@ -30,7 +30,7 @@
 #
 
 cd /etc/hotplug
-. hotplug.functions
+. ./hotplug.functions
 # DEBUG=yes export DEBUG
 
 # generated by module-init-tools
@@ -51,21 +51,18 @@
 # Each modules.inputmap format line corresponds to one entry in a
 # MODULE_DEVICE_TABLE(input,...) declaration in a kernel file.
 #
-declare -i matchBits=0
-declare -i i_bustype=0 i_vendor=0 i_product=0 i_version=0
-declare -i i_evBits=0
-declare i_keyBits i_relBits i_absBits i_mscBits i_ledBits i_sndBits i_ffBits
+matchBits=0; i_bustype=0; i_vendor=0; i_product=0; i_version=0; i_evBits=0
 
 input_join_words ()
 {
-    declare name=$1 array=$2 tmp
+    local name="$1" array="$2" tmp
     if [ "$array" = '' ]; then
 	return
     fi
 
     set $array
 
-    tmp=$1
+    tmp="$1"
     shift
     while [ "$#" -gt 0 ]; do
 	tmp="$tmp:$1"
@@ -81,14 +78,14 @@
 	IFS=/
 	set $PRODUCT ''
 	IFS="$DEFAULT_IFS"
-	i_bustype=0x$1
-	i_vendor=0x$2
-	i_product=0x$3
-	i_version=0x$4
+	i_bustype=$((0x$1))
+	i_vendor=$((0x$2))
+	i_product=$((0x$3))
+	i_version=$((0x$4))
     fi
 
     if [ "$EV" != "" ]; then
-	i_evBits=0x$EV
+	i_evBits=$((0x$EV))
     fi
 
     input_join_words i_keyBits "$KEY"
@@ -100,27 +97,26 @@
     input_join_words i_ffBits  "$FF"
 }
 
-declare -i INPUT_DEVICE_ID_MATCH_BUS=1
-declare -i INPUT_DEVICE_ID_MATCH_VENDOR=2
-declare -i INPUT_DEVICE_ID_MATCH_PRODUCT=4
-declare -i INPUT_DEVICE_ID_MATCH_VERSION=8
-declare -i INPUT_DEVICE_ID_MATCH_EVBIT=0x010
-declare -i INPUT_DEVICE_ID_MATCH_KEYBIT=0x020
-declare -i INPUT_DEVICE_ID_MATCH_RELBIT=0x040
-declare -i INPUT_DEVICE_ID_MATCH_ABSBIT=0x080
-declare -i INPUT_DEVICE_ID_MATCH_MSCBIT=0x100
-declare -i INPUT_DEVICE_ID_MATCH_LEDBIT=0x200
-declare -i INPUT_DEVICE_ID_MATCH_SNDBIT=0x400
-declare -i INPUT_DEVICE_ID_MATCH_FFBIT=0x800
+INPUT_DEVICE_ID_MATCH_BUS=1
+INPUT_DEVICE_ID_MATCH_VENDOR=2
+INPUT_DEVICE_ID_MATCH_PRODUCT=4
+INPUT_DEVICE_ID_MATCH_VERSION=8
+INPUT_DEVICE_ID_MATCH_EVBIT=$((0x010))
+INPUT_DEVICE_ID_MATCH_KEYBIT=$((0x020))
+INPUT_DEVICE_ID_MATCH_RELBIT=$((0x040))
+INPUT_DEVICE_ID_MATCH_ABSBIT=$((0x080))
+INPUT_DEVICE_ID_MATCH_MSCBIT=$((0x100))
+INPUT_DEVICE_ID_MATCH_LEDBIT=$((0x200))
+INPUT_DEVICE_ID_MATCH_SNDBIT=$((0x400))
+INPUT_DEVICE_ID_MATCH_FFBIT=$((0x800))
 
 
 input_match_bits ()
 {
-    declare mod_bits=$1 dev_bits=$2
-    declare -i mword dword
+    local mod_bits=$1 dev_bits=$2
 
-    mword=0x${mod_bits##*:}
-    dword=0x${dev_bits##*:}
+    mword=$((0x${mod_bits##*:}))
+    dword=$((0x${dev_bits##*:}))
 
     while true; do
 	if [ $(( $mword & $dword != $mword )) -eq 1 ]; then
@@ -151,10 +147,7 @@
 input_map_modules ()
 {
     local line module
-    declare -i matchBits
-    declare -i bustype vendor product version
-    declare -i evBits driverInfo 
-    declare relBits mscBits ledBits sndBits keyBits absBits ffBits
+    local relBits mscBits ledBits sndBits keyBits absBits ffBits
 
     while read line
     do
@@ -167,24 +160,24 @@
 	set $line
 
 	module="$1"
-	matchBits="$2"
+	matchBits=$(($2))
 
-	bustype="$3"
-	vendor="$4"
-	product="$5"
-	version="$6"
-
-	evBits="$7"
-	keyBits="$8"
-	relBits="$9"
+	bustype=$(($3))
+	vendor=$(($4))
+	product=$(($5))
+	version=$(($6))
+
+	evBits=$(($7))
+	keyBits=$(($8))
+	relBits=$(($9))
 
 	shift 9
-	absBits="$1"
-	cbsBits="$2"
-	ledBits="$3"
-	sndBits="$4"
-	ffBits="$5"
-	driverInfo="$6"
+	absBits=$(($1))
+	cbsBits=$(($2))
+	ledBits=$(($3))
+	sndBits=$(($4))
+	ffBits=$(($5))
+	driverInfo=$(($6))
 
 	: checkmatch $module
 
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/input.rc hotplug-2004_01_05/etc/hotplug/input.rc
--- hotplug-2004_01_05.orig/etc/hotplug/input.rc	2003-10-14 01:46:58.000000000 +0200
+++ hotplug-2004_01_05/etc/hotplug/input.rc	2004-02-03 01:21:16.000000000 +0100
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 # input.rc	This loads handlers for those input devices
 #		that have drivers compiled in kernel
@@ -61,7 +61,7 @@
     export PRODUCT NAME PHYS EV KEY REL ABS MSC LED SND FF
     input_reset_state
 
-    declare line
+    local line
 
     #
     # the following reads from /proc/bus/input/devices. It is inherently
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/net.agent hotplug-2004_01_05/etc/hotplug/net.agent
--- hotplug-2004_01_05.orig/etc/hotplug/net.agent	2003-10-07 21:56:24.000000000 +0200
+++ hotplug-2004_01_05/etc/hotplug/net.agent	2004-02-03 01:21:16.000000000 +0100
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 # Network hotplug policy agent for Linux 2.4 kernels
 #
@@ -17,7 +17,7 @@
 #
 
 cd /etc/hotplug
-. hotplug.functions
+. ./hotplug.functions
 # DEBUG=yes export DEBUG
 
 if [ "$INTERFACE" = "" ]; then
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/pci.agent hotplug-2004_01_05/etc/hotplug/pci.agent
--- hotplug-2004_01_05.orig/etc/hotplug/pci.agent	2004-02-03 01:21:26.000000000 +0100
+++ hotplug-2004_01_05/etc/hotplug/pci.agent	2004-02-03 01:21:16.000000000 +0100
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 # PCI-specific hotplug policy agent.
 #
@@ -33,7 +33,7 @@
 #
 
 cd /etc/hotplug
-. hotplug.functions
+. ./hotplug.functions
 
 # generated by modutils, for current 2.4.x kernels
 MAP_CURRENT=$MODULE_DIR/modules.pcimap
@@ -57,31 +57,20 @@
 # extra filtering.
 #
 
-# inputs to the match algorithm, from kernel by way of /sbin/hotplug
-declare -i pci_class
-declare -i pci_id_vendor pci_id_device
-declare -i pci_subid_vendor pci_subid_device
-
 pci_convert_vars ()
 {
-    if [ "$AWK" = "" ]; then
-	mesg "can't find awk!"
-	exit 1
-    fi
+    pci_class=$((0x$PCI_CLASS))
 
-    pci_class=0x$PCI_CLASS
-
-    set `echo $PCI_ID | $AWK -F: '{print "0x" $1, "0x" $2 }'` ''
-    pci_id_vendor=$1
-    pci_id_device=$2
-
-    set `echo $PCI_SUBSYS_ID | $AWK -F: '{print "0x" $1, "0x" $2 }'` ''
-    pci_subid_vendor=$1
-    pci_subid_device=$2
+    set $(echo $PCI_ID | sed -e 's/\([^:]*\):\(.*\)/\1 \2/')
+    pci_id_vendor=$((0x$1))
+    pci_id_device=$((0x$2))
+
+    set $(echo $PCI_SUBSYS_ID | sed -e 's/\([^:]*\):\(.*\)/\1 \2/')
+    pci_subid_vendor=$((0x$1))
+    pci_subid_device=$((0x$2))
 }
 
-declare -i PCI_ANY
-PCI_ANY=0xffffffff
+PCI_ANY=$((0xffffffff))
 
 
 #
@@ -90,12 +79,7 @@
 #
 pci_map_modules ()
 {
-    # convert the usb_device_id fields to integers as we read them 
     local module ignored
-    declare -i vendor device
-    declare -i subvendor subdevice
-    declare -i class class_mask
-    declare -i class_temp
 
     # comment line lists (current) pci_device_id field names
     read ignored
@@ -110,6 +94,11 @@
 	\#*) continue ;;
 	esac
 
+	# convert the fields from hex to dec
+	vendor=$(($vendor)); device=$(($device))
+	subvendor=$(($subvendor)); subdevice=$(($subdevice))
+	class=$(($class)); class_mask=$(($class_mask))
+
 	: checkmatch $module
 
 	: vendor $vendor $pci_id_vendor
@@ -129,7 +118,7 @@
 	    continue
 	fi
 
-	class_temp="$pci_class & $class_mask"
+	class_temp=$(($pci_class & $class_mask))
 	if [ $class_temp -eq $class ]; then
 	    DRIVERS="$module $DRIVERS"
 	    : drivers $DRIVERS
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/pci.rc hotplug-2004_01_05/etc/hotplug/pci.rc
--- hotplug-2004_01_05.orig/etc/hotplug/pci.rc	2003-06-28 02:13:10.000000000 +0200
+++ hotplug-2004_01_05/etc/hotplug/pci.rc	2004-02-03 01:21:16.000000000 +0100
@@ -17,7 +17,7 @@
 	. /etc/rc.d/init.d/functions
 fi
 
-. hotplug.functions
+. ./hotplug.functions
 
 
 # # override any of the defaults?
@@ -32,7 +32,7 @@
     # information, and more can be gotten with 'lspci'.
     # don't expect pcimodules to exist!!
     #
-    LISTER=`type -p pcimodules`
+    LISTER=`which pcimodules`
     if [ "$LISTER" = "" -o ! -f /proc/bus/pci/devices -o ! -x pci.agent ]; then
 	    echo $"** can't synthesize pci hotplug events"
 	    return
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/scsi.agent hotplug-2004_01_05/etc/hotplug/scsi.agent
--- hotplug-2004_01_05.orig/etc/hotplug/scsi.agent	2002-12-11 23:05:06.000000000 +0100
+++ hotplug-2004_01_05/etc/hotplug/scsi.agent	2004-02-03 01:21:16.000000000 +0100
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 # SCSI hotplug agent for 2.5 kernels 
 #
@@ -7,7 +7,7 @@
 #
 
 cd /etc/hotplug
-. hotplug.functions
+. ./hotplug.functions
 
 case $ACTION in
 
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-03 01:21:26.000000000 +0100
+++ hotplug-2004_01_05/etc/hotplug/usb.agent	2004-02-03 01:21:16.000000000 +0100
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 # USB-specific hotplug policy agent.
 #
@@ -79,7 +79,7 @@
 fi
 
 cd /etc/hotplug
-. hotplug.functions
+. ./hotplug.functions
 # DEBUG=yes export DEBUG
 
 # generated by modutils, for current 2.4.x (and later) kernels
@@ -165,27 +165,19 @@
 # mechanism, but some driver probe() routines need to provide
 # extra filtering.
 #
-declare -i usb_idVendor usb_idProduct usb_bcdDevice
-declare -i usb_bDeviceClass usb_bDeviceSubClass usb_bDeviceProtocol
-declare -i usb_bInterfaceClass usb_bInterfaceSubClass usb_bInterfaceProtocol
 
 usb_convert_vars ()
 {
-    if [ "$AWK" = "" ]; then
-	mesg "can't find awk!"
-	exit 1
-    fi
-
     # work around 2.2.early brokenness
     # munges the usb_bcdDevice such that it is a integer rather
     # than a float: e.g. 1.0 become 0100
     PRODUCT=`echo $PRODUCT | sed -e "s+\.\([0-9]\)$+.\10+" -e "s/\.$/00/" \
                                   -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
+    set $(echo $PRODUCT | sed -e 's+\([^/]*\)/\([^/]*\)/\(.*\)+\1 \2 \3+')
+    usb_idVendor=$((0x$1))
+    usb_idProduct=$((0x$2))
+    usb_bcdDevice=$((0x$3))
 
     if [ "$TYPE" != "" ]; then
     	IFS=/
@@ -224,16 +216,16 @@
     fi
 }
 
-declare -i USB_MATCH_VENDOR=0x0001
-declare -i USB_MATCH_PRODUCT=0x0002
-declare -i USB_MATCH_DEV_LO=0x0004
-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
+USB_MATCH_VENDOR=$((0x0001))
+USB_MATCH_PRODUCT=$((0x0002))
+USB_MATCH_DEV_LO=$((0x0004))
+USB_MATCH_DEV_HI=$((0x0008))
+USB_MATCH_DEV_CLASS=$((0x0010))
+USB_MATCH_DEV_SUBCLASS=$((0x0020))
+USB_MATCH_DEV_PROTOCOL=$((0x0040))
+USB_MATCH_INT_CLASS=$((0x0080))
+USB_MATCH_INT_SUBCLASS=$((0x0100))
+USB_MATCH_INT_PROTOCOL=$((0x0200))
 
 #
 # stdin is "modules.usbmap" syntax
@@ -241,12 +233,7 @@
 #
 usb_map_modules ()
 {
-    # convert the usb_device_id fields to integers as we read them 
     local line module
-    declare -i match_flags
-    declare -i idVendor idProduct bcdDevice_lo bcdDevice_hi
-    declare -i bDeviceClass bDeviceSubClass bDeviceProtocol
-    declare -i bInterfaceClass bInterfaceSubClass bInterfaceProtocol
 
     # look at each usb_device_id entry
     # collect all matches in $DRIVERS
@@ -262,21 +249,21 @@
 	set $line
 
 	module=$1
-	match_flags=$2
+	match_flags=$(($2))
 
-	idVendor=$3
-	idProduct=$4
-	bcdDevice_lo=$5
-	bcdDevice_hi=$6
-
-	bDeviceClass=$7
-	bDeviceSubClass=$8
-	bDeviceProtocol=$9
+	idVendor=$(($3))
+	idProduct=$(($4))
+	bcdDevice_lo=$(($5))
+	bcdDevice_hi=$(($6))
+
+	bDeviceClass=$(($7))
+	bDeviceSubClass=$(($8))
+	bDeviceProtocol=$(($9))
 
 	shift 9
-	bInterfaceClass=$1
-	bInterfaceSubClass=$2
-	bInterfaceProtocol=$3
+	bInterfaceClass=$(($1))
+	bInterfaceSubClass=$(($2))
+	bInterfaceProtocol=$(($3))
 
 	: checkmatch $module
 
@@ -350,10 +337,11 @@
 # remover, or that the remove action can use to execute a remover.
 #
 if [ "$DEVICE" = "" ]; then
-  declare -rx REMOVER=/var/run/usb/`echo "$INTERFACE/$PRODUCT/$TYPE" | sed -e 's;/;%;g'`
+  REMOVER=/var/run/usb/`echo "$INTERFACE/$PRODUCT/$TYPE" | sed -e 's;/;%;g'`
 else
-  declare -rx REMOVER=/var/run/usb/`echo $DEVICE | sed -e 's;/;%;g'`
+  REMOVER=/var/run/usb/`echo $DEVICE | sed -e 's;/;%;g'`
 fi
+export REMOVER
 
 #
 # What to do with this USB hotplug event?
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-03 01:21:26.000000000 +0100
+++ hotplug-2004_01_05/etc/hotplug/usb.rc	2004-02-03 01:21:16.000000000 +0100
@@ -79,7 +79,7 @@
 
 	# synthesize hotplug events if we can 
 	# we need (non-bash) programs to parse descriptors.
-	LISTER=`type -p usbmodules`
+	LISTER=`which usbmodules`
 	if [ "$LISTER" = "" -o ! -f /proc/bus/usb/devices ]; then
 		echo $"** can't synthesize root hub events"
 		return

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

* hotplug patches: fixes and sysfs support 3/5
  2004-02-05  1:05 hotplug patches: fixes and sysfs support Marco d'Itri
                   ` (4 preceding siblings ...)
  2004-03-07 12:43 ` hotplug patches: fixes and sysfs support 2/5 Marco d'Itri
@ 2004-03-07 12:44 ` Marco d'Itri
  2004-03-07 12:48 ` hotplug patches: fixes and sysfs support 4/5 Marco d'Itri
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Marco d'Itri @ 2004-03-07 12:44 UTC (permalink / raw)
  To: linux-hotplug

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

003_no_useless_includes: removed some unused code.

-- 
ciao, |
Marco | [4958 diVR8I6hPFBsY]

[-- Attachment #2: 003_no_useless_includes --]
[-- Type: text/plain, Size: 1263 bytes --]

diff -ruN hotplug-2004_01_05.orig/etc/hotplug/pci.rc hotplug-2004_01_05/etc/hotplug/pci.rc
--- hotplug-2004_01_05.orig/etc/hotplug/pci.rc	2004-02-01 17:36:26.000000000 +0100
+++ hotplug-2004_01_05/etc/hotplug/pci.rc	2004-02-01 17:34:59.000000000 +0100
@@ -9,22 +9,8 @@
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 
 cd /etc/hotplug
-
-# source function library
-if [ -f /etc/init.d/functions ]; then
-	. /etc/init.d/functions
-elif [ -f /etc/rc.d/init.d/functions ]; then
-	. /etc/rc.d/init.d/functions
-fi
-
 . ./hotplug.functions
 
-
-# # override any of the defaults?
-# if [ -f /etc/sysconfig/pci ]; then
-#     . /etc/sysconfig/pci
-# fi
-
 pci_boot_events ()
 {
     #
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 17:36:26.000000000 +0100
+++ hotplug-2004_01_05/etc/hotplug/usb.rc	2004-02-01 17:36:19.000000000 +0100
@@ -27,14 +27,6 @@
 STATIC_MODULE_LIST=
 X11_USBMICE_HACK=false
 
-# source function library
-if [ -f /etc/init.d/functions ]; then
-	. /etc/init.d/functions
-elif [ -f /etc/rc.d/init.d/functions ]; then
-	. /etc/rc.d/init.d/functions
-fi
-
-
 # override any of the defaults above?
 if [ -f /etc/sysconfig/usb ]; then
     . /etc/sysconfig/usb

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

* hotplug patches: fixes and sysfs support 4/5
  2004-02-05  1:05 hotplug patches: fixes and sysfs support Marco d'Itri
                   ` (5 preceding siblings ...)
  2004-03-07 12:44 ` hotplug patches: fixes and sysfs support 3/5 Marco d'Itri
@ 2004-03-07 12:48 ` Marco d'Itri
  2004-03-07 12:49 ` hotplug patches: fixes and sysfs support 5/5 Marco d'Itri
  2004-03-11 23:24 ` hotplug patches: fixes and sysfs support 1/5 Greg KH
  8 siblings, 0 replies; 10+ messages in thread
From: Marco d'Itri @ 2004-03-07 12:48 UTC (permalink / raw)
  To: linux-hotplug

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

004_2.6_pci_synthesis: added sysfs support to pci.rc, enabling boot time
events synthesis on lacking the pcimodules program.

-- 
ciao, |
Marco | [4959 priBDK6jz7vDA]

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

diff -ruN hotplug-2004_01_05.orig/etc/hotplug/pci.rc hotplug-2004_01_05/etc/hotplug/pci.rc
--- hotplug-2004_01_05.orig/etc/hotplug/pci.rc	2004-02-01 18:00:45.000000000 +0100
+++ hotplug-2004_01_05/etc/hotplug/pci.rc	2004-02-01 17:49:59.000000000 +0100
@@ -13,33 +13,51 @@
 
 pci_boot_events ()
 {
-    #
-    # FIXME on 2.5, /sys/bus/pci/devices gives some of this
-    # information, and more can be gotten with 'lspci'.
-    # don't expect pcimodules to exist!!
-    #
-    LISTER=`which pcimodules`
-    if [ "$LISTER" = "" -o ! -f /proc/bus/pci/devices -o ! -x pci.agent ]; then
-	    echo $"** can't synthesize pci hotplug events"
-	    return
-    fi
-
     # make sure the pci agent will run
     ACTION=add
     PCI_CLASS=0
     PCI_ID=0:0
     PCI_SLOT=0:0.0
+    PCI_SLOT_NAME=0:0.0
     PCI_SUBSYS_ID=0:0
-    export ACTION PCI_CLASS PCI_ID PCI_SLOT PCI_SUBSYS_ID
+    export ACTION PCI_CLASS PCI_ID PCI_SLOT PCI_SLOT_NAME PCI_SUBSYS_ID
 
-    # 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
-	    PCI_SLOT=$BUS:$SLOT_FUNC
-	    : hotplug pci for $PCI_SLOT
+    if [ -d /sys/bus/pci/devices/ ]; then
+	# 2.6 kernels
+	cd /sys/bus/pci/devices/
+	for PCI_DEVICE in *; do
+	    set `echo $PCI_DEVICE \
+		| sed -e 's/\([^:]*\):\(.*\):\(.*\)\.\(.*\)/\1 \2 \3 \4/'`
+	    PCI_SLOT_NAME=$2:$3.$4
+	    PCI_CLASS="`cat $PCI_DEVICE/class`"
+	    PCI_CLASS=${PCI_CLASS#0x}
+	    vendor_id=`cat $PCI_DEVICE/vendor`
+	    device_id=`cat $PCI_DEVICE/device`
+	    PCI_ID="${vendor_id#0x}:${device_id#0x}"
+	    sub_vendor_id=`cat $PCI_DEVICE/subsystem_vendor`
+	    sub_device_id=`cat $PCI_DEVICE/subsystem_device`
+	    PCI_SUBSYS_ID="${sub_vendor_id#0x}:${sub_device_id#0x}"
 	    /sbin/hotplug pci
 	done
-    done
+    else
+	# 2.4 kernels
+	LISTER=`which pcimodules`
+	if [ "$LISTER" = "" -o ! -f /proc/bus/pci/devices
+		 -o ! -x pci.agent ]; then
+	    echo $"** can't synthesize pci hotplug events"
+	    return
+	fi
+
+	# 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
+		PCI_SLOT=$BUS:$SLOT_FUNC
+		/sbin/hotplug pci
+	    done
+	done
+    fi
+
+    return 0
 }
 
 # See how we were called.

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

* hotplug patches: fixes and sysfs support 5/5
  2004-02-05  1:05 hotplug patches: fixes and sysfs support Marco d'Itri
                   ` (6 preceding siblings ...)
  2004-03-07 12:48 ` hotplug patches: fixes and sysfs support 4/5 Marco d'Itri
@ 2004-03-07 12:49 ` Marco d'Itri
  2004-03-11 23:24 ` hotplug patches: fixes and sysfs support 1/5 Greg KH
  8 siblings, 0 replies; 10+ messages in thread
From: Marco d'Itri @ 2004-03-07 12:49 UTC (permalink / raw)
  To: linux-hotplug

[-- 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

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

* Re: hotplug patches: fixes and sysfs support 1/5
  2004-02-05  1:05 hotplug patches: fixes and sysfs support Marco d'Itri
                   ` (7 preceding siblings ...)
  2004-03-07 12:49 ` hotplug patches: fixes and sysfs support 5/5 Marco d'Itri
@ 2004-03-11 23:24 ` Greg KH
  8 siblings, 0 replies; 10+ messages in thread
From: Greg KH @ 2004-03-11 23:24 UTC (permalink / raw)
  To: linux-hotplug

On Sun, Mar 07, 2004 at 01:42:43PM +0100, Marco d'Itri wrote:
> 000_small_fixes: fixed some small bugs.

Ok, due to a total lack of discussion about these patches, I've applied
them all (all 5) and it seems to work for me :)

thanks,

greg k-h


-------------------------------------------------------
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\x1470&alloc_id638&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

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

end of thread, other threads:[~2004-03-11 23:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` hotplug patches: fixes and sysfs support 5/5 Marco d'Itri
2004-03-11 23:24 ` hotplug patches: fixes and sysfs support 1/5 Greg KH

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