File: scsi-re-add

package info (click to toggle)
udev 0.105-4etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 672 kB
  • ctags: 54
  • sloc: sh: 1,636; makefile: 273
file content (25 lines) | stat: -rw-r--r-- 559 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/sh -e
# re-detect the capacity of USB devices after they have been powered off an on

[ "$DEVPATH" ] || exit 1

device=${DEVPATH##*/}
ctrl=${device%%:*}
bus=${device#*:}; bus=${bus%%:*}
target=${device#*:*:}; target=${target%%:*}
lun=${device#*:*:*:}
DEV_ID="$ctrl $bus $target $lun"

case "$ctrl$bus$target$lun" in
    *[A-Za-z_.:-]*)
    echo "Invalid \$DEVPATH!" >&2
    exit 1
    ;;
esac

# controller, bus, target, lun
echo "scsi remove-single-device $DEV_ID" > /proc/scsi/scsi
echo "scsi add-single-device $DEV_ID"    > /proc/scsi/scsi

exit 0