]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
e2fsck: exit with exit status 0 if no errors were fixed
authorTheodore Ts'o <tytso@mit.edu>
Fri, 17 Feb 2017 03:02:35 +0000 (22:02 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 17 Feb 2017 03:02:35 +0000 (22:02 -0500)
Previously, e2fsck would exit with a status code of 1 even though the
only changes that it made to the file system were various
optimziations and not fixing file system corruption.  Since the man
page states that an exit status of 1 means "file system errors
corrupted", fix e2fsck to return an exit status of 0.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
16 files changed:
e2fsck/e2fsck.conf.5.in
e2fsck/journal.c
e2fsck/problem.c
e2fsck/problemP.h
e2fsck/unix.c
tests/f_collapse_extent_tree/expect.1
tests/f_compress_extent_tree_level/expect.1
tests/f_convert_bmap/expect.1
tests/f_convert_bmap_and_extent/expect.1
tests/f_extent_htree/expect.1
tests/f_jnl_errno/expect.1
tests/f_journal/expect.1
tests/f_orphan/expect.1
tests/f_orphan_extents_inode/expect.1
tests/f_rehash_dir/expect.1
tests/f_unsorted_EAs/expect.1

index 1848bdb8f5fa40fe42efef3a3a796e2f9287efeb..0bfc76abb34164dae1b04f4aa6efed74293745d8 100644 (file)
@@ -303,6 +303,13 @@ of 'should this problem be fixed?'.  The
 option even overrides the
 .B -y
 option given on the command-line (just for the specific problem, of course).
+.TP
+.I not_a_fix
+This boolean option, it set to true, marks the problem as
+one where if the user gives permission to make the requested change,
+it does not mean that the file system had a problem which has since
+been fixed.  This is used for requests to optimize the file system's
+data structure, such as pruning an extent tree.
 @TDB_MAN_COMMENT@.SH THE [scratch_files] STANZA
 @TDB_MAN_COMMENT@The following relations are defined in the
 @TDB_MAN_COMMENT@.I [scratch_files]
index 46fe7b4cd3331377fed56ca363ff12db15263892..c4f58f1b8519f733af4febdc940eae576c6685c7 100644 (file)
@@ -572,6 +572,7 @@ static void clear_v2_journal_fields(journal_t *journal)
        if (!fix_problem(ctx, PR_0_CLEAR_V2_JOURNAL, &pctx))
                return;
 
+       ctx->flags |= E2F_FLAG_PROBLEMS_FIXED;
        memset(((char *) journal->j_superblock) + V1_SB_SIZE, 0,
               ctx->fs->blocksize-V1_SB_SIZE);
        mark_buffer_dirty(journal->j_sb_buffer);
index 34a671e582ccdc8735ea39ad9da4681b3583059f..4b2506927cc21e111d02b9dc1ee612fbe98d7886 100644 (file)
@@ -1276,12 +1276,12 @@ static struct e2fsck_problem problem_table[] = {
        /* Inode extent tree could be shorter */
        { PR_1E_CAN_COLLAPSE_EXTENT_TREE,
          N_("@i %i @x tree (at level %b) could be shorter.  "),
-         PROMPT_FIX, PR_NO_OK | PR_PREEN_NO | PR_PREEN_OK },
+         PROMPT_FIX, PR_NO_OK | PR_PREEN_NO | PR_PREEN_OK | PR_NOT_A_FIX },
 
        /* Inode extent tree could be narrower */
        { PR_1E_CAN_NARROW_EXTENT_TREE,
          N_("@i %i @x tree (at level %b) could be narrower.  "),
-         PROMPT_FIX, PR_NO_OK | PR_PREEN_NO | PR_PREEN_OK },
+         PROMPT_FIX, PR_NO_OK | PR_PREEN_NO | PR_PREEN_OK | PR_NOT_A_FIX },
 
        /* Pass 2 errors */
 
@@ -2166,6 +2166,7 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx)
                reconfigure_bool(ctx, ptr, key, PR_NO_NOMSG, "no_nomsg");
                reconfigure_bool(ctx, ptr, key, PR_PREEN_NOHDR, "preen_noheader");
                reconfigure_bool(ctx, ptr, key, PR_FORCE_NO, "force_no");
+               reconfigure_bool(ctx, ptr, key, PR_NOT_A_FIX, "not_a_fix");
                profile_get_integer(ctx->profile, "options",
                                    "max_count_problems", 0, 0,
                                    &ptr->max_count);
@@ -2283,7 +2284,8 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx)
        if (ptr->flags & PR_AFTER_CODE)
                answer = fix_problem(ctx, ptr->second_code, pctx);
 
-       if (answer && (ptr->prompt != PROMPT_NONE))
+       if (answer && (ptr->prompt != PROMPT_NONE) &&
+           !(ptr->flags & PR_NOT_A_FIX))
                ctx->flags |= E2F_FLAG_PROBLEMS_FIXED;
 
        return answer;
index 7944cd6c72b83feb3e2e9c624c8454b427727005..63bb8df6c7bf70df78085baa21fabbc8746cae9b 100644 (file)
@@ -44,3 +44,4 @@ struct latch_descr {
 #define PR_CONFIG      0x080000 /* This problem has been customized
                                    from the config file */
 #define PR_FORCE_NO    0x100000 /* Force the answer to be no */
+#define PR_NOT_A_FIX   0x200000 /* Yes doesn't mean a problem was fixed */
index eb9f3119aaac3c8289abb6e33e10fe6123cc2d77..9e4d31a84ab4e1236af2d59fb7dbce304184357b 100644 (file)
@@ -1901,11 +1901,23 @@ no_journal:
                fix_problem(ctx, PR_6_IO_FLUSH, &pctx);
 
        if (was_changed) {
-               exit_value |= FSCK_NONDESTRUCT;
-               if (!(ctx->options & E2F_OPT_PREEN))
-                       log_out(ctx, _("\n%s: ***** FILE SYSTEM WAS "
-                                      "MODIFIED *****\n"),
+               int fs_fixed = (ctx->flags & E2F_FLAG_PROBLEMS_FIXED);
+
+               if (fs_fixed)
+                       exit_value |= FSCK_NONDESTRUCT;
+               if (!(ctx->options & E2F_OPT_PREEN)) {
+#if 0  /* Do this later; it breaks too many tests' golden outputs */
+                       log_out(ctx, fs_fixed ?
+                               _("\n%s: ***** FILE SYSTEM ERRORS "
+                                 "CORRECTED *****\n") :
+                               _("%s: File system was modified.\n"),
                                ctx->device_name);
+#else
+                       log_out(ctx,
+                               _("\n%s: ***** FILE SYSTEM WAS MODIFIED *****\n"),
+                               ctx->device_name);
+#endif
+               }
                if (ctx->mount_flags & EXT2_MF_ISROOT) {
                        log_out(ctx, _("%s: ***** REBOOT SYSTEM *****\n"),
                                ctx->device_name);
index e2eb65e0a795d5f0249de48454500e8242d98dcd..8165a589abb800ee0495624f44e39e3f13b80ee7 100644 (file)
@@ -13,4 +13,4 @@ Pass 5: Checking group summary information
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
 test_filesys: 12/128 files (0.0% non-contiguous), 19/512 blocks
-Exit status is 1
+Exit status is 0
index a359c9973f9a94f06500c10cf731a6f0e6c2058c..dd33f63d280ca014212829464dcfbbda1df13b26 100644 (file)
@@ -20,4 +20,4 @@ Pass 5: Checking group summary information
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
 test_filesys: 12/128 files (8.3% non-contiguous), 26/512 blocks
-Exit status is 1
+Exit status is 0
index 7d2ca86e9ac2f3e78c05d930d2ab17848e0099c5..c387962fc6c3a17a3c9cd4f4f7f2ca92e382b3c1 100644 (file)
@@ -23,4 +23,4 @@ Pass 5: Checking group summary information
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
 test_filesys: 12/128 files (8.3% non-contiguous), 570/2048 blocks
-Exit status is 1
+Exit status is 0
index 7af91aa3e07a97749e691998f7829171436edf24..c86c57159821b05bd11ff248dee21c4ee4f4ddb5 100644 (file)
@@ -30,4 +30,4 @@ Pass 5: Checking group summary information
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
 test_filesys: 13/128 files (15.4% non-contiguous), 574/2048 blocks
-Exit status is 1
+Exit status is 0
index 223ca697910e165ab04257bc631a72402682a4f7..ea4840538f380d41c136fd54edfd0729763da1a4 100644 (file)
@@ -26,4 +26,4 @@ test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
            0 sockets
 ------------
          343 files
-Exit status is 1
+Exit status is 0
index c572951252c2e135d35ba48d1e243e21f9d02629..41342344136e7b6e774775c0d07a6ae03a6bf0b6 100644 (file)
@@ -6,4 +6,4 @@ Pass 5: Checking group summary information
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
 test_filesys: 11/2048 files (9.1% non-contiguous), 1330/8192 blocks
-Exit status is 1
+Exit status is 0
index a202c80c77368543125ab0f58d87bff3374947e3..0a18654d049f24760bd50a43a104e9614f771e6a 100644 (file)
@@ -59,4 +59,4 @@ Pass 5: Checking group summary information
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
 test_filesys: 53/2048 files (1.9% non-contiguous), 1409/8192 blocks
-Exit status is 1
+Exit status is 0
index eddc1f8b6206f8a53c61d948c679cfd320979299..087ebee24ad7b4e5f3d2303243cb844920109983 100644 (file)
@@ -11,4 +11,4 @@ Pass 5: Checking group summary information
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
 test_filesys: 12/2048 files (0.0% non-contiguous), 1303/8192 blocks
-Exit status is 1
+Exit status is 0
index 2eaab78aa1cf9a56e16c06636e8795d293bff1eb..5d713b36daf7d1c428035d8b944b661879e8d4cc 100644 (file)
@@ -7,4 +7,4 @@ Pass 5: Checking group summary information
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
 test_filesys: 12/16 files (0.0% non-contiguous), 21/100 blocks
-Exit status is 1
+Exit status is 0
index 60767651d832b00535429494d784161766cf48a0..c1449ba01fa1c4c1124be216199cbbd57953a1c3 100644 (file)
@@ -7,4 +7,4 @@ Pass 5: Checking group summary information
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
 test_filesys: 105/2048 files (2.9% non-contiguous), 336/512 blocks
-Exit status is 1
+Exit status is 0
index 7d588d7a0872574912fbb8c46447f4fc11abfc77..64b9045e6a8668b9aafc5b83393c58f45378aa23 100644 (file)
@@ -8,4 +8,4 @@ Pass 5: Checking group summary information
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
 test_filesys: 12/2048 files (0.0% non-contiguous), 1294/2048 blocks
-Exit status is 1
+Exit status is 0