Allow e2fsck exit codes of 0,1

From the e2fsck man pages, the exit codes of 0, 1, 2 should
not be treated as failures.  We should never see exit code 2 though,
since it only occurs when e2fsck is run against a mounted filesystem.

The solution is to extend the check to only fail on exit code > 1.

Test Plan
PASS: Verify e2fsck exit code handling during subcloud install
      with resized partition

Closes-Bug: 1998611

Change-Id: Ie22fd77e3d2e2d631ba467b818bdc77c77f0d8b8
Signed-off-by: Kyle MacLeod <kyle.macleod@windriver.com>
This commit is contained in:
Kyle MacLeod 2022-12-02 10:38:49 -05:00
parent 1796ed8740
commit f15661bcf6

@ -1781,7 +1781,14 @@ if [ "${backup_part_extension_required}" -ne 0 ]; then
wlog "Platform Backup partition: resizing ${BACKUP_PART} from ${BACKUP_PART_CURRENT_SIZE}MiB to ${BACKUP_SIZE}MiB"
e2fsck -p -f ${BACKUP_PART}
rc=$?
[ ${rc} -ne 0 ] && report_failure_with_msg "e2fsck failed on platform backup partition [rc=${rc}]"
# Handle e2fsck exit code, non-zero can still indicate success:
# 0 - No errors
# 1 - File system errors corrected
# 2 - File system errors corrected, system should be rebooted
# > 2 are all hard failures (see man e2fsck)
# Include 2 as a failure in our case, since it should only happen if the filesystem
# is mounted while e2fsck is run (not a valid scenario here).
[ ${rc} -gt 1 ] && report_failure_with_msg "e2fsck failed on platform backup partition [rc=${rc}]"
resize2fs -f ${BACKUP_PART}
rc=$?
[ ${rc} -ne 0 ] && report_failure_with_msg "Failed to resize ext4 fs of platform backup partition [rc=${rc}]"