diff -urN hotplug.orig/hotplug.functions hotplug/hotplug.functions --- hotplug.orig/hotplug.functions 2003-10-07 23:15:38.000000000 +0200 +++ hotplug/hotplug.functions 2003-10-28 21:55:50.000000000 +0100 @@ -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 diff -urN hotplug.orig/ieee1394.agent hotplug/ieee1394.agent --- hotplug.orig/ieee1394.agent 2003-09-16 21:42:17.000000000 +0200 +++ hotplug/ieee1394.agent 2003-10-28 21:49:52.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 @@ -98,7 +99,7 @@ load_drivers ieee1394 $MAP_CURRENT "$LABEL" fi - if [ "$DRIVERS" == "" ]; then + if [ "$DRIVERS" = "" ]; then mesg "... no drivers for $LABEL" exit 2 fi diff -urN hotplug.orig/pci.agent hotplug/pci.agent --- hotplug.orig/pci.agent 2003-09-16 21:42:17.000000000 +0200 +++ hotplug/pci.agent 2003-10-28 21:49:56.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,22 @@ # 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 - +# convert from hex to dec the input values passed by the kernel to +# /sbin/hotplug 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 +81,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 +96,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 +120,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 @@ -154,7 +145,7 @@ load_drivers pci $MAP_CURRENT "$LABEL" fi - if [ "$DRIVERS" == "" ]; then + if [ "$DRIVERS" = "" ]; then mesg "... no modules for $LABEL" exit 2 fi diff -urN hotplug.orig/pci.rc hotplug/pci.rc --- hotplug.orig/pci.rc 2003-06-06 20:27:23.000000000 +0200 +++ hotplug/pci.rc 2003-10-28 21:57:33.000000000 +0100 @@ -9,51 +9,58 @@ 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 +. ./hotplug.functions 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=`type -p 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_SUBSYS_ID=0:0 - export ACTION PCI_CLASS PCI_ID PCI_SLOT PCI_SUBSYS_ID + PCI_SLOT_NAME=0:0.0 + export ACTION PCI_CLASS PCI_ID PCI_SLOT_NAME PCI_SUBSYS_ID + + 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}" - # 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 + debug_mesg "Detected $PCI_DEVICE $PCI_ID ($PCI_SUBSYS_ID, $PCI_CLASS)" /sbin/hotplug pci done - done + + else + + LISTER=`type -p 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_NAME=$BUS:$SLOT_FUNC + : hotplug pci for $PCI_SLOT_NAME + /sbin/hotplug pci + done + done + + fi + return 0 } # See how we were called.