Page MenuHomeFreeBSD

Exit fsck_ffs with non-zero status when file system is not repaired.
ClosedPublic

Authored by dab on Jan 11 2018, 3:17 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Jun 2, 12:27 AM
Unknown Object (File)
Mar 8 2024, 12:20 AM
Unknown Object (File)
Jan 25 2024, 5:17 AM
Unknown Object (File)
Dec 20 2023, 2:15 AM
Unknown Object (File)
Nov 28 2023, 7:43 PM
Unknown Object (File)
Nov 24 2023, 2:54 AM
Unknown Object (File)
Nov 13 2023, 1:18 AM
Unknown Object (File)
Oct 22 2023, 10:27 PM
Subscribers

Details

Summary

When the fsck_ffs program cannot fully repair a file system,
it will output the message PLEASE RERUN FSCK. However, it does not
exit with a non-zero status in this case (contradicting the man page
claim that it "exits with 0 on success, and >0 if an error occurs."
The fsck rc-script (when running "fsck -y") tests the status from fsck
(which passes along the exit status from fsck_ffs) and issues a
"stop_boot" if the status fails. However, this is not effective since
fsck_ffs can return zero even on (some) errors. Effectively, it is
left to a later step in the boot process when the file systems are
mounted to detect the still-unclean file system and stop the boot.

This change modifies fsck_ffs so that when it cannot fully repair the
file system and issues the PLEASE RERUN FSCK message it also exits
with a non-zero status.

While here, the fsck_ffs man page has also been updated to document
the failing exit status codes used by fsck_ffs. Previously, only exit
status 7 was documented. Some of these exit statuses are tested for in
the fsck rc-script, so they are clearly depended upon and deserve
documentation.

Test Plan

Run fsck_ffs under the debugger on a file system. Force the
"rerun" flag to be set. Make sure that the exit status is non-zero
(and, specifically, equal to the new ERERUN define in fsck.h).

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 14301
Build 14461: arc lint + arc unit

Event Timeline

This looks like a sensible and long overdue change.

This revision is now accepted and ready to land.Jan 13 2018, 6:28 AM
jilles added inline comments.
sbin/fsck_ffs/fsck_ffs.8
386

Consider adding markup like

a
.Dv SIGQUIT
was received
406–412

Note that it is not arbitrary that many of these are powers of two. When fsck(8) runs checks on multiple filesystems, it combines their exit statuses using bitwise OR.

dab added inline comments.
sbin/fsck_ffs/fsck_ffs.8
406–412

You are correct. I was debating whether I should add a note to that effect, but whether it does or does not end up OR-ing statuses for multiple file systems together isn't entirely straightforward. Sometimes it will return a status and loop to the next file system, sometimes it will simply exit() with the status from a single (un-clean) file system.

Somehow inadvertently removed jilles when I posted that last comment; add jilles back.

Update the man page as suggested by jilles in review.

This revision now requires review to proceed.Jan 14 2018, 2:47 AM
dab marked an inline comment as done.Jan 14 2018, 2:49 AM

Approve of latest change.

This revision is now accepted and ready to land.Jan 14 2018, 7:15 AM
This revision was automatically updated to reflect the committed changes.