Skip to contentSkip to conversation

hotplug patches: fixes and sysfs support

PATCH Marco d'Itri 2 participants 10 messages Feb 5, 2004 – Mar 11, 2004

lore
Share & tools
lore
#0 lore raw

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.

Signature · 2 lines
ciao, |
Marco | [4466 diwYqAwSWjuYU]
etc/hotplug/ieee1394.agent +1 -1
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/ieee1394.agent hotplug-2004_01_05/etc/hotplug/ieee1394.agent
@@ -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
etc/hotplug/input.agent +2 -2
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/input.agent hotplug-2004_01_05/etc/hotplug/input.agent
@@ -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"
etc/hotplug/pci.agent +1 -1
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/pci.agent hotplug-2004_01_05/etc/hotplug/pci.agent
@@ -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
etc/hotplug/usb.agent +6 -6
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/usb.agent hotplug-2004_01_05/etc/hotplug/usb.agent
@@ -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
etc/hotplug/usb.rc +3 -0
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/usb.rc hotplug-2004_01_05/etc/hotplug/usb.rc
@@ -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
 
etc/hotplug/firmware.agent +1 -1
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/firmware.agent hotplug-2004_01_05/etc/hotplug/firmware.agent
@@ -16,7 +16,7 @@
 #
 
 cd /etc/hotplug
-. hotplug.functions
+. ./hotplug.functions
 # DEBUG=yes export DEBUG
 
 # directory of the firmware files
etc/hotplug/hotplug.functions +2 -13
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/hotplug.functions hotplug-2004_01_05/etc/hotplug/hotplug.functions
@@ -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
 
etc/hotplug/ieee1394.agent +10 -9
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/ieee1394.agent hotplug-2004_01_05/etc/hotplug/ieee1394.agent
@@ -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
etc/hotplug/input.agent +41 -48

148 lines not on this page · raw message

etc/hotplug/input.rc +2 -2
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/input.rc hotplug-2004_01_05/etc/hotplug/input.rc
@@ -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
etc/hotplug/net.agent +2 -2
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/net.agent hotplug-2004_01_05/etc/hotplug/net.agent
@@ -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
etc/hotplug/pci.agent +17 -28

84 lines not on this page · raw message

etc/hotplug/pci.rc +2 -2
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/pci.rc hotplug-2004_01_05/etc/hotplug/pci.rc
@@ -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
etc/hotplug/scsi.agent +2 -2
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/scsi.agent hotplug-2004_01_05/etc/hotplug/scsi.agent
@@ -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
 
etc/hotplug/usb.agent +31 -43

128 lines not on this page · raw message

etc/hotplug/usb.rc +1 -1
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/usb.rc hotplug-2004_01_05/etc/hotplug/usb.rc
@@ -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
etc/hotplug/pci.rc +0 -14
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/pci.rc hotplug-2004_01_05/etc/hotplug/pci.rc
@@ -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 ()
 {
     #
etc/hotplug/usb.rc +0 -8
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/usb.rc hotplug-2004_01_05/etc/hotplug/usb.rc
@@ -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
etc/hotplug/pci.rc +36 -18

69 lines not on this page · raw message

etc/hotplug/usb.agent +5 -1
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/usb.agent hotplug-2004_01_05/etc/hotplug/usb.agent
@@ -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"
etc/hotplug/usb.rc +29 -10
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/usb.rc hotplug-2004_01_05/etc/hotplug/usb.rc
@@ -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
#1 lore raw
Quoted 5 lines · Marco d'Itri

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?

Signature · 13 lines
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_id56&alloc_id438&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#2 lore raw
In reply to Marco d'Itri
Quoted 7 lines · Marco d'Itri
Quoted 5 lines · Marco d'Itri

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?

Signature · 13 lines
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_id56&alloc_id438&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#3 lore raw
In reply to Marco d'Itri
Quoted 9 lines · Marco d'Itri
Quoted 7 lines · Marco d'Itri
Quoted 5 lines · Marco d'Itri

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?

Signature · 13 lines
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_id56&alloc_id438&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#4 lore raw

hotplug patches: fixes and sysfs support 1/5

In reply to Marco d'Itri

000_small_fixes: fixed some small bugs.

Signature · 2 lines
ciao, |
Marco | [4956 adXbsurXEy5zg]
etc/hotplug/ieee1394.agent +1 -1
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/ieee1394.agent hotplug-2004_01_05/etc/hotplug/ieee1394.agent
@@ -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
etc/hotplug/input.agent +2 -2
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/input.agent hotplug-2004_01_05/etc/hotplug/input.agent
@@ -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"
etc/hotplug/pci.agent +1 -1
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/pci.agent hotplug-2004_01_05/etc/hotplug/pci.agent
@@ -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
etc/hotplug/usb.agent +6 -6
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/usb.agent hotplug-2004_01_05/etc/hotplug/usb.agent
@@ -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
etc/hotplug/usb.rc +3 -0
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/usb.rc hotplug-2004_01_05/etc/hotplug/usb.rc
@@ -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
 
#5 lore raw

hotplug patches: fixes and sysfs support 2/5

In reply to Marco d'Itri

001_no_bashisms: removed bashisms from all scripts.

Signature · 2 lines
ciao, |
Marco | [4957 raw4F0e.nH4kU]
etc/hotplug/firmware.agent +1 -1
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/firmware.agent hotplug-2004_01_05/etc/hotplug/firmware.agent
@@ -16,7 +16,7 @@
 #
 
 cd /etc/hotplug
-. hotplug.functions
+. ./hotplug.functions
 # DEBUG=yes export DEBUG
 
 # directory of the firmware files
etc/hotplug/hotplug.functions +2 -13
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/hotplug.functions hotplug-2004_01_05/etc/hotplug/hotplug.functions
@@ -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
 
etc/hotplug/ieee1394.agent +10 -9
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/ieee1394.agent hotplug-2004_01_05/etc/hotplug/ieee1394.agent
@@ -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
etc/hotplug/input.agent +41 -48

148 lines not on this page · raw message

etc/hotplug/input.rc +2 -2
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/input.rc hotplug-2004_01_05/etc/hotplug/input.rc
@@ -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
etc/hotplug/net.agent +2 -2
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/net.agent hotplug-2004_01_05/etc/hotplug/net.agent
@@ -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
etc/hotplug/pci.agent +17 -28

84 lines not on this page · raw message

etc/hotplug/pci.rc +2 -2
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/pci.rc hotplug-2004_01_05/etc/hotplug/pci.rc
@@ -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
etc/hotplug/scsi.agent +2 -2
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/scsi.agent hotplug-2004_01_05/etc/hotplug/scsi.agent
@@ -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
 
etc/hotplug/usb.agent +31 -43

128 lines not on this page · raw message

etc/hotplug/usb.rc +1 -1
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/usb.rc hotplug-2004_01_05/etc/hotplug/usb.rc
@@ -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
#6 lore raw

hotplug patches: fixes and sysfs support 3/5

In reply to Marco d'Itri

003_no_useless_includes: removed some unused code.

Signature · 2 lines
ciao, |
Marco | [4958 diVR8I6hPFBsY]
etc/hotplug/pci.rc +0 -14
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/pci.rc hotplug-2004_01_05/etc/hotplug/pci.rc
@@ -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 ()
 {
     #
etc/hotplug/usb.rc +0 -8
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/usb.rc hotplug-2004_01_05/etc/hotplug/usb.rc
@@ -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
#7 lore raw

hotplug patches: fixes and sysfs support 4/5

In reply to Marco d'Itri

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

Signature · 2 lines
ciao, |
Marco | [4959 priBDK6jz7vDA]
etc/hotplug/pci.rc +36 -18
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/pci.rc hotplug-2004_01_05/etc/hotplug/pci.rc
@@ -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.
#8 lore raw

hotplug patches: fixes and sysfs support 5/5

In reply to Marco d'Itri

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.

Signature · 2 lines
ciao, |
Marco | [4960 afL/bBUW.i/og]
etc/hotplug/usb.agent +5 -1
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/usb.agent hotplug-2004_01_05/etc/hotplug/usb.agent
@@ -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"
etc/hotplug/usb.rc +29 -10
diff -ruN hotplug-2004_01_05.orig/etc/hotplug/usb.rc hotplug-2004_01_05/etc/hotplug/usb.rc
@@ -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
#9 lore raw

Re: hotplug patches: fixes and sysfs support 1/5

In reply to Marco d'Itri
Quoted 1 line · Marco d'Itri

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_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel