From: "Marco d'Itri" Date: Sun, 07 Mar 2004 12:48:23 +0000 Subject: hotplug patches: fixes and sysfs support 4/5 Message-Id: <20040307124823.GB4345@wonderland.linux.it> MIME-Version: 1 Content-Type: multipart/mixed; boundary="f2QGlHpHGjS2mn6Y" List-Id: References: <20040205010507.GA12825@wonderland.linux.it> In-Reply-To: <20040205010507.GA12825@wonderland.linux.it> To: linux-hotplug@vger.kernel.org --f2QGlHpHGjS2mn6Y Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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] --f2QGlHpHGjS2mn6Y Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="004_2.6_pci_synthesis" 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. --f2QGlHpHGjS2mn6Y-- ------------------------------------------------------- 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=1470&alloc_id=3638&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