Home | History | Annotate | Line # | Download | only in rc.d
fsck_root revision 1.4
      1 #!/bin/sh
      2 #
      3 # $NetBSD: fsck_root,v 1.4 2010/02/16 02:46:02 mrg Exp $
      4 #
      5 
      6 # PROVIDE: fsck_root
      7 
      8 $_rc_subr_loaded . /etc/rc.subr
      9 
     10 name="fsck_root"
     11 start_cmd="fsck_root_start"
     12 stop_cmd=":"
     13 fstab_file=/etc/fstab
     14 
     15 fsck_root_start()
     16 {
     17 	if [ -e /fastboot ]; then
     18 		echo "Fast boot: skipping disk checks."
     19 		return
     20 	fi
     21 	trap : 2 		# Ignore SIGINT, SIGQUIT, so we
     22 	trap : 3		# enter single-user mode on failure.
     23 
     24 	# Do nothing if root file system has fs_passno=0 in /etc/fstab.
     25 	while read fs_spec fs_file fs_vfstype fs_mntops fs_freq fs_passno
     26 	do
     27 		case "${fs_spec}:${fs_file}:${fs_passno}" in
     28 		\#*|'':*)
     29 			continue # skip comment or blank line
     30 			;;
     31 		*:/:0)
     32 			echo "Not checking /: fs_passno = 0 in ${fstab_file}"
     33 			return
     34 			;;
     35 		*:/:*)	case "${fs_spec}" in
     36 			*:*)
     37 				echo "Not checking /: nfs mounted"
     38 				return
     39 				;;
     40 			esac
     41 
     42 			echo "Starting root file system check:"
     43 			fsck $fsck_flags /
     44 			handle_fsck_error "$?"
     45 			return
     46 			;;
     47 		esac
     48 	done < "${fstab_file}"
     49 }
     50 
     51 load_rc_config $name
     52 run_rc_command "$1"
     53