diff options
author | Lennart Poettering <lennart@poettering.net> | 2021-11-13 08:03:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-13 08:03:55 +0100 |
commit | b1beb004068dbd76377a545bc1bc5edd208f7c68 (patch) | |
tree | cc753d2b02bf83a480997c85af74a493ab978559 /src/home/homework-mount.c | |
parent | test: Create convenience macros to declare tests (diff) | |
parent | doc: document the new luksExtraMountOptions concept (diff) | |
download | systemd-b1beb004068dbd76377a545bc1bc5edd208f7c68.tar.xz systemd-b1beb004068dbd76377a545bc1bc5edd208f7c68.zip |
Merge pull request #21331 from poettering/luks-extra-mount-options
homed: allow per-user additional LUKS mount options
Diffstat (limited to 'src/home/homework-mount.c')
-rw-r--r-- | src/home/homework-mount.c | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/src/home/homework-mount.c b/src/home/homework-mount.c index 234b965dc8..1e63dbed41 100644 --- a/src/home/homework-mount.c +++ b/src/home/homework-mount.c @@ -40,28 +40,35 @@ static const char *mount_options_for_fstype(const char *fstype) { return NULL; } -int home_mount_node(const char *node, const char *fstype, bool discard, unsigned long flags) { +int home_mount_node( + const char *node, + const char *fstype, + bool discard, + unsigned long flags, + const char *extra_mount_options) { + _cleanup_free_ char *joined = NULL; - const char *options, *discard_option; + const char *default_options; int r; assert(node); assert(fstype); - options = mount_options_for_fstype(fstype); + default_options = mount_options_for_fstype(fstype); + if (default_options) { + if (!strextend_with_separator(&joined, ",", default_options)) + return log_oom(); + } - discard_option = discard ? "discard" : "nodiscard"; + if (!strextend_with_separator(&joined, ",", discard ? "discard" : "nodiscard")) + return log_oom(); - if (options) { - joined = strjoin(options, ",", discard_option); - if (!joined) + if (extra_mount_options) { + if (!strextend_with_separator(&joined, ",", extra_mount_options)) return log_oom(); + } - options = joined; - } else - options = discard_option; - - r = mount_nofollow_verbose(LOG_ERR, node, HOME_RUNTIME_WORK_DIR, fstype, flags|MS_RELATIME, strempty(options)); + r = mount_nofollow_verbose(LOG_ERR, node, HOME_RUNTIME_WORK_DIR, fstype, flags|MS_RELATIME, joined); if (r < 0) return r; @@ -85,7 +92,13 @@ int home_unshare_and_mkdir(void) { return 0; } -int home_unshare_and_mount(const char *node, const char *fstype, bool discard, unsigned long flags) { +int home_unshare_and_mount( + const char *node, + const char *fstype, + bool discard, + unsigned long flags, + const char *extra_mount_options) { + int r; assert(node); @@ -95,7 +108,7 @@ int home_unshare_and_mount(const char *node, const char *fstype, bool discard, u if (r < 0) return r; - r = home_mount_node(node, fstype, discard, flags); + r = home_mount_node(node, fstype, discard, flags, extra_mount_options); if (r < 0) return r; |