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)
Sat, Dec 14, 11:24 PM
Unknown Object (File)
Sun, Nov 24, 6:24 PM
Unknown Object (File)
Oct 18 2024, 8:54 PM
Unknown Object (File)
Oct 3 2024, 7:05 PM
Unknown Object (File)
Sep 22 2024, 8:29 AM
Unknown Object (File)
Sep 19 2024, 10:10 AM
Unknown Object (File)
Sep 8 2024, 12:59 PM
Unknown Object (File)
Sep 7 2024, 10:03 AM
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 Not Applicable
Unit
Tests Not Applicable

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 ↗(On Diff #37806)

Consider adding markup like

a
.Dv SIGQUIT
was received
406–412 ↗(On Diff #37806)

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 ↗(On Diff #37806)

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.