[BACK]Return to fsck CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / etc / rc.d

File: [cvs.NetBSD.org] / src / etc / rc.d / fsck (download)

Revision 1.6, Sat Oct 7 04:11:23 2006 UTC (17 years, 6 months ago) by riz
Branch: MAIN
CVS Tags: wrstuden-fixsa-newbase, wrstuden-fixsa-base-1, wrstuden-fixsa-base, wrstuden-fixsa, netbsd-4-base, netbsd-4-0-RELEASE, netbsd-4-0-RC5, netbsd-4-0-RC4, netbsd-4-0-RC3, netbsd-4-0-RC2, netbsd-4-0-RC1, netbsd-4-0-1-RELEASE, netbsd-4-0, netbsd-4
Changes since 1.5: +3 -3 lines

Trap SIGINT so that if fsck is interrupted by ^C, we drop into single-user
mode.  Fixes misc/29822 from der Mouse, fix from Arnaud Lacombe with
comment rework by me.

#!/bin/sh
#
# $NetBSD: fsck,v 1.6 2006/10/07 04:11:23 riz Exp $
#

# PROVIDE: fsck
# REQUIRE: localswap

$_rc_subr_loaded . /etc/rc.subr

name="fsck"
start_cmd="fsck_start"
stop_cmd=":"

stop_boot()
{
	#	Terminate the process (which may include the parent /etc/rc)
	#	if booting directly to multiuser mode.
	#
	if [ "$autoboot" = yes ]; then
		kill -TERM $$
	fi
	exit 1
}

fsck_start()
{
	if [ -e /fastboot ]; then
		echo "Fast boot: skipping disk checks."
	else
		trap : 2		# Ignore SIGINT, SIGQUIT, so we
		trap : 3		# enter single-user mode on failure.

		echo "Starting file system checks:"
		fsck $fsck_flags
		case $? in
		0)
			;;
		2)
			stop_boot
			;;
		4)
			echo "Rebooting..."
			reboot
			echo "Reboot failed; help!"
			stop_boot
			;;
		8)
			echo "Automatic file system check failed; help!"
			stop_boot
			;;
		12)
			echo "Boot interrupted."
			stop_boot
			;;
		130)
			stop_boot
			;;
		*)
			echo "Unknown error; help!"
			stop_boot
			;;
		esac
	fi
}

load_rc_config $name
run_rc_command "$1"