home *** CD-ROM | disk | FTP | other *** search
- #!/bin/bash
- #
- # nplanel@mandrakesoft.com
- #
- # SCSI-specific hotplug policy agent.
- #
- # This should handle 2.4.* SCSI hotplugging. (usefull with usb-storage)
- #
- # Kernel SCSI params are:
- # ACTION=%s [add or remove]
- # SCSI_HOST=%u
- # SCSI_BUS=%u
- # SCSI_TARGET=%u
- # SCSI_LUN=%u
- # SCSI_VENDOR=%s
- # SCSI_MODEL=%s
- # SCSI_REV=%s
- # SCSI_TYPE=%d [0 for direct access device, 1 for ...]
- # SCSI_REMOVABLE=%d [1 for removable, 0 for not removable]
- # SCSI_EMULATED=%d [1 implies native to another stack (emulated)]
- # SCSI_ACCESS_COUNT [number of sd, sr and sg open() active on this device]
- # SCSI_WRITEABLE=%d
- # SCSI_LOCKABLE=%d
- # SCSI_EVENT_ATTACHED=%lu
- # [ SCSI_EVENT_DETACHED=%lu when ACTION=remove ]
-
- cd /etc/hotplug
- . hotplug.functions
-
- TYPE_DISK=0
- TYPE_TAPE=1
- TYPE_PRINTER=2
- TYPE_PROCESSOR=3 #/* HP scanners use this */
- TYPE_WORM=4 #/* Treated as ROM by our system */
- TYPE_ROM=5
- TYPE_SCANNER=6
- TYPE_MOD=7 #/* Magneto-optical disk - treated as TYPE_DISK */
-
- load_module () {
- MODULE=$1
- if ! $(grep -q "^$MODULE " /proc/modules); then
- debug_mesg "loading ... $MODULE"
- if $MODPROBE -n $MODULE >/dev/null 2>&1 &&
- ! $MODPROBE $MODULE >/dev/null 2>&1 ; then
- mesg "... can't load module $MODULE"
- fi
- else
- debug_mesg "$MODULE allready loaded"
- fi
- }
-
- load_disk_modules () {
- load_module sd_mod
- }
-
- load_cdrom_modules () {
- load_module sr_mod
- }
-
- load_tape_modules () {
- load_module st
- }
-
- load_generic_modules () {
- load_module sg
- }
-
- #
- # What to do with this SCSI hotplug event?
- #
-
- case $ACTION in
-
- add)
- case $SCSI_TYPE in
- # Disk
- $TYPE_MOD) #/* Magneto-optical disk - treated as TYPE_DISK */
- load_disk_modules
- ;;
- $TYPE_DISK)
- load_disk_modules
- ;;
- # Tape
- $TYPE_TAPE)
- load_tape_modules
- ;;
- # CDROM
- $TYPE_WORM) #/* Treated as ROM by our system */
- load_cdrom_modules
- ;;
- $TYPE_ROM)
- load_cdrom_modules
- ;;
- # Generic
- $TYPE_PRINTER)
- load_generic_modules
- ;;
- $TYPE_PROCESSOR) #/* HP scanners use this */
- load_generic_modules
- ;;
- $TYPE_SCANNER)
- load_generic_modules
- ;;
- *)
- debug_mesg "Unknown type: $SCSI_TYPE"
- ;;
- esac
- exit 0
- ;;
- *)
- debug_mesg SCSI $ACTION event not supported
- exit 1
- ;;
- esac
-
-