diff options
Diffstat (limited to '')
-rw-r--r-- | docs/ENVIRONMENT.md | 5 | ||||
-rw-r--r-- | src/home/homework-luks.c | 25 | ||||
-rw-r--r-- | src/partition/makefs.c | 2 | ||||
-rw-r--r-- | src/partition/repart.c | 6 | ||||
-rw-r--r-- | src/shared/mkfs-util.c | 9 | ||||
-rw-r--r-- | src/shared/mkfs-util.h | 2 | ||||
-rw-r--r-- | src/test/test-loop-block.c | 8 |
7 files changed, 46 insertions, 11 deletions
diff --git a/docs/ENVIRONMENT.md b/docs/ENVIRONMENT.md index 604d1a6232..b4fa682cae 100644 --- a/docs/ENVIRONMENT.md +++ b/docs/ENVIRONMENT.md @@ -480,6 +480,11 @@ SYSTEMD_HOME_DEBUG_SUFFIX=foo \ options. There's one variable for each of the supported file systems for the LUKS home directory backend. +* `$SYSTEMD_HOME_MKFS_OPTIONS_BTRFS`, `$SYSTEMD_HOME_MKFS_OPTIONS_EXT4`, + `$SYSTEMD_HOME_MKFS_OPTIONS_XFS` – configure additional arguments to use for + `mkfs` when formatting LUKS home directories. There's one variable for each + of the supported file systems for the LUKS home directory backend. + `kernel-install`: * `$KERNEL_INSTALL_BYPASS` – If set to "1", execution of kernel-install is skipped diff --git a/src/home/homework-luks.c b/src/home/homework-luks.c index 4d04359740..2b803bc0bd 100644 --- a/src/home/homework-luks.c +++ b/src/home/homework-luks.c @@ -2110,6 +2110,25 @@ static int home_truncate( return !trunc; /* Return == 0 if we managed to truncate, > 0 if we managed to allocate */ } +static int mkfs_options_for_fstype(const char *fstype, char ***ret) { + _cleanup_(strv_freep) char **l = NULL; + const char *e; + char *n; + + assert(fstype); + + n = strjoina("SYSTEMD_HOME_MKFS_OPTIONS_", fstype); + e = getenv(ascii_strupper(n)); + if (e) { + l = strv_split(e, NULL); + if (!l) + return -ENOMEM; + } + + *ret = TAKE_PTR(l); + return 0; +} + int home_create_luks( UserRecord *h, HomeSetup *setup, @@ -2126,6 +2145,7 @@ int home_create_luks( const char *fstype, *ip; struct statfs sfs; int r; + _cleanup_strv_free_ char **extra_mkfs_options = NULL; assert(h); assert(h->storage < 0 || h->storage == USER_LUKS); @@ -2333,7 +2353,10 @@ int home_create_luks( log_info("Setting up LUKS device %s completed.", setup->dm_node); - r = make_filesystem(setup->dm_node, fstype, user_record_user_name_and_realm(h), NULL, fs_uuid, user_record_luks_discard(h)); + r = mkfs_options_for_fstype(fstype, &extra_mkfs_options); + if (r < 0) + return log_error_errno(r, "Failed to determine mkfs command line options for '%s': %m", fstype); + r = make_filesystem(setup->dm_node, fstype, user_record_user_name_and_realm(h), NULL, fs_uuid, user_record_luks_discard(h), extra_mkfs_options); if (r < 0) return r; diff --git a/src/partition/makefs.c b/src/partition/makefs.c index e8aa813bda..9ffdcb6db8 100644 --- a/src/partition/makefs.c +++ b/src/partition/makefs.c @@ -65,7 +65,7 @@ static int run(int argc, char *argv[]) { if (r < 0) return log_error_errno(r, "Failed to generate UUID for file system: %m"); - return make_filesystem(device, fstype, basename(device), NULL, uuid, true); + return make_filesystem(device, fstype, basename(device), NULL, uuid, true, NULL); } DEFINE_MAIN_FUNCTION(run); diff --git a/src/partition/repart.c b/src/partition/repart.c index 64a3637369..010d775c0b 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -4032,7 +4032,7 @@ static int context_mkfs(Context *context) { } r = make_filesystem(partition_target_path(t), p->format, strempty(p->new_label), root, - p->fs_uuid, arg_discard); + p->fs_uuid, arg_discard, NULL); if (r < 0) return r; @@ -5362,7 +5362,7 @@ static int context_minimize(Context *context) { return r; } - r = make_filesystem(d ? d->node : temp, p->format, strempty(p->new_label), root, fs_uuid, arg_discard); + r = make_filesystem(d ? d->node : temp, p->format, strempty(p->new_label), root, fs_uuid, arg_discard, NULL); if (r < 0) return r; @@ -5415,7 +5415,7 @@ static int context_minimize(Context *context) { if (r < 0 && r != -ENOENT && !ERRNO_IS_PRIVILEGE(r)) return log_error_errno(r, "Failed to make loopback device of %s: %m", temp); - r = make_filesystem(d ? d->node : temp, p->format, strempty(p->new_label), root, p->fs_uuid, arg_discard); + r = make_filesystem(d ? d->node : temp, p->format, strempty(p->new_label), root, p->fs_uuid, arg_discard, NULL); if (r < 0) return r; diff --git a/src/shared/mkfs-util.c b/src/shared/mkfs-util.c index 97c3ff8da2..59d851ba0f 100644 --- a/src/shared/mkfs-util.c +++ b/src/shared/mkfs-util.c @@ -302,7 +302,8 @@ int make_filesystem( const char *label, const char *root, sd_id128_t uuid, - bool discard) { + bool discard, + char * const *extra_mkfs_args) { _cleanup_free_ char *mkfs = NULL, *mangled_label = NULL; _cleanup_strv_free_ char **argv = NULL; @@ -522,6 +523,12 @@ int make_filesystem( if (!argv) return log_oom(); + if (extra_mkfs_args) { + r = strv_extend_strv(&argv, extra_mkfs_args, false); + if (r < 0) + return log_oom(); + } + if (root && stat(root, &st) < 0) return log_error_errno(errno, "Failed to stat %s: %m", root); diff --git a/src/shared/mkfs-util.h b/src/shared/mkfs-util.h index 62061c6647..7f72016cca 100644 --- a/src/shared/mkfs-util.h +++ b/src/shared/mkfs-util.h @@ -11,4 +11,4 @@ int mkfs_exists(const char *fstype); int mkfs_supports_root_option(const char *fstype); -int make_filesystem(const char *node, const char *fstype, const char *label, const char *root, sd_id128_t uuid, bool discard); +int make_filesystem(const char *node, const char *fstype, const char *label, const char *root, sd_id128_t uuid, bool discard, char * const *extra_mkfs_args); diff --git a/src/test/test-loop-block.c b/src/test/test-loop-block.c index b06ab0d172..6e15e1accb 100644 --- a/src/test/test-loop-block.c +++ b/src/test/test-loop-block.c @@ -245,16 +245,16 @@ static int run(int argc, char *argv[]) { assert_se(r >= 0); assert_se(sd_id128_randomize(&id) >= 0); - assert_se(make_filesystem(dissected->partitions[PARTITION_ESP].node, "vfat", "EFI", NULL, id, true) >= 0); + assert_se(make_filesystem(dissected->partitions[PARTITION_ESP].node, "vfat", "EFI", NULL, id, true, NULL) >= 0); assert_se(sd_id128_randomize(&id) >= 0); - assert_se(make_filesystem(dissected->partitions[PARTITION_XBOOTLDR].node, "vfat", "xbootldr", NULL, id, true) >= 0); + assert_se(make_filesystem(dissected->partitions[PARTITION_XBOOTLDR].node, "vfat", "xbootldr", NULL, id, true, NULL) >= 0); assert_se(sd_id128_randomize(&id) >= 0); - assert_se(make_filesystem(dissected->partitions[PARTITION_ROOT].node, "ext4", "root", NULL, id, true) >= 0); + assert_se(make_filesystem(dissected->partitions[PARTITION_ROOT].node, "ext4", "root", NULL, id, true, NULL) >= 0); assert_se(sd_id128_randomize(&id) >= 0); - assert_se(make_filesystem(dissected->partitions[PARTITION_HOME].node, "ext4", "home", NULL, id, true) >= 0); + assert_se(make_filesystem(dissected->partitions[PARTITION_HOME].node, "ext4", "home", NULL, id, true, NULL) >= 0); dissected = dissected_image_unref(dissected); |