From ce22c05474b843cbdb474816af015f26cf8a99b8 Mon Sep 17 00:00:00 2001
From: Mike Yuan <me@yhndnzj.com>
Date: Fri, 26 Jan 2024 00:47:23 +0800
Subject: [PATCH] fstab-generator: drop assertions for mount opts
fstab_filter_options accepts NULL and (with later changes)
might even return NULL.
(cherry picked from commit c521ce42b43ad542a8e3c6e5e83ceb653ca6a71e)
src/fstab-generator/fstab-generator.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
@@ -476,17 +476,13 @@ static int mandatory_mount_drop_unapplicable_options(
assert(flags);
assert(where);
- assert(options);
assert(ret_options);
if (!(*flags & (MOUNT_NOAUTO|MOUNT_NOFAIL|MOUNT_AUTOMOUNT))) {
- _cleanup_free_ char *opts = NULL;
-
- opts = strdup(options);
- if (!opts)
- return -ENOMEM;
+ r = strdup_or_null(options, ret_options);
+ if (r < 0)
+ return r;
- *ret_options = TAKE_PTR(opts);
return 0;
}
@@ -522,7 +518,6 @@ static int add_mount(
assert(what);
assert(where);
- assert(opts);
assert(target_unit);
assert(source);
@@ -816,6 +811,9 @@ static int add_sysusr_sysroot_usr_bind_mount(const char *source) {
static MountPointFlags fstab_options_to_flags(const char *options, bool is_swap) {
MountPointFlags flags = 0;
+ if (isempty(options))
+ return 0;
+
if (fstab_test_option(options, "x-systemd.makefs\0"))
flags |= MOUNT_MAKEFS;
if (fstab_test_option(options, "x-systemd.growfs\0"))
@@ -891,7 +889,6 @@ static int parse_fstab_one(
assert(what_original);
assert(fstype);
- assert(options);
if (prefix_sysroot && !mount_in_initrd(where_original, options, accept_root))
return 0;
--
2.43.0