scsi 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/bin/sh
  2. #
  3. # scsi 1.30 1997/05/13 02:18:00 (David Hinds)
  4. #
  5. # Initialize or shutdown a PCMCIA SCSI adapter
  6. #
  7. # The first argument should be either 'start' or 'stop'. The second
  8. # argument is the base name for the device.
  9. #
  10. # The script passes an extended device address to 'scsi.opts' in the
  11. # ADDRESS variable, to retrieve device-specific configuration options.
  12. # The address format is "scheme,device,socket,channel,id,lun[,part]"
  13. # where "scheme" is the PCMCIA configuration scheme; "device" is the
  14. # SCSI device type (sd, sr, st, sg); "socket" is the socket number;
  15. # "channel", "id", and "lun" are the SCSI device ID's; and "part" is,
  16. # optionally, the partition number.
  17. #
  18. # The script first calls scsi.opts for the entire device. If
  19. # scsi.opts returns with the PARTS variable set, then this variable
  20. # contains a list of partitions for which options should be read.
  21. #
  22. if [ -r ./shared ] ; then . ./shared ; else . /etc/pcmcia/shared ; fi
  23. # Get device attributes
  24. get_info $DEVICE
  25. case "$DEVICE" in
  26. scsi*) exit 0 ;;
  27. sd*) TYPE="sd" ;;
  28. st*) TYPE="st" ;;
  29. scd*) TYPE="sr" ;;
  30. sg*) TYPE="sg" ;;
  31. esac
  32. eval `/sbin/scsi_info /dev/$DEVICE` || usage
  33. # Load site-specific settings
  34. ADDRESS="$SCHEME,$TYPE,$SOCKET,$SCSI_ID"
  35. . $0.opts
  36. case "$ACTION" in
  37. 'start')
  38. [ -n "$VERBOSE" -a -n "$INFO" ] && echo "$INFO"
  39. add_parts $ADDRESS "$PARTS" || exit 1
  40. ;;
  41. 'stop')
  42. if [ -b /dev/$DEVICE ] ; then
  43. rm_parts $ADDRESS "$PARTS"
  44. else
  45. do_fuser -k /dev/$DEVICE > /dev/null
  46. fi
  47. exit $?
  48. ;;
  49. 'check')
  50. is_true $NO_CHECK && exit 0
  51. if [ -b /dev/$DEVICE ] ; then
  52. do_fuser -s -m /dev/${DEVICE}* && exit 1
  53. elif [ -c /dev/$DEVICE ] ; then
  54. do_fuser -s /dev/${DEVICE}* && exit 1
  55. fi
  56. ;;
  57. 'cksum')
  58. chk_parts "$NEW_SCHEME,$TYPE,$SOCKET,$SCSI_ID" || exit 1
  59. ;;
  60. 'suspend'|'resume')
  61. ;;
  62. *)
  63. usage
  64. ;;
  65. esac
  66. exit 0