]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
mke2fs: support multiple '-E' options
authorRalph Siemsen <ralph.siemsen@linaro.org>
Wed, 10 Sep 2025 13:51:46 +0000 (09:51 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 11 Nov 2025 19:37:16 +0000 (14:37 -0500)
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@linaro.org>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Message-ID: <20250910-mke2fs-small-fixes-v2-2-55c9842494e0@linaro.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
misc/mke2fs.8.in
misc/mke2fs.c

index 14bae326b446288e0799d9fe189583818392b520..99ecc64b6e0f9cfdfa8148eadb30e44d10d17e72 100644 (file)
@@ -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
index 3a8ff5b1c3d943dfccb9542b818ab69e8df9dd37..a54f83ad6e46b85c56b219ce9cb10d6b105a31c6 100644 (file)
@@ -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) {