mirror of
https://github.com/systemd/systemd.git
synced 2025-02-13 01:57:42 +03:00
mkfs-util: Make sure we pass non option arguments last
POSIX specifies that getopt() stops parsing options when it encounters a non-option argument, so let's make sure we pass non-option arguments last.
This commit is contained in:
parent
362efc3804
commit
9b18dcf8c2
@ -424,8 +424,7 @@ int make_filesystem(
|
||||
"-m", "0",
|
||||
"-E", discard ? "discard,lazy_itable_init=1" : "nodiscard,lazy_itable_init=1",
|
||||
"-b", "4096",
|
||||
"-T", "default",
|
||||
node);
|
||||
"-T", "default");
|
||||
if (!argv)
|
||||
return log_oom();
|
||||
|
||||
@ -435,6 +434,9 @@ int make_filesystem(
|
||||
if (quiet && strv_extend(&argv, "-q") < 0)
|
||||
return log_oom();
|
||||
|
||||
if (strv_extend(&argv, node) < 0)
|
||||
return log_oom();
|
||||
|
||||
if (sector_size > 0) {
|
||||
if (strv_extend(&env, "MKE2FS_DEVICE_SECTSIZE") < 0)
|
||||
return log_oom();
|
||||
@ -446,8 +448,7 @@ int make_filesystem(
|
||||
} else if (streq(fstype, "btrfs")) {
|
||||
argv = strv_new(mkfs,
|
||||
"-L", label,
|
||||
"-U", vol_id,
|
||||
node);
|
||||
"-U", vol_id);
|
||||
if (!argv)
|
||||
return log_oom();
|
||||
|
||||
@ -469,14 +470,16 @@ int make_filesystem(
|
||||
if (sector_size > 0 && strv_extendf(&argv, "--sectorsize=%"PRIu64, MAX(sector_size, 4 * U64_KB)) < 0)
|
||||
return log_oom();
|
||||
|
||||
if (strv_extend(&argv, node) < 0)
|
||||
return log_oom();
|
||||
|
||||
} else if (streq(fstype, "f2fs")) {
|
||||
argv = strv_new(mkfs,
|
||||
"-g", /* "default options" */
|
||||
"-f", /* force override, without this it doesn't seem to want to write to an empty partition */
|
||||
"-l", label,
|
||||
"-U", vol_id,
|
||||
"-t", one_zero(discard),
|
||||
node);
|
||||
"-t", one_zero(discard));
|
||||
if (!argv)
|
||||
return log_oom();
|
||||
|
||||
@ -491,6 +494,9 @@ int make_filesystem(
|
||||
return log_oom();
|
||||
}
|
||||
|
||||
if (strv_extend(&argv, node) < 0)
|
||||
return log_oom();
|
||||
|
||||
} else if (streq(fstype, "xfs")) {
|
||||
const char *j;
|
||||
|
||||
@ -499,8 +505,7 @@ int make_filesystem(
|
||||
argv = strv_new(mkfs,
|
||||
"-L", label,
|
||||
"-m", j,
|
||||
"-m", "reflink=1",
|
||||
node);
|
||||
"-m", "reflink=1");
|
||||
if (!argv)
|
||||
return log_oom();
|
||||
|
||||
@ -539,13 +544,15 @@ int make_filesystem(
|
||||
if (quiet && strv_extend(&argv, "-q") < 0)
|
||||
return log_oom();
|
||||
|
||||
if (strv_extend(&argv, node) < 0)
|
||||
return log_oom();
|
||||
|
||||
} else if (streq(fstype, "vfat")) {
|
||||
|
||||
argv = strv_new(mkfs,
|
||||
"-i", vol_id,
|
||||
"-n", label,
|
||||
"-F", "32", /* yes, we force FAT32 here */
|
||||
node);
|
||||
"-F", "32"); /* yes, we force FAT32 here */
|
||||
if (!argv)
|
||||
return log_oom();
|
||||
|
||||
@ -557,6 +564,9 @@ int make_filesystem(
|
||||
return log_oom();
|
||||
}
|
||||
|
||||
if (strv_extend(&argv, node) < 0)
|
||||
return log_oom();
|
||||
|
||||
/* mkfs.vfat does not have a --quiet option so let's redirect stdout to /dev/null instead. */
|
||||
if (quiet)
|
||||
stdio_fds[1] = -EBADF;
|
||||
@ -577,7 +587,7 @@ int make_filesystem(
|
||||
} else if (streq(fstype, "squashfs")) {
|
||||
|
||||
argv = strv_new(mkfs,
|
||||
root, node,
|
||||
root, node, /* mksquashfs expects its arguments before the options. */
|
||||
"-noappend");
|
||||
if (!argv)
|
||||
return log_oom();
|
||||
@ -596,8 +606,7 @@ int make_filesystem(
|
||||
|
||||
} else if (streq(fstype, "erofs")) {
|
||||
argv = strv_new(mkfs,
|
||||
"-U", vol_id,
|
||||
node, root);
|
||||
"-U", vol_id);
|
||||
if (!argv)
|
||||
return log_oom();
|
||||
|
||||
@ -618,6 +627,9 @@ int make_filesystem(
|
||||
return log_oom();
|
||||
}
|
||||
|
||||
if (strv_extend_many(&argv, node, root) < 0)
|
||||
return log_oom();
|
||||
|
||||
} else {
|
||||
/* Generic fallback for all other file systems */
|
||||
argv = strv_new(mkfs, node);
|
||||
|
Loading…
x
Reference in New Issue
Block a user