From 3cfe0a33b83fa2206ac12b81104450122504c08c Mon Sep 17 00:00:00 2001 From: az Date: Wed, 18 Dec 2024 07:55:53 +1000 Subject: [PATCH] fstab with UUID/LABEL: nofail handling for fsck add support for 'nofail' fstab option. if present, finit's fsck invocation ignores errors for this device. this is useful if you have an fstab entry for a device with UUID= or LABEL= which isn't always present and which you'd like to not bail on (so you set nofail). in this case finit leaves the presence-or-not decision to fsck, which exits nonzero. for block devices that are directly listed in fstab this change isn't important, because for such finit looks for the blockdev's existence and skips the fsck if n/a. --- src/finit.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/finit.c b/src/finit.c index 49107a53..f04a86df 100644 --- a/src/finit.c +++ b/src/finit.c @@ -272,8 +272,13 @@ static int fsck(int pass) * errors were corrected but that the boot may proceed. */ if (fsck_rc > 1) { - logit(LOG_CONSOLE | LOG_ALERT, "Failed fsck %s, attempting sulogin ...", dev); - sulogin(1); + if (hasmntopt(mnt,"nofail")) { + logit(LOG_CONSOLE | LOG_WARNING, "Ignoring failed fsck %s because of nofail option", dev); + fsck_rc = 0; + } else { + logit(LOG_CONSOLE | LOG_ALERT, "Failed fsck %s, attempting sulogin ...", dev); + sulogin(1); + } } rc += fsck_rc; }