home *** CD-ROM | disk | FTP | other *** search
/ HAKERIS 11 / HAKERIS 11.ISO / linux / system / LinuxConsole 0.4 / linuxconsole0.4install-en.iso / linuxconsole0.4.lcm / etc / hotplug / pci.rc < prev    next >
Encoding:
Text File  |  2004-03-26  |  2.0 KB  |  96 lines

  1. #!/bin/sh
  2. #
  3. # pci.rc    mostly to recover lost boot-time pci hotplug events
  4. #
  5. # $Id: pci.rc,v 1.4 2001/03/22 04:54:01 dbrownell Exp $
  6. #
  7.  
  8. PATH=/sbin:/bin:/usr/sbin:/usr/bin
  9.  
  10. cd /etc/hotplug
  11.  
  12. # source function library
  13. if [ -f /etc/init.d/functions ]; then
  14.     . /etc/init.d/functions
  15. elif [ -f /etc/rc.d/init.d/functions ]; then
  16.     . /etc/rc.d/init.d/functions
  17. fi
  18.  
  19. . hotplug.functions
  20.  
  21.  
  22. # # override any of the defaults?
  23. # if [ -f /etc/sysconfig/pci ]; then
  24. #     . /etc/sysconfig/pci
  25. # fi
  26.  
  27. pci_boot_events ()
  28. {
  29.     LISTER=`type -p pcimodules`
  30.     if [ "$LISTER" = "" -o ! -f /proc/bus/pci/devices -o ! -x pci.agent ]; then
  31.         echo $"** can't synthesize pci hotplug events"
  32.         return
  33.     fi
  34.  
  35.     # make sure the pci agent will run
  36.     ACTION=add
  37.     PCI_CLASS=0
  38.     PCI_ID=0:0
  39.     PCI_SLOT=0:0.0
  40.     PCI_SUBSYS_ID=0:0
  41.     export ACTION PCI_CLASS PCI_ID PCI_SLOT PCI_SUBSYS_ID
  42.  
  43.     # Alternatively, parse /proc/bus/pci/devices to find
  44.     # which pci slots don't have drivers.  That's messy to
  45.     # parse, and hides PCI_CLASS and PCI_SUBSYS_ID.  At
  46.     # least PCI_CLASS is used by common drivers (USB hcds).
  47.  
  48.     # these notifications will be handled by pcimodules
  49.     for BUS in `cd /proc/bus/pci;find * -type d -print`; do
  50.     for SLOT_FUNC in `cd /proc/bus/pci/$BUS; echo *`; do
  51.         PCI_SLOT=$BUS:$SLOT_FUNC
  52.         : hotplug pci for $PCI_SLOT
  53.         /sbin/hotplug pci
  54.     done
  55.     done
  56. }
  57.  
  58. # See how we were called.
  59. case "$1" in
  60.   start)
  61.     pci_boot_events
  62.         ;;
  63.   stop)
  64.     echo $"pci stop -- ignored"
  65.         ;;
  66.   status)
  67.     echo $"PCI Status for kernel: "  `uname -srm`
  68.     echo ''
  69.  
  70.     if [ -f /proc/bus/pci/devices ]; then
  71.         COUNT=`ls /proc/bus/pci | wc -l`
  72.         if [ $COUNT -gt 1 ]; then
  73.         COUNT=`expr $COUNT - 1`
  74.         echo $"PCI up; bus count is $COUNT"
  75.         if [ -x /sbin/lspci ]; then
  76.             /sbin/lspci
  77.         fi
  78.         else
  79.         echo $"no PCI busses?"
  80.         fi
  81.         echo ''
  82.     else
  83.         echo $"no PCI /proc support?"
  84.     fi
  85.     echo ''
  86.  
  87.     ;;
  88.   restart)
  89.     # always invoke by absolute path, else PATH=$PATH:
  90.     $0 stop && $0 start
  91.     ;;
  92.   *)
  93.         echo $"Usage: $0 {start|stop|status|restart}"
  94.         exit 1
  95. esac
  96.