mirror of
https://github.com/systemd/systemd.git
synced 2025-01-09 01:18:19 +03:00
mkfs-util: Set sector size environment variables when invoking mkfs.ext4
Let's inform mkfs.ext4 about the sector size we're using.
This commit is contained in:
parent
579fbe5b78
commit
89dfac6b8f
@ -329,7 +329,7 @@ int make_filesystem(
|
||||
char * const *extra_mkfs_args) {
|
||||
|
||||
_cleanup_free_ char *mkfs = NULL, *mangled_label = NULL;
|
||||
_cleanup_strv_free_ char **argv = NULL;
|
||||
_cleanup_strv_free_ char **argv = NULL, **env = NULL;
|
||||
_cleanup_(rm_rf_physical_and_freep) char *protofile_tmpdir = NULL;
|
||||
_cleanup_(unlink_and_freep) char *protofile = NULL;
|
||||
char vol_id[CONST_MAX(SD_ID128_UUID_STRING_MAX, 8U + 1U)] = {};
|
||||
@ -432,6 +432,15 @@ int make_filesystem(
|
||||
if (quiet && strv_extend(&argv, "-q") < 0)
|
||||
return log_oom();
|
||||
|
||||
if (sector_size > 0)
|
||||
FOREACH_STRING(s, "MKE2FS_DEVICE_SECTSIZE", "MKE2FS_DEVICE_PHYS_SECTSIZE") {
|
||||
if (strv_extend(&env, s) < 0)
|
||||
return log_oom();
|
||||
|
||||
if (strv_extendf(&env, "%"PRIu64, sector_size) < 0)
|
||||
return log_oom();
|
||||
}
|
||||
|
||||
} else if (streq(fstype, "btrfs")) {
|
||||
argv = strv_new(mkfs,
|
||||
"-L", label,
|
||||
@ -594,6 +603,12 @@ int make_filesystem(
|
||||
if (r == 0) {
|
||||
/* Child */
|
||||
|
||||
STRV_FOREACH_PAIR(k, v, env)
|
||||
if (setenv(*k, *v, /* replace = */ true) < 0) {
|
||||
log_error_errno(r, "Failed to set %s=%s environment variable: %m", *k, *v);
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* mkfs.btrfs refuses to operate on block devices with mounted partitions, even if operating
|
||||
* on unformatted free space, so let's trick it and other mkfs tools into thinking no
|
||||
* partitions are mounted. See https://github.com/kdave/btrfs-progs/issues/640 for more
|
||||
|
Loading…
Reference in New Issue
Block a user