diff -urN hotplug.orig1/firmware.agent hotplug/firmware.agent --- hotplug.orig1/firmware.agent 2003-10-07 21:34:19.000000000 +0200 +++ hotplug/firmware.agent 2003-10-29 02:24:31.000000000 +0100 @@ -16,7 +16,7 @@ # cd /etc/hotplug -. hotplug.functions +. ./hotplug.functions # DEBUG=yes export DEBUG # directory of the firmware files diff -urN hotplug.orig1/input.agent hotplug/input.agent --- hotplug.orig1/input.agent 2003-10-14 01:52:54.000000000 +0200 +++ hotplug/input.agent 2003-10-29 22:23:16.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,14 +51,16 @@ # 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 @@ -81,14 +83,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 +102,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 +152,7 @@ input_map_modules () { local line module - declare -i matchBits - declare -i bustype vendor product version - declare -i evBits driverInfo - declare relBits mscBits ledBits sndBitskeyBits absBits ffBits + local relBits mscBits ledBits sndBitskeyBits absBits ffBits while read line do @@ -166,25 +164,26 @@ set $line - module="$1" - matchBits="$2" + module=$(($1)) + matchBits=$(($2)) - bustype="$3" - vendor="$4" - product="$5" - product="$6" - - evBits="$7" - keyBits="$8" - relBits="$9" + bustype=$(($3)) + vendor=$(($4)) + product=$(($5)) + product=$(($6)) + + evBits=$(($7)) +echo "|||$8|||" + 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 -urN hotplug.orig1/input.rc hotplug/input.rc --- hotplug.orig1/input.rc 2003-10-14 01:52:54.000000000 +0200 +++ hotplug/input.rc 2003-10-29 22:19:12.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 -urN hotplug.orig1/net.agent hotplug/net.agent --- hotplug.orig1/net.agent 2003-10-07 21:56:24.000000000 +0200 +++ hotplug/net.agent 2003-10-29 19:16:49.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 -urN hotplug.orig1/NOTES hotplug/NOTES --- hotplug.orig1/NOTES 1970-01-01 01:00:00.000000000 +0100 +++ hotplug/NOTES 2003-10-29 02:22:51.000000000 +0100 @@ -0,0 +1,9 @@ +usb.rc: +- PCI hotplugging is supported when sysfs is present, the HC code should + be removed or made conditional to 2.4 kernels +- rmmod will always fail with some 2.6 kernel configurations, so it cannot + be used to check if everything has been loaded +- could maybe_stop_usb() be improved now? + +firmware.agent: +- /usr/lib/hotplug/firmware should become /usr/share/hotplug/firmware. diff -urN hotplug.orig1/scsi.agent hotplug/scsi.agent --- hotplug.orig1/scsi.agent 2002-12-11 23:05:06.000000000 +0100 +++ hotplug/scsi.agent 2003-10-29 19:17:07.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 -urN hotplug.orig1/usb.agent hotplug/usb.agent --- hotplug.orig1/usb.agent 2003-10-14 01:52:54.000000000 +0200 +++ hotplug/usb.agent 2003-10-29 19:08:54.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,39 +165,31 @@ # 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=/ set $TYPE '' - usb_bDeviceClass=$1 - usb_bDeviceSubClass=$2 - usb_bDeviceProtocol=$3 + usb_bDeviceClass=$((0x$1)) + usb_bDeviceSubClass=$((0x$2)) + usb_bDeviceProtocol=$((0x$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=$((0x$(cat $SYSFS/$DEVPATH/bDeviceClass))) + usb_bDeviceSubClass=$((0x$(cat $SYSFS/$DEVPATH/bDeviceSubClass))) + usb_bDeviceProtocol=$((0x$(cat $SYSFS/$DEVPATH/bDeviceProtocol))) else # out-of-range values usb_bDeviceClass=1000 @@ -208,14 +200,14 @@ if [ "$INTERFACE" != "" ]; then IFS=/ set $INTERFACE '' - usb_bInterfaceClass=$1 - usb_bInterfaceSubClass=$2 - usb_bInterfaceProtocol=$3 + usb_bInterfaceClass=$((0x$1)) + usb_bInterfaceSubClass=$((0x$2)) + usb_bInterfaceProtocol=$((0x$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=$((0x$(cat $SYSFS/$DEVPATH/bInterfaceClass))) + usb_bInterfaceSubClass=$((0x$(cat $SYSFS/$DEVPATH/bInterfaceSubClass))) + usb_bInterfaceProtocol=$((0x$(cat $SYSFS/$DEVPATH/bInterfaceProtocol))) else # out-of-range values usb_bInterfaceClass=1000 @@ -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 @@ -243,10 +235,6 @@ { # 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 +250,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 +338,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? @@ -373,7 +362,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 -urN hotplug.orig1/usb.rc hotplug/usb.rc --- hotplug.orig1/usb.rc 2003-09-25 02:09:08.000000000 +0200 +++ hotplug/usb.rc 2003-10-29 22:27:18.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 @@ -76,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 @@ -85,11 +88,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 @@ -100,10 +104,27 @@ # 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 + 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/} + # XXX is this correct? +# class=0 + 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 } @@ -135,12 +156,16 @@ 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