mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-25 11:47:43 +03:00
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:
+10
-2
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user