From: Theodore Ts'o Date: Sat, 31 Dec 2005 21:33:33 +0000 (-0500) Subject: Add e2fsck problem handling to be configurable X-Git-Tag: E2FSPROGS-1.39-WIP-1231~4 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=8fd98bba213bbcc93e43993aaf41e7dec19a1b61;p=tools%2Fe2fsprogs.git Add e2fsck problem handling to be configurable Add the ability for the e2fsck configuration file to override the behaviour of e2fsck when a particular filesystem problem is encountered. This allows reconnecting an inode to lost+found to not stop the boot sequence, if a system administrator really badly wants this behaviour for some specialized reason, for example. Signed-off-by: "Theodore Ts'o" --- diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog index 951ff73..29a907e 100644 --- a/e2fsck/ChangeLog +++ b/e2fsck/ChangeLog @@ -1,5 +1,13 @@ 2005-12-31 Theodore Ts'o + * problem.c (fix_problem), problemP.h: Add the ability for the + e2fsck configuration file to override the behaviour of + e2fsck when a particular filesystem problem is + encountered. This allows reconnecting an inode to + lost+found to not stop the boot sequence, if a system + administrator really badly wants this behaviour for some + specialized reason, for example. + * unix.c (main): If the e2fsck configuration file sets the allow_cancellation option to be true, then if the filesystem does not have any known problems, and was known diff --git a/e2fsck/problem.c b/e2fsck/problem.c index 7d70f56..a25cc08 100644 --- a/e2fsck/problem.c +++ b/e2fsck/problem.c @@ -98,7 +98,7 @@ static const char *preen_msg[] = { "", /* 20 */ }; -static const struct e2fsck_problem problem_table[] = { +static struct e2fsck_problem problem_table[] = { /* Pre-Pass 1 errors */ @@ -1497,7 +1497,7 @@ static struct latch_descr pr_latch_info[] = { { -1, 0, 0 }, }; -static const struct e2fsck_problem *find_problem(problem_t code) +static struct e2fsck_problem *find_problem(problem_t code) { int i; @@ -1564,10 +1564,24 @@ void clear_problem_context(struct problem_context *ctx) ctx->group = -1; } +static void reconfigure_bool(e2fsck_t ctx, struct e2fsck_problem *ptr, + const char *key, int mask, const char *name) +{ + int bool; + + bool = (ptr->flags & mask); + profile_get_boolean(ctx->profile, "problems", key, name, bool, &bool); + if (bool) + ptr->flags |= mask; + else + ptr->flags &= ~mask; +} + + int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx) { ext2_filsys fs = ctx->fs; - const struct e2fsck_problem *ptr; + struct e2fsck_problem *ptr; struct latch_descr *ldesc = 0; const char *message; int def_yn, answer, ans; @@ -1579,6 +1593,27 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx) printf(_("Unhandled error code (0x%x)!\n"), code); return 0; } + if (!(ptr->flags & PR_CONFIG)) { + char key[9], *new_desc; + + sprintf(key, "0x%06x", code); + + profile_get_string(ctx->profile, "problems", key, + "description", 0, &new_desc); + if (new_desc) + ptr->e2p_description = new_desc; + + reconfigure_bool(ctx, ptr, key, PR_PREEN_OK, "preen_ok"); + reconfigure_bool(ctx, ptr, key, PR_NO_OK, "no_ok"); + reconfigure_bool(ctx, ptr, key, PR_NO_DEFAULT, "no_default"); + reconfigure_bool(ctx, ptr, key, PR_MSG_ONLY, "print_message_only"); + reconfigure_bool(ctx, ptr, key, PR_PREEN_NOMSG, "preen_nomessage"); + 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"); + + ptr->flags |= PR_CONFIG; + } def_yn = 1; if ((ptr->flags & PR_NO_DEFAULT) || ((ptr->flags & PR_PREEN_NO) && (ctx->options & E2F_OPT_PREEN)) || diff --git a/e2fsck/problemP.h b/e2fsck/problemP.h index 329056b..21264fa 100644 --- a/e2fsck/problemP.h +++ b/e2fsck/problemP.h @@ -39,4 +39,5 @@ struct latch_descr { #define PR_NO_NOMSG 0x010000 /* Don't print a message if e2fsck -n */ #define PR_PREEN_NO 0x020000 /* Use No as an answer if preening */ #define PR_PREEN_NOHDR 0x040000 /* Don't print the preen header */ - +#define PR_CONFIG 0x080000 /* This problem has been customized + from the config file */