PATCH pci.rc with lspci instead of deprecated /proc/pci
greetings
this patch is for using lspci to generate pci semi coldplug events (ie load the modules...) regards
etc/hotplug/pci.rc +6 -12
@@ -27,13 +27,9 @@ 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 + + LISTER=`type -p lspci` + if [ "$LISTER" = "" -o ! -x pci.agent ]; then echo $"** can't synthesize pci hotplug events" return fi
@@ -47,13 +43,11 @@ export ACTION PCI_CLASS PCI_ID PCI_SLOT 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 + lspci -n | gawk -F ' ' '{printf"%s\n",toupper($4)}' | + while read PCI_ID; do : hotplug pci for $PCI_SLOT /sbin/hotplug pci - done - done + done } # See how we were called.
Quoted 2 lines · mjl
this patch is for using lspci to generate pci semi coldplug events (ie load the modules...)
You cannot use awk because it's in /usr/bin/, which may not be mounted when hotplug is started.
(I'm going to post soon a patch which will enable PCI events synthesis for 2.6 kernels.)
Signature · 13 lines
ciao, | Marco | [4457 ro0sPURkp5vwA] ------------------------------------------------------- The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA. http://www.eclipsecon.org/osdn _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net [email protected] https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 11 lines · Marco d'Itri
Quoted 2 lines · mjl
this patch is for using lspci to generate pci semi coldplug events (ie load the modules...)
You cannot use awk because it's in
/usr/bin/, which may not be mounted when hotplug is started.(I'm going to post soon a patch which will enable PCI events synthesis for 2.6 kernels.)
ijlm@Sorcerer:~/devel$ which lspci /usr/sbin/lspci
so you can't use lspci too. if I remember correctly /proc pci is a deprecated option....
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 2 lines
You cannot use awk because it's in
/usr/bin/, which may not be mounted when hotplug is started.
"cut -d' ' -f4" should be fine.
Have a nice fortnight
Signature · 14 lines
Martin `MJ' Mares <[email protected]> http://atrey.karlin.mff.cuni.cz/~mj/ Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth Don't take life too seriously -- you'll never get out of it alive. ------------------------------------------------------- The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA. http://www.eclipsecon.org/osdn _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net [email protected] https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 7 lines · mjl
Quoted 2 lines · Marco d'Itri
You cannot use awk because it's in
/usr/bin/, which may not be mounted when hotplug is started.so you can't use lspci too. if I remember correctly /proc pci is a deprecated option....
How about "ls /sys/bus/pci/devices/ ; while read PCI_ID ; do ... ; done"?
Arnd <><
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 1 line · Arnd Bergmann
How about "ls
/sys/bus/pci/devices/; while readPCI_ID; do ... ; done"?
Yesterday I send a patch which does this and more. It will not support 2.4 kernels, but I don't care much.
Signature · 13 lines
ciao, | Marco | [4472 esn2GieqovK/6] ------------------------------------------------------- The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA. http://www.eclipsecon.org/osdn _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net [email protected] https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 4 lines · Martin Mares
Quoted 2 lines
You cannot use awk because it's in
/usr/bin/, which may not be mounted when hotplug is started."cut -d' ' -f4" should be fine.
This patch is working well for me with Linux 2.6.2. Please tell me if I've missed something.
Signature · 2 lines
Måns Rullgård [email protected]
Index: etc/hotplug/hotplug.functions
===================================================================
RCS file: /cvsroot/linux-hotplug/admin/etc/hotplug/hotplug.functions,v retrieving revision 1.22
hotplug/hotplug.functions +1 -1
@@ -139,7 +139,7 @@ do # maybe driver modules need loading LOADED=false - if ! lsmod | grep -q "^$MODULE " > /dev/null 2>&1; then + if ! lsmod | grep -q "^${MODULE//-/_} " > /dev/null 2>&1; then if grep -q "^$MODULE\$" $HOTPLUG_DIR/blacklist \ >/dev/null 2>&1; then debug_mesg "... blacklisted module: $MODULE"
Index: etc/hotplug/pci.agent
===================================================================
RCS file: /cvsroot/linux-hotplug/admin/etc/hotplug/pci.agent,v retrieving revision 1.13
hotplug/pci.agent +1 -1
@@ -147,7 +147,7 @@ add) pci_convert_vars - LABEL="PCI slot $PCI_SLOT_NAME" + LABEL="PCI slot $PCI_SLOT" # on 2.4 systems, modutils maintains MAP_CURRENT if [ -r $MAP_CURRENT ]; then
Index: etc/hotplug/pci.rc
===================================================================
RCS file: /cvsroot/linux-hotplug/admin/etc/hotplug/pci.rc,v retrieving revision 1.7
hotplug/pci.rc +25 -7
@@ -25,6 +25,11 @@ # . /etc/sysconfig/pci # fi +sys_file () +{ + cut -f2 -dx $DEVICE/$1 +} + pci_boot_events () { #
@@ -46,14 +51,27 @@ PCI_SUBSYS_ID=0:0 export ACTION PCI_CLASS PCI_ID PCI_SLOT 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 - /sbin/hotplug pci + case $KERNEL in + 2.5*|2.6*) + for DEVICE in /sys/bus/pci/devices/*; do + PCI_CLASS=`sys_file class` + PCI_ID=`sys_file vendor`:`sys_file device` + PCI_SLOT=`echo $DEVICE | cut -d: -f2-` + PCI_SUBSYS_ID=`sys_file subsystem_vendor`:`sys_file subsystem_device` + /sbin/hotplug pci + done + ;; + 2.4*) + # 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 + /sbin/hotplug pci + done done - done + ;; + esac } # See how we were called.