2021-03-31 19:49:56 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
#
|
|
|
|
|
# fsck.zfs: A fsck helper to accommodate distributions that expect
|
|
|
|
|
# to be able to execute a fsck on all filesystem types.
|
|
|
|
|
#
|
|
|
|
|
# This script simply bubbles up some already-known-about errors,
|
|
|
|
|
# see fsck.zfs(8)
|
|
|
|
|
#
|
|
|
|
|
|
2022-04-09 04:09:55 +02:00
|
|
|
if [ $# -eq 0 ]; then
|
2021-03-31 19:49:56 +02:00
|
|
|
echo "Usage: $0 [options] dataset…" >&2
|
|
|
|
|
exit 16
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
ret=0
|
2022-04-09 04:09:55 +02:00
|
|
|
for dataset; do
|
2021-03-31 19:49:56 +02:00
|
|
|
case "$dataset" in
|
|
|
|
|
-*)
|
|
|
|
|
continue
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
pool="${dataset%%/*}"
|
|
|
|
|
|
|
|
|
|
case "$(@sbindir@/zpool list -Ho health "$pool")" in
|
|
|
|
|
DEGRADED)
|
2021-05-14 14:02:11 +02:00
|
|
|
ret=$(( ret | 4 ))
|
2021-03-31 19:49:56 +02:00
|
|
|
;;
|
|
|
|
|
FAULTED)
|
|
|
|
|
awk '!/^([[:space:]]*#.*)?$/ && $1 == "'"$dataset"'" && $3 == "zfs" {exit 1}' /etc/fstab || \
|
2021-05-14 14:02:11 +02:00
|
|
|
ret=$(( ret | 8 ))
|
2021-03-31 19:49:56 +02:00
|
|
|
;;
|
|
|
|
|
"")
|
|
|
|
|
# Pool not found, error printed by zpool(8)
|
2021-05-14 14:02:11 +02:00
|
|
|
ret=$(( ret | 8 ))
|
2021-03-31 19:49:56 +02:00
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
exit "$ret"
|