aboutsummaryrefslogtreecommitdiff
path: root/init.d/fsck
blob: d07cec850a6d97d23ca7dea3dcaa0c4004ac09e3 (plain)
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
#!/sbin/runscript
# Copyright 2007-2008 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.

description="Check and repair filesystems according to /etc/fstab"

depend()
{
	need swap
	after clock modules
	keywords notimeout
}

start()
{
	if [ "${RC_UNAME}" = "Linux" ]; then
		opts="${opts} -A -C0 -T"
		if echo 2>/dev/null >/.test.$$; then
			rm -f /.test.$$
			opts="${opts} -R"
		fi
	fi

	ebegin "Checking local filesystems"
	fsck ${fsck_args-p} ${opts}
	case $? in
		0)     eend 0; return 0;;
		1)     ewend 1 "Filesystems repaired"; return 0;;
		2|4)   ewend 1 "Filesystems repaired, but reboot needed"
		       reboot; exec rc-abort; return 1;;
		8)     ewend 1 "Operational error"; return 0;;
		12)    ewend 1 "fsck interupted"; return 1;;
		*)     eend 2 "Filesystems couldn't be fixed"
		       exec rc-abort; return 1;;
	esac
}

stop()
{
	yesno "${fsck_shutdown}" && start
	return 0
}