dosfstools icon indicating copy to clipboard operation
dosfstools copied to clipboard

Use standard fsck exit codes in fsck.fat

Open fstirlitz opened this issue 7 years ago • 1 comments

Excerpt from fsck(8):

       The exit code returned by fsck is the sum of the following conditions:

              0      No errors
              1      Filesystem errors corrected
              2      System should be rebooted
              4      Filesystem errors left uncorrected
              8      Operational error
              16     Usage or syntax error
              32     Checking canceled by user request
              128    Shared-library error

The way this is implemented in /sbin/fsck is by performing bitwise OR on exit codes of the filesystem-specific fsck subprocesses it spawns; this relies on them in turn implementing the same convention in their exit codes.

fsck.fat does not conform to this standard: for example, invalid command lines result in exit code 2. Quitting at an interactive prompt results in exit code 0. The program chooses between exit codes 0 and 1 based on whether the changes were written to the file system image, not based on whether errors were detected.

Software which relies on these exit codes being used properly may perform erroneously. Apart from /sbin/fsck, this includes systemd-fsck and probably other software.

(Discovered while investigating issue #88; also subsumes #48.)

fstirlitz avatar May 30 '18 05:05 fstirlitz

What would be the probability of a patch being accepted which converts all the existing exit code returning code points into ones which adhere to the fsck exit code specification?

MarkJonas avatar Feb 03 '25 09:02 MarkJonas