Whamcloud - gitweb
e2fsck: Fix a number of problems that were inappropriately using PROMPT_ABORT
authorTheodore Ts'o <tytso@mit.edu>
Wed, 12 May 2010 22:58:53 +0000 (18:58 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 12 May 2010 22:58:53 +0000 (18:58 -0400)
There were a number of problems that were prompting the user whether
or not to ABORT, but then would abort regardless of whether the user
answered yes or no.  Change those to be PROMPT_NONE, PR_FATAL.

Also, fix PR_1_RESIZE_INODE_CREATE so that it recovers appropriately
after failing to create the resize inode.  This problem now uses
PROMPT_CONTINUE instead of PROMPT_ABORT, and if the user says, "no",
the code will abort.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
e2fsck/pass1.c
e2fsck/problem.c
e2fsck/problem.h

index a0249ff..3b65e8a 100644 (file)
@@ -1126,16 +1126,20 @@ void e2fsck_pass1(e2fsck_t ctx)
                clear_problem_context(&pctx);
                pctx.errcode = ext2fs_create_resize_inode(fs);
                if (pctx.errcode) {
-                       fix_problem(ctx, PR_1_RESIZE_INODE_CREATE, &pctx);
-                       /* Should never get here */
-                       ctx->flags |= E2F_FLAG_ABORT;
-                       return;
+                       if (!fix_problem(ctx, PR_1_RESIZE_INODE_CREATE,
+                                        &pctx)) {
+                               ctx->flags |= E2F_FLAG_ABORT;
+                               return;
+                       }
+                       pctx.errcode = 0;
+               }
+               if (!pctx.errcode) {
+                       e2fsck_read_inode(ctx, EXT2_RESIZE_INO, inode,
+                                         "recreate inode");
+                       inode->i_mtime = ctx->now;
+                       e2fsck_write_inode(ctx, EXT2_RESIZE_INO, inode,
+                                          "recreate inode");
                }
-               e2fsck_read_inode(ctx, EXT2_RESIZE_INO, inode,
-                                 "recreate inode");
-               inode->i_mtime = ctx->now;
-               e2fsck_write_inode(ctx, EXT2_RESIZE_INO, inode,
-                                  "recreate inode");
                fs->block_map = save_bmap;
                ctx->flags &= ~E2F_FLAG_RESIZE_INODE;
        }
@@ -1391,7 +1395,8 @@ static void adjust_extattr_refcount(e2fsck_t ctx, ext2_refcount_t refcount,
                        pctx.errcode = ext2fs_write_ext_attr(fs, blk,
                                                             block_buf);
                        if (pctx.errcode) {
-                               fix_problem(ctx, PR_1_EXTATTR_WRITE, &pctx);
+                               fix_problem(ctx, PR_1_EXTATTR_WRITE_ABORT,
+                                           &pctx);
                                continue;
                        }
                }
@@ -1505,7 +1510,7 @@ static int check_ext_attr(e2fsck_t ctx, struct problem_context *pctx,
 
        region = region_create(0, fs->blocksize);
        if (!region) {
-               fix_problem(ctx, PR_1_EA_ALLOC_REGION, pctx);
+               fix_problem(ctx, PR_1_EA_ALLOC_REGION_ABORT, pctx);
                ctx->flags |= E2F_FLAG_ABORT;
                return 0;
        }
index ceb2ae9..5825f5b 100644 (file)
@@ -703,7 +703,7 @@ 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,
@@ -711,9 +711,9 @@ static struct e2fsck_problem problem_table[] = {
          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,
@@ -721,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,
@@ -798,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,
index b1bc97f..7c4c156 100644 (file)
@@ -413,13 +413,13 @@ struct problem_context {
 #define PR_1_EXTATTR_REFCOUNT          0x01003C
 
 /* Error writing Extended Attribute block while fixing refcount */
-#define PR_1_EXTATTR_WRITE             0x01003D
+#define PR_1_EXTATTR_WRITE_ABORT       0x01003D
 
 /* Multiple EA blocks not supported */
 #define PR_1_EA_MULTI_BLOCK            0x01003E
 
 /* Error allocating EA region allocation structure */
-#define PR_1_EA_ALLOC_REGION           0x01003F
+#define PR_1_EA_ALLOC_REGION_ABORT     0x01003F
 
 /* Error EA allocation collision */
 #define PR_1_EA_ALLOC_COLLISION                0x010040