+2001-12-21 Theodore Tso <tytso@valinux.com>
+
+ * journal.c (e2fsck_check_ext3_journal): Give the opportunity to
+ run the journal even if recovery flag is cleared. If
+ we're using a backup superblock, run the journal by
+ default.
+
+ * e2fsck.h (E2F_OPT_FORCE), unix.c (PRS, check_if_skip): Use a
+ bitfield in the e2fsck context flags word to indicate
+ whether or not a check should be forced. This allows the
+ journal code to set the option if necessary to force a
+ filesystem check.
+
+ * problem.h, problem.c: Remove PR_0_JOURNAL_RESET_JOURNAL, and add
+ PR_0_JOURNAL_RUN and PR_0_JOURNAL_RUN_DEFAULT. Update
+ problem decription texts.
+
2001-12-16 Theodore Tso <tytso@valinux.com>
* e2fsck.h (ext2fs_get_refcount_size), unix.c (check_mount, PRS),
#define E2F_OPT_TIME2 0x0020
#define E2F_OPT_CHECKBLOCKS 0x0040
#define E2F_OPT_DEBUG 0x0080
+#define E2F_OPT_FORCE 0x0100
/*
* E2fsck flags
int recover = ctx->fs->super->s_feature_incompat &
EXT3_FEATURE_INCOMPAT_RECOVER;
struct problem_context pctx;
+ problem_t problem;
int reset = 0, force_fsck = 0;
int retval;
if (sb->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL &&
!(sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_RECOVER) &&
journal->j_superblock->s_start != 0) {
- if (fix_problem(ctx, PR_0_JOURNAL_RESET_JOURNAL, &pctx)) {
+ /* Print status information */
+ fix_problem(ctx, PR_0_JOURNAL_RECOVERY_CLEAR, &pctx);
+ if (ctx->superblock)
+ problem = PR_0_JOURNAL_RUN_DEFAULT;
+ else
+ problem = PR_0_JOURNAL_RUN;
+ if (fix_problem(ctx, problem, &pctx)) {
+ ctx->options |= E2F_OPT_FORCE;
+ sb->s_feature_incompat |=
+ EXT3_FEATURE_INCOMPAT_RECOVER;
+ ext2fs_mark_super_dirty(ctx->fs);
+ } else if (fix_problem(ctx,
+ PR_0_JOURNAL_RESET_JOURNAL, &pctx)) {
reset = 1;
sb->s_state &= ~EXT2_VALID_FS;
ext2fs_mark_super_dirty(ctx->fs);
#define PROMPT_DELETE 15
#define PROMPT_SUPPRESS 16
#define PROMPT_UNLINK 17
+#define PROMPT_NULL 18
/*
* These are the prompts which are used to ask the user if they want
N_("Delete file"), /* 15 */
N_("Suppress messages"),/* 16 */
N_("Unlink"), /* 17 */
+ "", /* 18 */
};
/*
/* Superblock flag should be cleared */
{ PR_0_JOURNAL_HAS_JOURNAL,
- N_("@S doesn't have has_journal flag, but has ext3 @j %s.\n"),
+ N_("@S doesn't have has_@j flag, but has ext3 @j %s.\n"),
PROMPT_CLEAR, PR_PREEN_OK },
/* Superblock flag is incorrect */
N_("@S has ext3 needs_recovery flag set, but no @j.\n"),
PROMPT_CLEAR, PR_PREEN_OK },
- /* Journal should be reset */
+ /* Journal has data, but recovery flag is clear */
+ { PR_0_JOURNAL_RECOVERY_CLEAR,
+ N_("ext3 recovery flag clear, but @j has data.\n"),
+ PROMPT_NONE, 0 },
+
+ /* Ask if we should clear the journal */
{ PR_0_JOURNAL_RESET_JOURNAL,
- N_("*** WARNING *** leaving data in the @j may be DANGEROUS.\n"),
- PROMPT_NONE, PR_PREEN_NOMSG|PR_AFTER_CODE, PR_0_JOURNAL_RESET_PROMPT},
+ N_("Clear @j"),
+ PROMPT_NULL, PR_PREEN_NOMSG },
- /* Journal should be reset */
- { PR_0_JOURNAL_RESET_PROMPT,
- N_("ext3 recovery flag clear, but journal has data.\n"),
- PROMPT_CLEAR, PR_PREEN_OK|PR_PREEN_NOMSG },
+ /* Ask if we should run the journal anyway */
+ { PR_0_JOURNAL_RUN,
+ N_("Run @j anyway"),
+ PROMPT_NULL, 0 },
+
+ /* Run the journal by default */
+ { PR_0_JOURNAL_RUN_DEFAULT,
+ N_("Recovery flag not set in backup @S, so running @j anyway.\n"),
+ PROMPT_NONE, 0 },
/* Clearing orphan inode */
{ PR_0_ORPHAN_CLEAR_INODE,
/* Superblock has recovery flag set but no journal */
#define PR_0_JOURNAL_RECOVER_SET 0x000017
-/* Warning message about leaving data in the journal */
-#define PR_0_JOURNAL_RESET_JOURNAL 0x000018
+/* Journal has data, but recovery flag is clear */
+#define PR_0_JOURNAL_RECOVERY_CLEAR 0x000018
-/* Superblock recovery flag clear - journal needs to be reset */
-#define PR_0_JOURNAL_RESET_PROMPT 0x000019
+/* Ask if we should clear the journal */
+#define PR_0_JOURNAL_RESET_JOURNAL 0x000019
/* Filesystem revision is 0, but feature flags are set */
#define PR_0_FS_REV_LEVEL 0x00001A
/* Clearing V2 journal superblock */
#define PR_0_CLEAR_V2_JOURNAL 0x00002A
+/* Run journal anyway */
+#define PR_0_JOURNAL_RUN 0x00002B
+
+/* Run journal anyway by default */
+#define PR_0_JOURNAL_RUN_DEFAULT 0x00002C
+
/*
* Pass 1 errors
*/
static int normalize_swapfs = 0;
static int cflag = 0; /* check disk */
static int show_version_only = 0;
-static int force = 0;
static int verbose = 0;
static int replace_bad_blocks = 0;
const char *reason = NULL;
unsigned int reason_arg = 0;
- if (force || bad_blocks_file || cflag || swapfs)
+ if ((ctx->options & E2F_OPT_FORCE) || bad_blocks_file ||
+ cflag || swapfs)
return;
if (fs->super->s_state & EXT2_ERROR_FS)
ctx->options |= E2F_OPT_DEBUG;
break;
case 'f':
- force = 1;
+ ctx->options |= E2F_OPT_FORCE;
break;
case 'F':
flush = 1;