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 / ieee1394.agent < prev    next >
Encoding:
Text File  |  2004-03-26  |  2.8 KB  |  124 lines

  1. #!/bin/bash
  2. #
  3. # IEEE1394-specific hotplug policy agent.
  4. #
  5. # This should handle 2.4.10 (or later) IEEE1394 hotplugging, with a
  6. # consistent framework for adding device and driver specific treatments.
  7. #
  8. # Kernel IEEE1394 params are:
  9. #    
  10. #    ACTION=add or remove
  11. #    VENDOR_ID=24 bit vendor id
  12. #    GUID=64 bit globally unique id
  13. #    SPEFICIER_ID=24 bit id of owner of specification
  14. #    VERSION=version of specification
  15. #
  16. # See IEEE1212 for details on these parameters.
  17. #
  18. # HISTORY:
  19. #    26-Mar-2002    Small cleanups to match other .agent files. (gkh)
  20. #    16-Sept-2001    Initial version from Kristian Hogsberg
  21. #            <hogsberg@users.sourceforge.net> (plus tweaks)
  22. #
  23. # $Id: ieee1394.agent,v 1.6 2002/03/30 21:06:08 dbrownell Exp $
  24. #
  25.  
  26. cd /etc/hotplug
  27. . hotplug.functions
  28. # DEBUG=yes export DEBUG
  29.  
  30. # generated by modutils 2.4.9 or later, for 2.4.10 and later kernels
  31. MAP_CURRENT=$MODULE_DIR/modules.ieee1394map
  32.  
  33. # accumulates list of modules we may care about
  34. DRIVERS=
  35.  
  36. if [ "$ACTION" = "" ]; then
  37.     mesg Bad IEEE1394 agent invocation
  38.     exit 1
  39. fi
  40.  
  41.  
  42. declare -i device_vendor_id device_specifier_id device_version
  43. device_vendor_id="0x$VENDOR_ID"
  44. device_specifier_id="0x$SPECIFIER_ID"
  45. device_version="0x$VERSION"
  46.  
  47. declare -i MATCH_VENDOR_ID MATCH_SPECIFIER_ID MATCH_VERSION
  48. MATCH_VENDOR_ID=0x0001
  49. MATCH_SPECIFIER_ID=0x0004
  50. MATCH_VERSION=0x0008
  51.  
  52. #
  53. # stdin is "modules.ieee1394map" syntax
  54. # on return, ONE matching module was added to $DRIVERS
  55. #
  56. ieee1394_map_modules ()
  57. {
  58.     local module ignored
  59.     declare -i match_flags vendor_id model_id
  60.     declare -i specifier_id version
  61.  
  62.     # comment line lists (current) pci_device_id field names
  63.     read ignored
  64.  
  65.     while read module match_flags vendor_id model_id specifier_id version
  66.     do
  67.     : check match for $module
  68.  
  69.     : vendor_id $vendor_id $device_vendor_id
  70.     if [ $(($match_flags & $MATCH_VENDOR_ID)) -ne 0 -a $vendor_id -ne $device_vendor_id ]; then
  71.         continue
  72.     fi
  73.  
  74.     : specifier_id $specifier_id $device_specifier_id
  75.     if [ $(($match_flags & $MATCH_SPECIFIER_ID)) -ne 0 -a $specifier_id -ne $device_specifier_id ]; then
  76.         continue
  77.     fi
  78.  
  79.     : version $version $device_version
  80.     if [ $(($match_flags & $MATCH_VERSION)) -ne 0 -a $version != $device_version ]; then
  81.         continue
  82.     fi
  83.  
  84.         DRIVERS="$module $DRIVERS"
  85.     break
  86.     done
  87. }
  88.  
  89. #
  90. # What to do with this IEEE1394 hotplug event?
  91. #
  92. case "$ACTION" in
  93.  
  94. add)
  95.     LABEL="IEEE1394 product 0x$VENDOR_ID/0x$SPECIFIER_ID/0x$VERSION"
  96.  
  97.     # on 2.4 systems, modutils maintains MAP_CURRENT
  98.     if [ -r $MAP_CURRENT ]; then
  99.         load_drivers ieee1394 $MAP_CURRENT "$LABEL"
  100.     fi
  101.  
  102.     if [ "$DRIVERS" == "" ]; then
  103.     mesg "... no drivers for $LABEL"
  104.     exit 2
  105.     fi
  106.     ;;
  107.  
  108. remove)
  109.     ieee1394_map_modules < $MAP_CURRENT
  110.     for MODULE in $DRIVERS
  111.     do
  112.     if [ -x $HOTPLUG_DIR/ieee1394/$MODULE ]; then
  113.             $HOTPLUG_DIR/ieee1394/$MODULE
  114.     fi
  115.     done
  116.     ;;
  117.  
  118. *)
  119.     mesg "IEEE1394 '$ACTION' event not supported"
  120.     exit 1
  121.     ;;
  122.  
  123. esac
  124.