[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH initramfs-tools 1/3] checkfs: Continue unless fsck reports uncorrectable errors



The current checking of the fsck exit code is extremely fragile.  We
should never see the reboot flag (2) set as that is only used when
checking a mounted root filesystem, so don't bother checking for it.
So we should only need to check whether the uncorrectable error flag
(4) is set, and should continue otherwise.

This mitigates bug #766448.

Closes: #765614
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 scripts/functions | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/scripts/functions b/scripts/functions
index c0dd684..398c822 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -383,14 +383,14 @@ checkfs()
 	# If there was a failure, drop into a shell.
 	#
 	# NOTE: "failure" is defined as exiting with a return code of
-	# 4 or larger. A return code of 1 indicates that file system
-	# errors were corrected but that the boot may proceed. A return
-	# code of 2 or 3 indicates that the system should immediately reboot.
+	# 4, possibly or-ed with other flags. A return code of 1
+	# indicates that file system errors were corrected but that
+	# the boot may proceed.
 	#
 	if [ "$FSCKCODE" -eq 32 ]
 	then
 		log_warning_msg "File system check was interrupted by user"
-	elif [ "$FSCKCODE" -gt 3 ]
+	elif [ $((FSCKCODE & 4)) -eq 4 ]
 	then
 		# Surprise! Re-directing from a HERE document (as in "cat << EOF")
 		# does not work because the fs is currently read-only.
@@ -415,14 +415,8 @@ Will restart in 5 seconds."
 		reboot
 	elif [ "$FSCKCODE" -gt 1 ]
 	then
-		log_failure_msg "The file system check corrected errors on the $NAME partition
-but requested that the system be restarted."
-		log_warning_msg "The system will be restarted in 5 seconds."
+		log_warning_msg "File system check failed but did not detect errors"
 		sleep 5
-		if [ "${verbose}" = "y" ] ; then
-			log_begin_msg "Will now restart"
-		fi
-		reboot
 	fi
 }
 


-- 
Ben Hutchings
The first rule of tautology club is the first rule of tautology club.

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: