[arch-projects] [PATCH 1/4] fsck: move FORCEFSCK/FASTBOOT logic to fsck_all

Tom Gundersen teg at jklm.no
Sat Mar 17 06:44:27 EDT 2012


Avoid global variables, and make things clearer.

Signed-off-by: Tom Gundersen <teg at jklm.no>
---
 functions  |    6 ++++++
 rc.sysinit |   29 ++++++++++++-----------------
 2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/functions b/functions
index 0b7fd8d..747e42d 100644
--- a/functions
+++ b/functions
@@ -428,6 +428,12 @@ NETFS="nfs,nfs4,smbfs,cifs,codafs,ncpfs,shfs,fuse,fuseblk,glusterfs,davfs,fuse.g
 
 # Check local filesystems
 fsck_all() {
+	[[ -f /forcefsck ]] || in_array forcefsck $(< /proc/cmdline) && FORCEFSCK="-f"
+
+	if [[ ! -n $FORCEFSCK ]] && { [[ -f /fastboot ]] || in_array fastboot $(< /proc/cmdline); }; then
+		return
+	fi
+
 	if [[ -e /run/initramfs/root-fsck ]]; then
 		IGNORE_MOUNTED="-M"
 	fi
diff --git a/rc.sysinit b/rc.sysinit
index 8fa4270..0876d05 100755
--- a/rc.sysinit
+++ b/rc.sysinit
@@ -176,24 +176,19 @@ if [[ -f /etc/crypttab && $CS ]] && grep -q ^[^#] /etc/crypttab; then
 fi
 
 # Check filesystems
-[[ -f /forcefsck ]] || in_array forcefsck $(< /proc/cmdline) && FORCEFSCK="-f"
-declare -r FORCEFSCK
-
-if [[ -n $FORCEFSCK ]] || { [[ ! -f /fastboot ]] && ! in_array fastboot $(< /proc/cmdline); }; then
-	run_hook sysinit_prefsck
-	if [[ -x $(type -P fsck) ]]; then
-		stat_busy "Checking Filesystems"
-			fsck_all >|"${FSCK_OUT:-/dev/stdout}" 2>|"${FSCK_ERR:-/dev/stdout}"
-		declare -r fsckret=$?
-		(( fsckret <= 1 )) && stat_done || stat_fail
-	else
-		declare -r fsckret=0
-	fi
-	run_hook sysinit_postfsck
-
-	# Single-user login and/or automatic reboot if needed
-	fsck_reboot $fsckret
+run_hook sysinit_prefsck
+if [[ -x $(type -P fsck) ]]; then
+	stat_busy "Checking Filesystems"
+		fsck_all >|"${FSCK_OUT:-/dev/stdout}" 2>|"${FSCK_ERR:-/dev/stdout}"
+	declare -r fsckret=$?
+	(( fsckret <= 1 )) && stat_done || stat_fail
+else
+	declare -r fsckret=0
 fi
+run_hook sysinit_postfsck
+
+# Single-user login and/or automatic reboot if needed
+fsck_reboot $fsckret
 
 status "Remounting Root" \
 	mount -o remount /
-- 
1.7.9.4



More information about the arch-projects mailing list