[PATCH v2 2/4] mke2fs: support multiple '-E' options

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The '-E' option for specifying extended attributes can now be used
multiple times. The existing support for multiple attributes encoded
as comma-separated string is maintained for each '-E' option.

Prior to this change, if multiple '-E' options were specified, then
only the last one was used. Earlier ones were silently ignored.

Signed-off-by: Ralph Siemsen <ralph.siemsen@xxxxxxxxxx>
---
 misc/mke2fs.8.in |  4 +++-
 misc/mke2fs.c    | 16 ++++++++++++----
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/misc/mke2fs.8.in b/misc/mke2fs.8.in
index 14bae326..99ecc64b 100644
--- a/misc/mke2fs.8.in
+++ b/misc/mke2fs.8.in
@@ -268,7 +268,9 @@ Cause a kernel panic.
 .TP
 .BI \-E " extended-options"
 Set extended options for the file system.  Extended options are comma
-separated, and may take an argument using the equals ('=') sign.  The
+separated, and may take an argument using the equals ('=') sign.  Multiple
+.B \-E
+options may also be used. The
 .B \-E
 option used to be
 .B \-R
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 3a8ff5b1..a54f83ad 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -1653,7 +1653,7 @@ static void PRS(int argc, char *argv[])
 	int		default_csum_seed = 0;
 	errcode_t	retval;
 	char *		oldpath = getenv("PATH");
-	char *		extended_opts = 0;
+	struct str_list extended_opts;
 	char *		fs_type = 0;
 	char *		usage_types = 0;
 	/*
@@ -1751,6 +1751,13 @@ profile_error:
 			journal_size = -1;
 	}
 
+	retval = init_list(&extended_opts);
+	if (retval) {
+		com_err(program_name, retval, "%s",
+			_("in malloc for extended_opts"));
+		exit(1);
+	}
+
 	while ((c = getopt (argc, argv,
 		    "b:cd:e:g:i:jl:m:no:qr:s:t:vC:DE:FG:I:J:KL:M:N:O:R:ST:U:Vz:")) != EOF) {
 		switch (c) {
@@ -1796,7 +1803,7 @@ profile_error:
 				_("'-R' is deprecated, use '-E' instead"));
 			/* fallthrough */
 		case 'E':
-			extended_opts = optarg;
+			push_string(&extended_opts, optarg);
 			break;
 		case 'e':
 			if (strcmp(optarg, "continue") == 0)
@@ -2615,8 +2622,9 @@ profile_error:
 			free(tmp);
 	}
 
-	if (extended_opts)
-		parse_extended_opts(&fs_param, extended_opts);
+	/* Get options from commandline */
+	for (cpp = extended_opts.list; *cpp; cpp++)
+		parse_extended_opts(&fs_param, *cpp);
 
 	if (fs_param.s_rev_level == EXT2_GOOD_OLD_REV) {
 		if (fs_features) {

-- 
2.45.2.121.gc2b3f2b3cd





[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux