Whamcloud - gitweb
e2fsck: Add the ability to force a problem to not be fixed
[tools/e2fsprogs.git] / e2fsck / problem.c
index 43a0aa6..8f0b211 100644 (file)
@@ -252,12 +252,12 @@ static struct e2fsck_problem problem_table[] = {
 
        /* Illegal block found in orphaned inode */
        { PR_0_ORPHAN_ILLEGAL_BLOCK_NUM,
-          N_("@I @b #%B (%b) found in @o @i %i.\n"),
+          N_("@I %B (%b) found in @o @i %i.\n"),
          PROMPT_NONE, 0 },
 
        /* Already cleared block found in orphaned inode */
        { PR_0_ORPHAN_ALREADY_CLEARED_BLOCK,
-          N_("Already cleared @b #%B (%b) found in @o @i %i.\n"),
+          N_("Already cleared %B (%b) found in @o @i %i.\n"),
          PROMPT_NONE, 0 },
 
        /* Illegal orphan inode in superblock */
@@ -334,13 +334,13 @@ static struct e2fsck_problem problem_table[] = {
 
        /* Last mount time is in the future */
        { PR_0_FUTURE_SB_LAST_MOUNT,
-         N_("@S last mount time is in the future.  "),
-         PROMPT_FIX, PR_PREEN_OK | PR_NO_OK },
+         N_("@S last mount time (%t,\n\tnow = %T) is in the future.\n"),
+         PROMPT_FIX, PR_NO_OK },
 
        /* Last write time is in the future */
        { PR_0_FUTURE_SB_LAST_WRITE,
-         N_("@S last write time is in the future.  "),
-         PROMPT_FIX, PR_PREEN_OK | PR_NO_OK },
+         N_("@S last write time (%t,\n\tnow = %T) is in the future.\n"),
+         PROMPT_FIX, PR_NO_OK },
 
        { PR_0_EXTERNAL_JOURNAL_HINT,
          N_("@S hint for external superblock @s %X.  "),
@@ -354,7 +354,7 @@ static struct e2fsck_problem problem_table[] = {
        /* group descriptor N checksum is invalid. */
        { PR_0_GDT_CSUM,
          N_("@g descriptor %g checksum is invalid.  "),
-            PROMPT_FIX, PR_PREEN_OK },
+            PROMPT_FIX, PR_LATCH_BG_CHECKSUM },
 
        /* group descriptor N marked uninitialized without feature set. */
        { PR_0_GDT_UNINIT,
@@ -385,6 +385,23 @@ static struct e2fsck_problem problem_table[] = {
          N_("The test_fs flag is set (and ext4 is available).  "),
          PROMPT_CLEAR, PR_PREEN_OK },
 
+       /* Last mount time is in the future (fudged) */
+       { PR_0_FUTURE_SB_LAST_MOUNT_FUDGED,
+         N_("@S last mount time is in the future.\n\t(by less than a day, "
+            "probably due to the hardware clock being incorrectly set)  "),
+         PROMPT_FIX, PR_PREEN_OK | PR_NO_OK },
+
+       /* Last write time is in the future (fudged) */
+       { PR_0_FUTURE_SB_LAST_WRITE_FUDGED,
+         N_("@S last write time is in the future.\n\t(by less than a day, "
+            "probably due to the hardware clock being incorrectly set).  "),
+         PROMPT_FIX, PR_PREEN_OK | PR_NO_OK },
+
+       /* Block group checksum (latch question) is invalid. */
+       { PR_0_GDT_CSUM_LATCH,
+         N_("One or more @b @g descriptor checksums are invalid.  "),
+            PROMPT_FIX, PR_PREEN_OK },
+
        /* Pass 1 errors */
 
        /* Pass 1: Checking inodes, blocks, and sizes */
@@ -458,12 +475,12 @@ static struct e2fsck_problem problem_table[] = {
 
        /* Illegal blocknumber in inode */
        { PR_1_ILLEGAL_BLOCK_NUM,
-         N_("@I @b #%B (%b) in @i %i.  "),
+         N_("@I %B (%b) in @i %i.  "),
          PROMPT_CLEAR, PR_LATCH_BLOCK },
 
        /* Block number overlaps fs metadata */
        { PR_1_BLOCK_OVERLAPS_METADATA,
-         N_("@b #%B (%b) overlaps @f metadata in @i %i.  "),
+         N_("%B (%b) overlaps @f metadata in @i %i.  "),
          PROMPT_CLEAR, PR_LATCH_BLOCK },
 
        /* Inode has illegal blocks (latch question) */
@@ -478,7 +495,7 @@ static struct e2fsck_problem problem_table[] = {
 
        /* Illegal block number in bad block inode */
        { PR_1_BB_ILLEGAL_BLOCK_NUM,
-         N_("@I @b #%B (%b) in bad @b @i.  "),
+         N_("@I %B (%b) in bad @b @i.  "),
          PROMPT_CLEAR, PR_LATCH_BBLOCK },
 
        /* Bad block inode has illegal blocks (latch question) */
@@ -686,17 +703,17 @@ static struct e2fsck_problem problem_table[] = {
        /* Error reading Extended Attribute block while fixing refcount */
        { PR_1_EXTATTR_READ_ABORT,
          N_("Error reading @a @b %b (%m).  "),
-         PROMPT_ABORT, 0 },
+         PROMPT_NONE, PR_FATAL },
 
        /* Extended attribute reference count incorrect */
        { PR_1_EXTATTR_REFCOUNT,
-         N_("@a @b %b has reference count %B, @s %N.  "),
+         N_("@a @b %b has reference count %r, @s %N.  "),
          PROMPT_FIX, 0 },
 
        /* Error writing Extended Attribute block while fixing refcount */
-       { PR_1_EXTATTR_WRITE,
+       { PR_1_EXTATTR_WRITE_ABORT,
          N_("Error writing @a @b %b (%m).  "),
-         PROMPT_ABORT, 0 },
+         PROMPT_NONE, PR_FATAL },
 
        /* Multiple EA blocks not supported */
        { PR_1_EA_MULTI_BLOCK,
@@ -704,9 +721,9 @@ static struct e2fsck_problem problem_table[] = {
          PROMPT_CLEAR, 0},
 
        /* Error allocating EA region allocation structure */
-       { PR_1_EA_ALLOC_REGION,
+       { PR_1_EA_ALLOC_REGION_ABORT,
          N_("@A @a @b %b.  "),
-         PROMPT_ABORT, 0},
+         PROMPT_NONE, PR_FATAL},
 
        /* Error EA allocation collision */
        { PR_1_EA_ALLOC_COLLISION,
@@ -729,17 +746,17 @@ static struct e2fsck_problem problem_table[] = {
 
        /* Directory too big */
        { PR_1_TOOBIG_DIR,
-         N_("@b #%B (%b) causes @d to be too big.  "),
+         N_("%B (%b) causes @d to be too big.  "),
          PROMPT_CLEAR, PR_LATCH_TOOBIG },
 
        /* Regular file too big */
        { PR_1_TOOBIG_REG,
-         N_("@b #%B (%b) causes file to be too big.  "),
+         N_("%B (%b) causes file to be too big.  "),
          PROMPT_CLEAR, PR_LATCH_TOOBIG },
 
        /* Symlink too big */
        { PR_1_TOOBIG_SYMLINK,
-         N_("@b #%B (%b) causes symlink to be too big.  "),
+         N_("%B (%b) causes symlink to be too big.  "),
          PROMPT_CLEAR, PR_LATCH_TOOBIG },
 
        /* INDEX_FL flag set on a non-HTREE filesystem */
@@ -781,7 +798,7 @@ static struct e2fsck_problem problem_table[] = {
        /* Resize inode failed */
        { PR_1_RESIZE_INODE_CREATE,
          N_("Resize @i (re)creation failed: %m."),
-         PROMPT_ABORT, 0 },
+         PROMPT_CONTINUE, 0 },
 
        /* invalid inode->i_extra_isize */
        { PR_1_EXTRA_ISIZE,
@@ -868,6 +885,11 @@ static struct e2fsck_problem problem_table[] = {
          N_("@i %i has an invalid extent node (blk %b, lblk %c)\n"),
          PROMPT_CLEAR, 0 },
 
+       { PR_1_EOFBLOCKS_FL_SET,
+         N_("@i %i should not have EOFBLOCKS_FL set "
+            "(size %Is, lblk %r)\n"),
+         PROMPT_CLEAR, PR_PREEN_OK },
+
        /* Pass 1b errors */
 
        /* Pass 1B: Rescan for duplicate/bad blocks */
@@ -926,7 +948,7 @@ static struct e2fsck_problem problem_table[] = {
        /* File has duplicate blocks */
        { PR_1D_DUP_FILE,
          N_("File %Q (@i #%i, mod time %IM) \n"
-         "  has %B @m @b(s), shared with %N file(s):\n"),
+         "  has %r @m @b(s), shared with %N file(s):\n"),
          PROMPT_NONE, 0 },
 
        /* List of files sharing duplicate blocks */
@@ -1060,17 +1082,17 @@ static struct e2fsck_problem problem_table[] = {
 
        /* directory corrupted */
        { PR_2_DIR_CORRUPTED,
-         N_("@d @i %i, @b %B, offset %N: @d corrupted\n"),
+         N_("@d @i %i, %B, offset %N: @d corrupted\n"),
          PROMPT_SALVAGE, 0 },
 
        /* filename too long */
        { PR_2_FILENAME_LONG,
-         N_("@d @i %i, @b %B, offset %N: filename too long\n"),
+         N_("@d @i %i, %B, offset %N: filename too long\n"),
          PROMPT_TRUNCATE, 0 },
 
        /* Directory inode has a missing block (hole) */
        { PR_2_DIRECTORY_HOLE,
-         N_("@d @i %i has an unallocated @b #%B.  "),
+         N_("@d @i %i has an unallocated %B.  "),
          PROMPT_ALLOCATE, 0 },
 
        /* '.' is not NULL terminated */
@@ -1195,22 +1217,22 @@ static struct e2fsck_problem problem_table[] = {
 
        /* Node in HTREE directory not referenced */
        { PR_2_HTREE_NOTREF,
-         N_("@p @h %d: node (%B) not referenced\n"),
+         N_("@p @h %d: %B not referenced\n"),
          PROMPT_NONE, 0 },
 
        /* Node in HTREE directory referenced twice */
        { PR_2_HTREE_DUPREF,
-         N_("@p @h %d: node (%B) referenced twice\n"),
+         N_("@p @h %d: %B referenced twice\n"),
          PROMPT_NONE, 0 },
 
        /* Node in HTREE directory has bad min hash */
        { PR_2_HTREE_MIN_HASH,
-         N_("@p @h %d: node (%B) has bad min hash\n"),
+         N_("@p @h %d: %B has bad min hash\n"),
          PROMPT_NONE, 0 },
 
        /* Node in HTREE directory has bad max hash */
        { PR_2_HTREE_MAX_HASH,
-         N_("@p @h %d: node (%B) has bad max hash\n"),
+         N_("@p @h %d: %B has bad max hash\n"),
          PROMPT_NONE, 0 },
 
        /* Clear invalid HTREE directory */
@@ -1234,22 +1256,22 @@ static struct e2fsck_problem problem_table[] = {
 
        /* Invalid HTREE limit */
        { PR_2_HTREE_BAD_LIMIT,
-         N_("@p @h %d: node (%B) has @n limit (%N)\n"),
+         N_("@p @h %d: %B has @n limit (%N)\n"),
          PROMPT_CLEAR_HTREE, PR_PREEN_OK },
 
        /* Invalid HTREE count */
        { PR_2_HTREE_BAD_COUNT,
-         N_("@p @h %d: node (%B) has @n count (%N)\n"),
+         N_("@p @h %d: %B has @n count (%N)\n"),
          PROMPT_CLEAR_HTREE, PR_PREEN_OK },
 
        /* HTREE interior node has out-of-order hashes in table */
        { PR_2_HTREE_HASH_ORDER,
-         N_("@p @h %d: node (%B) has an unordered hash table\n"),
+         N_("@p @h %d: %B has an unordered hash table\n"),
          PROMPT_CLEAR_HTREE, PR_PREEN_OK },
 
        /* Node in HTREE directory has invalid depth */
        { PR_2_HTREE_BAD_DEPTH,
-         N_("@p @h %d: node (%B) has @n depth (%N)\n"),
+         N_("@p @h %d: %B has @n depth (%N)\n"),
          PROMPT_NONE, 0 },
 
        /* Duplicate directory entry found */
@@ -1633,6 +1655,7 @@ static struct latch_descr pr_latch_info[] = {
        { PR_LATCH_LOW_DTIME, PR_1_ORPHAN_LIST_REFUGEES, 0 },
        { PR_LATCH_TOOBIG, PR_1_INODE_TOOBIG, 0 },
        { PR_LATCH_OPTIMIZE_DIR, PR_3A_OPTIMIZE_DIR_HEADER, PR_3A_OPTIMIZE_DIR_END },
+       { PR_LATCH_BG_CHECKSUM, PR_0_GDT_CSUM_LATCH, 0 },
        { -1, 0, 0 },
 };
 
@@ -1750,6 +1773,7 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx)
                reconfigure_bool(ctx, ptr, key, PR_NOCOLLATE, "no_collate");
                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");
 
                ptr->flags |= PR_CONFIG;
        }
@@ -1780,7 +1804,7 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx)
            (ctx->options & E2F_OPT_PREEN))
                suppress++;
        if ((ptr->flags & PR_NO_NOMSG) &&
-           (ctx->options & E2F_OPT_NO))
+           ((ctx->options & E2F_OPT_NO) || (ptr->flags & PR_FORCE_NO)))
                suppress++;
        if (!suppress) {
                message = ptr->e2p_description;
@@ -1804,7 +1828,11 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx)
                else
                        answer = def_yn;
        } else {
-               if (ctx->options & E2F_OPT_PREEN) {
+               if (ptr->flags & PR_FORCE_NO) {
+                       answer = 0;
+                       if (!suppress)
+                               print_answer = 1;
+               } else if (ctx->options & E2F_OPT_PREEN) {
                        answer = def_yn;
                        if (!(ptr->flags & PR_PREEN_NOMSG))
                                print_answer = 1;