Module Name:    src
Committed By:   apb
Date:           Tue Sep 20 12:13:21 UTC 2011

Modified Files:
        src/etc/rc.d: fsck_root

Log Message:
Don't try to fsck root device if "/" is not mentioned in fstab.
Also don't assume that all network mounts are "nfs".


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/etc/rc.d/fsck_root

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/etc/rc.d/fsck_root
diff -u src/etc/rc.d/fsck_root:1.5 src/etc/rc.d/fsck_root:1.6
--- src/etc/rc.d/fsck_root:1.5	Sat Sep 25 15:10:14 2010
+++ src/etc/rc.d/fsck_root	Tue Sep 20 12:13:21 2011
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: fsck_root,v 1.5 2010/09/25 15:10:14 bad Exp $
+# $NetBSD: fsck_root,v 1.6 2011/09/20 12:13:21 apb Exp $
 #
 
 # PROVIDE: fsck_root
@@ -21,31 +21,45 @@
 	trap : 2 		# Ignore SIGINT, SIGQUIT, so we
 	trap : 3		# enter single-user mode on failure.
 
-	# Do nothing if root file system has fs_passno=0 in /etc/fstab.
+	# Do nothing if root file system has fs_passno=0 in /etc/fstab,
+	# or if root file system is not mentioned in /etc/fstab, or if
+	# root file system seems to be a network mount.
+	root_in_fstab=false
 	while read fs_spec fs_file fs_vfstype fs_mntops fs_freq fs_passno
 	do
-		case "${fs_spec}:${fs_file}:${fs_passno:=0}" in
-		\#*|'':*)
-			continue # skip comment or blank line
-			;;
-		*:/:0)
+		# skip comment or blank line
+		case "${fs_spec}" in
+		\#*|'') continue ;;
+		esac
+
+		# fs_freq and fs_passno default to 0 if not specified
+		: ${fs_freq:=0} ${fs_passno:=0}
+
+		case "${fs_file},${fs_passno}" in
+		/,0)
 			echo "Not checking /: fs_passno = 0 in ${fstab_file}"
 			return
 			;;
-		*:/:*)	case "${fs_spec}" in
+		/,*)
+			root_in_fstab=true
+			case "${fs_spec}" in
 			*:*)
-				echo "Not checking /: nfs mounted"
+				echo "Not checking /: network mount"
 				return
 				;;
 			esac
-
-			echo "Starting root file system check:"
-			fsck $fsck_flags /
-			handle_fsck_error "$?"
-			return
 			;;
 		esac
 	done < "${fstab_file}"
+
+	if $root_in_fstab; then
+		echo "Starting root file system check:"
+		fsck $fsck_flags /
+		handle_fsck_error "$?"
+		return
+	else
+		echo "Not checking /: not listed in ${fstab_file}"
+	fi
 }
 
 load_rc_config $name

Reply via email to