From: Andreas Dilger Date: Thu, 12 Apr 2012 23:24:55 +0000 (-0600) Subject: e2fsck: parse config file before command-line opts X-Git-Tag: v1.46.2.wc1~24 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;ds=sidebyside;h=bd14945bb0efa2e4a05b5790c08dd860bc58be2b;p=tools%2Fe2fsprogs.git e2fsck: parse config file before command-line opts The patch changes the order that the config file and command line are parsed so that command line has precedence. It also parses the -E option for every occurrence, otherwise the -E option is not cumulative. Signed-off-by: Jim Garlick Signed-off-by: Andreas Dilger --- diff --git a/e2fsck/unix.c b/e2fsck/unix.c index f3feb56..8e42f8c 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -820,7 +820,6 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) #ifdef HAVE_SIGNAL_H struct sigaction sa; #endif - char *extended_opts = 0; char *cp; int res; /* result of sscanf */ #ifdef CONFIG_JBD_DEBUG @@ -858,6 +857,12 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) else ctx->program_name = "e2fsck"; + cp = getenv("E2FSCK_CONFIG"); + if (cp != NULL) + config_fn[0] = cp; + profile_set_syntax_err_cb(syntax_err_report); + profile_init(config_fn, &ctx->profile); + phys_mem_kb = get_memory_size() / 1024; ctx->readahead_kb = ~0ULL; @@ -895,7 +900,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) ctx->options |= E2F_OPT_COMPRESS_DIRS; break; case 'E': - extended_opts = optarg; + parse_extended_opts(ctx, optarg); break; case 'p': case 'a': @@ -1067,8 +1072,6 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) argv[optind]); fatal_error(ctx, 0); } - if (extended_opts) - parse_extended_opts(ctx, extended_opts); /* Complain about mutually exclusive rebuilding activities */ if (getenv("E2FSCK_FIXES_ONLY")) @@ -1086,11 +1089,6 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) fatal_error(ctx, 0); } - if ((cp = getenv("E2FSCK_CONFIG")) != NULL) - config_fn[0] = cp; - profile_set_syntax_err_cb(syntax_err_report); - profile_init(config_fn, &ctx->profile); - profile_get_boolean(ctx->profile, "options", "report_time", 0, 0, &c); if (c)