[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20180615101613.98724-1-artem.blagodarenko@gmail.com>
Date: Fri, 15 Jun 2018 13:16:13 +0300
From: Artem Blagodarenko <artem.blagodarenko@...il.com>
To: linux-ext4@...r.kernel.org
Cc: adilger.kernel@...ger.ca, alexey.lyashkov@...il.com,
Andreas Dilger <andreas.dilger@...el.com>,
Jim Garlick <garlick@...l.gov>
Subject: [PATCH] misc: Allow "-E" and "-O" options multiple times
From: Andreas Dilger <andreas.dilger@...el.com>
Allow "-E" and "-O" options to be specified multiple times on the
command-line for mke2fs, tune2fs, and e2fsck, and parse them after
the config file options to more closely match user expectations.
Signed-off-by: Jim Garlick <garlick@...l.gov>
Signed-off-by: Andreas Dilger <andreas.dilger@...el.com>
Signed-off-by: Artem Blagodarenko <artem.blagodarenko@...il.com>
---
e2fsck/unix.c | 52 +++++++++++++++++++++++++---------------------------
1 file changed, 25 insertions(+), 27 deletions(-)
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index faf5af9a..0294f5bd 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -787,7 +787,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
@@ -821,6 +820,30 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
else
ctx->program_name = "e2fsck";
+ 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)
+ ctx->options |= E2F_OPT_TIME | E2F_OPT_TIME2;
+ profile_get_boolean(ctx->profile, "options", "report_verbose", 0, 0,
+ &c);
+ if (c)
+ verbose = 1;
+
+ profile_get_boolean(ctx->profile, "options", "no_optimize_extents",
+ 0, 0, &c);
+ if (c)
+ ctx->options |= E2F_OPT_NOOPT_EXTENTS;
+
+ profile_get_boolean(ctx->profile, "options", "inode_count_fullmap",
+ 0, 0, &c);
+ if (c)
+ ctx->options |= E2F_OPT_ICOUNT_FULLMAP;
+
phys_mem_kb = get_memory_size() / 1024;
ctx->readahead_kb = ~0ULL;
while ((c = getopt(argc, argv, "panyrcC:B:dE:fvtFVM:b:I:j:P:l:L:N:SsDkz:")) != EOF)
@@ -853,7 +876,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':
@@ -993,8 +1016,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"))
@@ -1012,29 +1033,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)
- ctx->options |= E2F_OPT_TIME | E2F_OPT_TIME2;
- profile_get_boolean(ctx->profile, "options", "report_verbose", 0, 0,
- &c);
- if (c)
- verbose = 1;
-
- profile_get_boolean(ctx->profile, "options", "no_optimize_extents",
- 0, 0, &c);
- if (c)
- ctx->options |= E2F_OPT_NOOPT_EXTENTS;
-
- profile_get_boolean(ctx->profile, "options", "inode_count_fullmap",
- 0, 0, &c);
- if (c)
- ctx->options |= E2F_OPT_ICOUNT_FULLMAP;
if (ctx->readahead_kb == ~0ULL) {
profile_get_integer(ctx->profile, "options",
--
2.14.3
Powered by blists - more mailing lists