Fix inconsistent mount options for ZFS root
[zfs.git] / cmd / zpool / zpool.d / ses
blob19ef92ad67b2e4a682eb12f93e9848976a9f1071
1 #!/bin/sh
3 # Print SCSI Enclosure Services (SES) info. The output is dependent on the name
4 # of the script/symlink used to call it.
6 helpstr="
7 enc: Show disk enclosure w:x:y:z value.
8 slot: Show disk slot number as reported by the enclosure.
9 encdev: Show /dev/sg* device associated with the enclosure disk slot.
10 fault_led: Show value of the disk enclosure slot fault LED.
11 locate_led: Show value of the disk enclosure slot locate LED.
12 ses: Show disk's enc, enc device, slot, and fault/locate LED values."
14 script="${0##*/}"
15 if [ "$1" = "-h" ] ; then
16 echo "$helpstr" | grep "$script:" | tr -s '\t' | cut -f 2-
17 exit
20 if [ "$script" = "ses" ] ; then
21 scripts='enc encdev slot fault_led locate_led'
22 else
23 scripts="$script"
26 for i in $scripts ; do
27 # shellcheck disable=SC2154
28 if [ -z "$VDEV_ENC_SYSFS_PATH" ] ; then
29 echo "$i="
30 continue
33 val=""
34 case $i in
35 enc)
36 if echo "$VDEV_ENC_SYSFS_PATH" | grep -q '/sys/bus/pci/slots' ; then
37 val="$VDEV_ENC_SYSFS_PATH"
38 else
39 val="$(ls """$VDEV_ENC_SYSFS_PATH/../../""" 2>/dev/null)"
42 slot)
43 if echo "$VDEV_ENC_SYSFS_PATH" | grep -q '/sys/bus/pci/slots' ; then
44 val="$(basename """$VDEV_ENC_SYSFS_PATH""")"
45 else
46 val="$(cat """$VDEV_ENC_SYSFS_PATH/slot""" 2>/dev/null)"
49 encdev)
50 val=$(ls "$VDEV_ENC_SYSFS_PATH/../device/scsi_generic" 2>/dev/null)
52 fault_led)
53 # JBODs fault LED is called 'fault', NVMe fault LED is called
54 # 'attention'.
55 if [ -f "$VDEV_ENC_SYSFS_PATH/fault" ] ; then
56 val=$(cat "$VDEV_ENC_SYSFS_PATH/fault" 2>/dev/null)
57 elif [ -f "$VDEV_ENC_SYSFS_PATH/attention" ] ; then
58 val=$(cat "$VDEV_ENC_SYSFS_PATH/attention" 2>/dev/null)
61 locate_led)
62 val=$(cat "$VDEV_ENC_SYSFS_PATH/locate" 2>/dev/null)
65 val=invalid
67 esac
68 echo "$i=$val"
69 done