diff options
Diffstat (limited to 'ubifs-utils/fsck.ubifs/problem.c')
-rw-r--r-- | ubifs-utils/fsck.ubifs/problem.c | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/ubifs-utils/fsck.ubifs/problem.c b/ubifs-utils/fsck.ubifs/problem.c index 1af6663..9df2c2a 100644 --- a/ubifs-utils/fsck.ubifs/problem.c +++ b/ubifs-utils/fsck.ubifs/problem.c @@ -37,12 +37,39 @@ struct fsck_problem { static const struct fsck_problem problem_table[] = { {0, "Corrupted superblock"}, // SB_CORRUPTED {PROBLEM_FIXABLE | PROBLEM_MUST_FIX | PROBLEM_DROP_DATA | PROBLEM_NEED_REBUILD, "Corrupted master node"}, // MST_CORRUPTED + {PROBLEM_FIXABLE | PROBLEM_MUST_FIX | PROBLEM_DROP_DATA | PROBLEM_NEED_REBUILD, "Corrupted log area"}, // LOG_CORRUPTED + {PROBLEM_FIXABLE | PROBLEM_MUST_FIX | PROBLEM_DROP_DATA, "Corrupted bud LEB"}, // BUD_CORRUPTED + {PROBLEM_FIXABLE | PROBLEM_MUST_FIX | PROBLEM_DROP_DATA | PROBLEM_NEED_REBUILD, "Corrupted index node"}, // TNC_CORRUPTED + {PROBLEM_FIXABLE | PROBLEM_MUST_FIX | PROBLEM_DROP_DATA, "Corrupted data searched from TNC"}, // TNC_DATA_CORRUPTED }; +static const char *get_question(const struct fsck_problem *problem, + int problem_type) +{ + if (problem->flags & PROBLEM_NEED_REBUILD) + return "Rebuild filesystem?"; + + switch (problem_type) { + case BUD_CORRUPTED: + return "Drop bud?"; + case TNC_DATA_CORRUPTED: + return "Drop it?"; + } + + return "Fix it?"; +} + static void print_problem(const struct ubifs_info *c, - const struct fsck_problem *problem) + const struct fsck_problem *problem, int problem_type, + const void *priv) { - log_out(c, "problem: %s", problem->desc); + if (problem_type == BUD_CORRUPTED) { + const struct ubifs_bud *bud = (const struct ubifs_bud *)priv; + + log_out(c, "problem: %s %d:%d %s", problem->desc, bud->lnum, + bud->start, dbg_jhead(bud->jhead)); + } else + log_out(c, "problem: %s", problem->desc); } static void fatal_error(const struct ubifs_info *c, @@ -59,17 +86,17 @@ static void fatal_error(const struct ubifs_info *c, * fix_problem - whether fixing the inconsistent problem * @c: UBIFS file-system description object * @problem_type: the type of inconsistent problem + * @priv: private data for problem instance * * This function decides to fix/skip the inconsistent problem or abort the * program according to @problem_type, returns %true if the problem should * be fixed, returns %false if the problem will be skipped. */ -bool fix_problem(const struct ubifs_info *c, int problem_type) +bool fix_problem(const struct ubifs_info *c, int problem_type, const void *priv) { bool ans, ask = true, def_y = true; const struct fsck_problem *problem = &problem_table[problem_type]; - const char *question = (problem->flags & PROBLEM_NEED_REBUILD) ? - "Rebuild filesystem?" : "Fix it?"; + const char *question = get_question(problem, problem_type); ubifs_assert(c, FSCK(c)->mode != REBUILD_MODE); @@ -88,7 +115,7 @@ bool fix_problem(const struct ubifs_info *c, int problem_type) (FSCK(c)->mode == DANGER_MODE0 || FSCK(c)->mode == DANGER_MODE1)) ask = false; - print_problem(c, problem); + print_problem(c, problem, problem_type, priv); ans = def_y; if (FSCK(c)->mode == NORMAL_MODE) { printf("%s[%d] (%s%s)", c->program_name, getpid(), |