File: fsck.zfs.in

package info (click to toggle)
zfs-linux 2.3.3-1
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid
  • size: 70,488 kB
  • sloc: ansic: 393,047; sh: 67,422; asm: 47,734; python: 8,160; makefile: 5,105; perl: 859; sed: 41
file content (44 lines) | stat: -rwxr-xr-x 756 bytes parent folder | download | duplicates (6)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/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)
#

if [ $# -eq 0 ]; then
	echo "Usage: $0 [options] dataset…" >&2
	exit 16
fi

ret=0
for dataset; do
	case "$dataset" in
		-*)
			continue
			;;
		*)
			;;
	esac

	pool="${dataset%%/*}"

	case "$(@sbindir@/zpool list -Ho health "$pool")" in
		DEGRADED)
			ret=$(( ret | 4 ))
			;;
		FAULTED)
			awk '!/^([[:space:]]*#.*)?$/ && $1 == "'"$dataset"'" && $3 == "zfs" {exit 1}' /etc/fstab || \
				ret=$(( ret | 8 ))
			;;
		"")
			# Pool not found, error printed by zpool(8)
			ret=$(( ret | 8 ))
			;;
		*)
			;;
	esac
done

exit "$ret"