Workaround broken VDEV_UPATH

Sometimes, for reasons I haven't looked into yet, VDEV_UPATH
gets set to /dev/(null), breaking all these scripts.

It'd be nice to have a fallback case to avoid total failure.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
Closes #13436
This commit is contained in:
Rich Ercolani
2022-05-10 13:14:07 -04:00
committed by GitHub
parent a30927f763
commit ecaccf764a
3 changed files with 34 additions and 10 deletions
+10 -2
View File
@@ -69,8 +69,16 @@ if [ "$1" = "-h" ] ; then
exit
fi
# Sometimes, UPATH ends up /dev/(null).
# That should be corrected, but for now...
# shellcheck disable=SC2154
if [ -b "$VDEV_UPATH" ] && PATH="/usr/sbin:$PATH" command -v smartctl > /dev/null || [ -n "$samples" ] ; then
if [ ! -b "$VDEV_UPATH" ]; then
somepath="${VDEV_PATH}"
else
somepath="${VDEV_UPATH}"
fi
if [ -b "$somepath" ] && PATH="/usr/sbin:$PATH" command -v smartctl > /dev/null || [ -n "$samples" ] ; then
if [ -n "$samples" ] ; then
# cat a smartctl output text file instead of running smartctl
# on a vdev (only used for developer testing).
@@ -78,7 +86,7 @@ if [ -b "$VDEV_UPATH" ] && PATH="/usr/sbin:$PATH" command -v smartctl > /dev/nul
echo "file=$file"
raw_out=$(cat "$samples/$file")
else
raw_out=$(sudo smartctl -a "$VDEV_UPATH")
raw_out=$(sudo smartctl -a "$somepath")
fi
# What kind of drive are we? Look for the right line in smartctl: