From a039df9c4a5a8977617786f6485da5386153fb22 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Tue, 10 May 2016 17:41:08 -0400 Subject: [PATCH] mke2fs: support multiple -O options Some users will get confused and try to specify multiple -O options. So teach mke2fs to treat "-O feature1 -O feature2" as "-O feature1,feature2". https://bugzilla.kernel.org/show_bug.cgi?id=117421 Signed-off-by: Theodore Ts'o --- misc/mke2fs.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 003473a..dd5bb35 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -1480,6 +1480,7 @@ static void PRS(int argc, char *argv[]) long sysval; int s_opt = -1, r_opt = -1; char *fs_features = 0; + int fs_features_size = 0; int use_bsize; char *newpath; int pathlen = sizeof(PATH_SET) + 1; @@ -1726,7 +1727,20 @@ profile_error: creator_os = optarg; break; case 'O': - fs_features = optarg; + retval = ext2fs_resize_mem(fs_features_size, + fs_features_size + 1 + strlen(optarg), + &fs_features); + if (retval) { + com_err(program_name, retval, + _("while allocating fs_feature string")); + exit(1); + } + if (fs_features_size) + strcat(fs_features, ","); + else + fs_features[0] = 0; + strcat(fs_features, optarg); + fs_features_size += 1 + strlen(optarg); break; case 'q': quiet = 1; @@ -1969,6 +1983,7 @@ profile_error: &fs_param.s_feature_compat); if (tmp) free(tmp); + (void) ext2fs_free_mem(&fs_features); /* * If the user specified features incompatible with the Hurd, complain */ -- 1.8.3.1