From 8f88e57397bc6d4f897c4547770e67abd849498d Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 26 Jul 2023 03:17:01 +0900 Subject: [PATCH 1/8] fstab-generator: rename 'initrd' flag to 'prefix_sysroot' The name 'initrd' is confusing with 'in_initrd()'. --- src/fstab-generator/fstab-generator.c | 34 +++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index 91e914d8fe..f54fb17065 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -801,7 +801,7 @@ static MountPointFlags fstab_options_to_flags(const char *options, bool is_swap) return flags; } -static int canonicalize_mount_path(const char *path, const char *type, bool initrd, char **ret) { +static int canonicalize_mount_path(const char *path, const char *type, bool prefix_sysroot, char **ret) { _cleanup_free_ char *p = NULL; bool changed; int r; @@ -813,11 +813,11 @@ static int canonicalize_mount_path(const char *path, const char *type, bool init // FIXME: when chase() learns to chase non-existent paths, use this here and drop the prefixing with // /sysroot on error below. - r = chase(path, initrd ? "/sysroot" : NULL, CHASE_PREFIX_ROOT | CHASE_NONEXISTENT, &p, NULL); + r = chase(path, prefix_sysroot ? "/sysroot" : NULL, CHASE_PREFIX_ROOT | CHASE_NONEXISTENT, &p, NULL); if (r < 0) { log_debug_errno(r, "Failed to chase '%s', using as-is: %m", path); - if (initrd) + if (prefix_sysroot) p = path_join("/sysroot", path); else p = strdup(path); @@ -842,7 +842,7 @@ static int parse_fstab_one( const char *fstype, const char *options, int passno, - bool initrd, + bool prefix_sysroot, bool use_swap_enabled) { _cleanup_free_ char *what = NULL, *where = NULL; @@ -854,7 +854,7 @@ static int parse_fstab_one( assert(fstype); assert(options); - if (initrd && !mount_in_initrd(where_original, options)) + if (prefix_sysroot && !mount_in_initrd(where_original, options)) return 0; is_swap = streq_ptr(fstype, "swap"); @@ -891,16 +891,16 @@ static int parse_fstab_one( * /etc/fstab. So we canonicalize here. Note that we use CHASE_NONEXISTENT to handle the case * where a symlink refers to another mount target; this works assuming the sub-mountpoint * target is the final directory. */ - r = canonicalize_mount_path(where_original, "where", initrd, &where); + r = canonicalize_mount_path(where_original, "where", prefix_sysroot, &where); if (r < 0) return r; where_changed = r > 0; - if (initrd && fstab_is_bind(options, fstype)) { + if (prefix_sysroot && fstab_is_bind(options, fstype)) { /* When in initrd, the source of bind mount needs to be prepended with /sysroot as well. */ _cleanup_free_ char *p = NULL; - r = canonicalize_mount_path(what, "what", initrd, &p); + r = canonicalize_mount_path(what, "what", prefix_sysroot, &p); if (r < 0) return r; @@ -919,7 +919,7 @@ static int parse_fstab_one( bool is_sysroot_usr = in_initrd() && path_equal(where, "/sysroot/usr"); const char *target_unit = - initrd ? SPECIAL_INITRD_FS_TARGET : + prefix_sysroot ? SPECIAL_INITRD_FS_TARGET : is_sysroot ? SPECIAL_INITRD_ROOT_FS_TARGET : is_sysroot_usr ? SPECIAL_INITRD_USR_FS_TARGET : mount_is_network(fstype, options) ? SPECIAL_REMOTE_FS_TARGET : @@ -948,13 +948,13 @@ static int parse_fstab_one( return true; } -static int parse_fstab(bool initrd) { +static int parse_fstab(bool prefix_sysroot) { _cleanup_endmntent_ FILE *f = NULL; const char *fstab; struct mntent *me; int r, ret = 0; - if (initrd) + if (prefix_sysroot) fstab = sysroot_fstab_path(); else { fstab = fstab_path(); @@ -974,7 +974,7 @@ static int parse_fstab(bool initrd) { while ((me = getmntent(f))) { r = parse_fstab_one(fstab, me->mnt_fsname, me->mnt_dir, me->mnt_type, me->mnt_opts, me->mnt_passno, - initrd, /* use_swap_enabled = */ true); + prefix_sysroot, /* use_swap_enabled = */ true); if (r < 0 && ret >= 0) ret = r; if (arg_sysroot_check && r > 0) @@ -1289,7 +1289,7 @@ static int add_mounts_from_cmdline(void) { m->fstype, m->options, /* passno = */ 0, - /* initrd = */ false, + /* prefix_sysroot = */ false, /* use_swap_enabled = */ false); if (r < 0 && ret >= 0) ret = r; @@ -1323,7 +1323,7 @@ static int add_mounts_from_creds(void) { me->mnt_type, me->mnt_opts, me->mnt_passno, - /* initrd = */ false, + /* prefix_sysroot = */ false, /* use_swap_enabled = */ true); if (r < 0 && ret >= 0) ret = r; @@ -1517,7 +1517,7 @@ static int run_generator(void) { (void) determine_usr(); if (arg_sysroot_check) { - r = parse_fstab(/* initrd= */ true); + r = parse_fstab(/* prefix_sysroot = */ true); if (r == 0) log_debug("Nothing interesting found, not doing daemon-reload."); if (r > 0) @@ -1547,13 +1547,13 @@ static int run_generator(void) { /* Honour /etc/fstab only when that's enabled */ if (arg_fstab_enabled) { /* Parse the local /etc/fstab, possibly from the initrd */ - r = parse_fstab(/* initrd= */ false); + r = parse_fstab(/* prefix_sysroot = */ false); if (r < 0 && ret >= 0) ret = r; /* If running in the initrd also parse the /etc/fstab from the host */ if (in_initrd()) - r = parse_fstab(/* initrd= */ true); + r = parse_fstab(/* prefix_sysroot = */ true); else r = generator_enable_remount_fs_service(arg_dest); if (r < 0 && ret >= 0) From b93d9e06fc6abbd496ec3fb150a4e01c3b7ec72b Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 26 Jul 2023 09:31:54 +0900 Subject: [PATCH 2/8] fstab-generator: fix target of /sysroot/usr If /usr mount is picked from the main system's fstab file (prefix_sysroot is true, and the path is prefixed as /sysroot/usr), then previously it was installed in the wrong target unit. --- src/fstab-generator/fstab-generator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index f54fb17065..218c13ad0c 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -919,9 +919,9 @@ static int parse_fstab_one( bool is_sysroot_usr = in_initrd() && path_equal(where, "/sysroot/usr"); const char *target_unit = - prefix_sysroot ? SPECIAL_INITRD_FS_TARGET : is_sysroot ? SPECIAL_INITRD_ROOT_FS_TARGET : is_sysroot_usr ? SPECIAL_INITRD_USR_FS_TARGET : + prefix_sysroot ? SPECIAL_INITRD_FS_TARGET : mount_is_network(fstype, options) ? SPECIAL_REMOTE_FS_TARGET : SPECIAL_LOCAL_FS_TARGET; From 45c535ddb009d89f2740bdf3a5c88594962759fb Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 26 Jul 2023 04:17:27 +0900 Subject: [PATCH 3/8] fstab-generator: add rd.systemd.mount-extra= and friends Previously, mounts specified in systemd.mount-extra= are equally handled both in initrd and the main system. So, the mounts for the main system are also mounted in initrd. This introduces rd.systemd.mount-extra=, which specifies mounts in initrd. Then, mounts specified in systemd.mount-extra= are still mounted both in initrd and the main system, but prefixed with /sysroot/ when running in initrd. Fixes #28516. --- man/systemd-fstab-generator.xml | 11 +++++-- src/fstab-generator/fstab-generator.c | 31 +++++++++++++------ .../test-19-mounts-from-cmdline.input | 10 +++--- .../test-20-swap-from-cmdline.input | 8 ++--- 4 files changed, 39 insertions(+), 21 deletions(-) diff --git a/man/systemd-fstab-generator.xml b/man/systemd-fstab-generator.xml index 46f2390234..9173970bf7 100644 --- a/man/systemd-fstab-generator.xml +++ b/man/systemd-fstab-generator.xml @@ -242,11 +242,15 @@ systemd.mount-extra=WHAT:WHERE[:FSTYPE[:OPTIONS]] + rd.systemd.mount-extra=WHAT:WHERE[:FSTYPE[:OPTIONS]] Specifies the mount unit. Takes at least two and at most four fields separated with a colon (:). Each field is handled as the corresponding fstab field. This option can be - specified multiple times. + specified multiple times. rd.systemd.mount-extra= is honored only in the initrd, + while systemd.mount-extra= is honored by both the main system and the initrd. + In the initrd, the mount point (and also source path if the mount is bind mount) specified in + systemd.mount-extra= is prefixed with /sysroot/. Example: systemd.mount-extra=/dev/sda1:/mount-point:ext4:rw,noatime @@ -256,10 +260,13 @@ systemd.mount-extra=/dev/sda1:/mount-point:ext4:rw,noatime systemd.swap-extra=WHAT[:OPTIONS] + rd.systemd.swap-extra=WHAT[:OPTIONS] Specifies the swap unit. Takes the block device to be used as a swap device, and optionally - takes mount options followed by a colon (:). + takes mount options followed by a colon (:). This option can be specified + multiple times. rd.systemd.swap-extra= is honored only in the initrd, while + systemd.swap-extra= is honored by both the main system and the initrd. Example: systemd.swap=/dev/sda2:x-systemd.makefs diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index 218c13ad0c..4bb727c0bb 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -49,6 +49,7 @@ typedef enum MountPointFlags { } MountPointFlags; typedef struct Mount { + bool for_initrd; char *what; char *where; char *fstype; @@ -102,7 +103,13 @@ static void mount_array_free(Mount *mounts, size_t n) { free(mounts); } -static int mount_array_add_internal(char *in_what, char *in_where, const char *in_fstype, const char *in_options) { +static int mount_array_add_internal( + bool for_initrd, + char *in_what, + char *in_where, + const char *in_fstype, + const char *in_options) { + _cleanup_free_ char *what = NULL, *where = NULL, *fstype = NULL, *options = NULL; int r; @@ -135,6 +142,7 @@ static int mount_array_add_internal(char *in_what, char *in_where, const char *i return -ENOMEM; arg_mounts[arg_n_mounts++] = (Mount) { + .for_initrd = for_initrd, .what = TAKE_PTR(what), .where = TAKE_PTR(where), .fstype = TAKE_PTR(fstype), @@ -144,7 +152,7 @@ static int mount_array_add_internal(char *in_what, char *in_where, const char *i return 0; } -static int mount_array_add(const char *str) { +static int mount_array_add(bool for_initrd, const char *str) { _cleanup_free_ char *what = NULL, *where = NULL, *fstype = NULL, *options = NULL; int r; @@ -159,10 +167,10 @@ static int mount_array_add(const char *str) { if (!isempty(str)) return -EINVAL; - return mount_array_add_internal(TAKE_PTR(what), TAKE_PTR(where), fstype, options); + return mount_array_add_internal(for_initrd, TAKE_PTR(what), TAKE_PTR(where), fstype, options); } -static int mount_array_add_swap(const char *str) { +static int mount_array_add_swap(bool for_initrd, const char *str) { _cleanup_free_ char *what = NULL, *options = NULL; int r; @@ -177,7 +185,7 @@ static int mount_array_add_swap(const char *str) { if (!isempty(str)) return -EINVAL; - return mount_array_add_internal(TAKE_PTR(what), NULL, "swap", options); + return mount_array_add_internal(for_initrd, TAKE_PTR(what), NULL, "swap", options); } static int write_options(FILE *f, const char *options) { @@ -1282,6 +1290,9 @@ static int add_mounts_from_cmdline(void) { /* Handle each entries found in cmdline as a fstab entry. */ FOREACH_ARRAY(m, arg_mounts, arg_n_mounts) { + if (m->for_initrd && !in_initrd()) + continue; + r = parse_fstab_one( "/proc/cmdline", m->what, @@ -1289,7 +1300,7 @@ static int add_mounts_from_cmdline(void) { m->fstype, m->options, /* passno = */ 0, - /* prefix_sysroot = */ false, + /* prefix_sysroot = */ !m->for_initrd && in_initrd(), /* use_swap_enabled = */ false); if (r < 0 && ret >= 0) ret = r; @@ -1437,21 +1448,21 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat else arg_verity = r; - } else if (streq(key, "systemd.mount-extra")) { + } else if (STR_IN_SET(key, "systemd.mount-extra", "rd.systemd.mount-extra")) { if (proc_cmdline_value_missing(key, value)) return 0; - r = mount_array_add(value); + r = mount_array_add(startswith(key, "rd."), value); if (r < 0) log_warning("Failed to parse systemd.mount-extra= option, ignoring: %s", value); - } else if (streq(key, "systemd.swap-extra")) { + } else if (STR_IN_SET(key, "systemd.swap-extra", "rd.systemd.swap-extra")) { if (proc_cmdline_value_missing(key, value)) return 0; - r = mount_array_add_swap(value); + r = mount_array_add_swap(startswith(key, "rd."), value); if (r < 0) log_warning("Failed to parse systemd.swap-extra= option, ignoring: %s", value); } diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.input b/test/test-fstab-generator/test-19-mounts-from-cmdline.input index 4312d01e52..f2cc6fc075 100644 --- a/test/test-fstab-generator/test-19-mounts-from-cmdline.input +++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.input @@ -1,5 +1,5 @@ -systemd.mount-extra=/dev/sdx1:/sysroot:auto:defaults -systemd.mount-extra=/dev/sdx2:/hoge/without_options:auto -systemd.mount-extra=/dev/sdx3:/hoge/without_fstype -systemd.mount-extra=/dev/sdx4 -systemd.mount-extra=//foo\ufffebar:/hoge/with\x20space:cifs:rw,seclabel +rd.systemd.mount-extra=/dev/sdx1:/sysroot:auto:defaults +rd.systemd.mount-extra=/dev/sdx2:/hoge/without_options:auto +rd.systemd.mount-extra=/dev/sdx3:/hoge/without_fstype +rd.systemd.mount-extra=/dev/sdx4 +rd.systemd.mount-extra=//foo\ufffebar:/hoge/with\x20space:cifs:rw,seclabel diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.input b/test/test-fstab-generator/test-20-swap-from-cmdline.input index 953c09ff10..d92c5300e2 100644 --- a/test/test-fstab-generator/test-20-swap-from-cmdline.input +++ b/test/test-fstab-generator/test-20-swap-from-cmdline.input @@ -1,4 +1,4 @@ -systemd.mount-extra=/dev/sdy1:none:swap -systemd.mount-extra=/dev/sdy2:none:swap:x-systemd.makefs -systemd.swap-extra=/dev/sdy3:x-systemd.makefs,nofail -systemd.swap-extra=/dev/sdy4 +rd.systemd.mount-extra=/dev/sdy1:none:swap +rd.systemd.mount-extra=/dev/sdy2:none:swap:x-systemd.makefs +rd.systemd.swap-extra=/dev/sdy3:x-systemd.makefs,nofail +rd.systemd.swap-extra=/dev/sdy4 From dfd10549ac5aec1379ee83d633aadd1296450dac Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 26 Jul 2023 04:25:57 +0900 Subject: [PATCH 4/8] fstab-generator: read both credentials in initrd This makes the behavior consistent with the way we already do for fstab and command line options. In initrd, entries read from fstab.extra are mounted under /sysroot. --- src/fstab-generator/fstab-generator.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index 4bb727c0bb..e414529ed8 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -1309,14 +1309,16 @@ static int add_mounts_from_cmdline(void) { return ret; } -static int add_mounts_from_creds(void) { +static int add_mounts_from_creds(bool prefix_sysroot) { _cleanup_free_ void *b = NULL; struct mntent *me; int r, ret = 0; size_t bs; + assert(in_initrd() || !prefix_sysroot); + r = read_credential_with_decryption( - in_initrd() ? "fstab.extra.initrd" : "fstab.extra", + in_initrd() && !prefix_sysroot ? "fstab.extra.initrd" : "fstab.extra", &b, &bs); if (r <= 0) return r; @@ -1334,7 +1336,7 @@ static int add_mounts_from_creds(void) { me->mnt_type, me->mnt_opts, me->mnt_passno, - /* prefix_sysroot = */ false, + /* prefix_sysroot = */ prefix_sysroot, /* use_swap_enabled = */ true); if (r < 0 && ret >= 0) ret = r; @@ -1575,10 +1577,16 @@ static int run_generator(void) { if (r < 0 && ret >= 0) ret = r; - r = add_mounts_from_creds(); + r = add_mounts_from_creds(/* prefix_sysroot = */ false); if (r < 0 && ret >= 0) ret = r; + if (in_initrd()) { + r = add_mounts_from_creds(/* prefix_sysroot = */ true); + if (r < 0 && ret >= 0) + ret = r; + } + return ret; } From 22f5a825e40ad9c8eeae18b763676759d24bb434 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 26 Jul 2023 09:39:23 +0900 Subject: [PATCH 5/8] fstab-generator: add a flag to accept entry for "/" in initrd When both prefix_sysroot and accept_root is true, the entry for "/" will be accepted and converted to "/sysroot/". Why? If the entry is read from the main system's fstab, then we already mounted /sysroot/, hence it is not and should not re-add the .mount unit for /sysroot/. However, if we want to specify the root mount through the kernel command line or credential, without this change, we need to specify the same entry in the two options. E.g. === systemd.mount-extra=/dev/sda1:/:auto:defaults rd.systemd.mount-extra=/dev/sda1:/sysroot:auto:defaults === That's inconvenient. Of course, we can dedup that by using traditional options, but cannot when defined in credential. --- src/fstab-generator/fstab-generator.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index e414529ed8..103c55c7c7 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -314,9 +314,9 @@ static bool mount_is_network(const char *fstype, const char *options) { (fstype && fstype_is_network(fstype)); } -static bool mount_in_initrd(const char *where, const char *options) { +static bool mount_in_initrd(const char *where, const char *options, bool accept_root) { return fstab_test_option(options, "x-initrd.mount\0") || - (where && path_equal(where, "/usr")); + (where && PATH_IN_SET(where, "/usr", accept_root ? "/" : NULL)); } static int write_timeout( @@ -851,6 +851,7 @@ static int parse_fstab_one( const char *options, int passno, bool prefix_sysroot, + bool accept_root, /* This takes an effect only when prefix_sysroot is true. */ bool use_swap_enabled) { _cleanup_free_ char *what = NULL, *where = NULL; @@ -862,7 +863,7 @@ static int parse_fstab_one( assert(fstype); assert(options); - if (prefix_sysroot && !mount_in_initrd(where_original, options)) + if (prefix_sysroot && !mount_in_initrd(where_original, options, accept_root)) return 0; is_swap = streq_ptr(fstype, "swap"); @@ -982,7 +983,9 @@ static int parse_fstab(bool prefix_sysroot) { while ((me = getmntent(f))) { r = parse_fstab_one(fstab, me->mnt_fsname, me->mnt_dir, me->mnt_type, me->mnt_opts, me->mnt_passno, - prefix_sysroot, /* use_swap_enabled = */ true); + prefix_sysroot, + /* accept_root = */ false, + /* use_swap_enabled = */ true); if (r < 0 && ret >= 0) ret = r; if (arg_sysroot_check && r > 0) @@ -1301,6 +1304,7 @@ static int add_mounts_from_cmdline(void) { m->options, /* passno = */ 0, /* prefix_sysroot = */ !m->for_initrd && in_initrd(), + /* accept_root = */ true, /* use_swap_enabled = */ false); if (r < 0 && ret >= 0) ret = r; @@ -1337,6 +1341,7 @@ static int add_mounts_from_creds(bool prefix_sysroot) { me->mnt_opts, me->mnt_passno, /* prefix_sysroot = */ prefix_sysroot, + /* accept_root = */ true, /* use_swap_enabled = */ true); if (r < 0 && ret >= 0) ret = r; From 7f8c67c9965a5f70a6c1592db4f5339f4851a5de Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 26 Jul 2023 06:30:37 +0900 Subject: [PATCH 6/8] test-fstab-generator: extract core part as a function No functional change, preparation for later commits. --- test/test-fstab-generator.sh | 172 ++++++++++++++++++----------------- 1 file changed, 90 insertions(+), 82 deletions(-) diff --git a/test/test-fstab-generator.sh b/test/test-fstab-generator.sh index c390c785c9..47cfdfa797 100755 --- a/test/test-fstab-generator.sh +++ b/test/test-fstab-generator.sh @@ -1,10 +1,10 @@ #!/usr/bin/env bash # SPDX-License-Identifier: LGPL-2.1-or-later -set -e +set -eux shopt -s nullglob shopt -s globstar -if [[ -n "$1" ]]; then +if [[ -n "${1:-}" ]]; then generator=$1 elif [[ -x /usr/lib/systemd/system-generators/systemd-fstab-generator ]]; then generator=/usr/lib/systemd/system-generators/systemd-fstab-generator @@ -23,97 +23,105 @@ PATH=$PATH:/usr/sbin # of the host system. Override the measurement to avoid the issue. export SYSTEMD_FORCE_MEASURE=0 -for f in "$src"/test-*.input; do - echo "*** Running $f" +test_one() ( + local input out exp i j k dir fname expf - ( - out=$(mktemp --tmpdir --directory "test-fstab-generator.XXXXXXXXXX") - # shellcheck disable=SC2064 - trap "rm -rf '$out'" EXIT INT QUIT PIPE + input=${1?} - exp="${f%.input}.expected" - if [[ "${f##*/}" =~ swap ]] && systemd-detect-virt --container >/dev/null; then - exp="${exp}.container" - fi + : "*** Running $input" - if [[ "${f##*/}" =~ \.fstab\.input ]]; then - SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD=yes SYSTEMD_SYSFS_CHECK=no SYSTEMD_PROC_CMDLINE="fstab=yes root=fstab" SYSTEMD_FSTAB="$f" SYSTEMD_SYSROOT_FSTAB="/dev/null" $generator "$out" "$out" "$out" - else - SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD=yes SYSTEMD_SYSFS_CHECK=no SYSTEMD_PROC_CMDLINE="fstab=no $(cat "$f")" $generator "$out" "$out" "$out" - fi + out=$(mktemp --tmpdir --directory "test-fstab-generator.XXXXXXXXXX") + # shellcheck disable=SC2064 + trap "rm -rf '$out'" EXIT INT QUIT PIPE - # The option x-systemd.growfs creates symlink to system's systemd-growfs@.service in .mount.wants directory. - # The system that the test is currently running on may not have or may have outdated unit file. - # Let's replace the symlink with an empty file. - for i in "$out"/*/systemd-growfs@*.service; do - [[ -L "$i" ]] || continue - rm "$i" - touch "$i" + exp="${input%.input}.expected" + if [[ "${input##*/}" =~ swap ]] && systemd-detect-virt --container >/dev/null; then + exp="${exp}.container" + fi + + if [[ "${input##*/}" =~ \.fstab\.input ]]; then + SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD=yes SYSTEMD_SYSFS_CHECK=no SYSTEMD_PROC_CMDLINE="fstab=yes root=fstab" SYSTEMD_FSTAB="$input" SYSTEMD_SYSROOT_FSTAB="/dev/null" $generator "$out" "$out" "$out" + else + SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD=yes SYSTEMD_SYSFS_CHECK=no SYSTEMD_PROC_CMDLINE="fstab=no $(cat "$input")" $generator "$out" "$out" "$out" + fi + + # The option x-systemd.growfs creates symlink to system's systemd-growfs@.service in .mount.wants directory. + # The system that the test is currently running on may not have or may have outdated unit file. + # Let's replace the symlink with an empty file. + for i in "$out"/*/systemd-growfs@*.service; do + [[ -L "$i" ]] || continue + rm "$i" + touch "$i" + done + + # For split-usr system + for i in "$out"/systemd-*.service; do + sed -i -e 's:ExecStart=/lib/systemd/:ExecStart=/usr/lib/systemd/:' "$i" + done + + if [[ "${input##*/}" =~ \.fstab\.input ]]; then + for i in "$out"/*.{automount,mount,swap}; do + sed -i -e 's:SourcePath=.*$:SourcePath=/etc/fstab:' "$i" done + fi - # For split-usr system - for i in "$out"/systemd-*.service; do - sed -i -e 's:ExecStart=/lib/systemd/:ExecStart=/usr/lib/systemd/:' "$i" - done - - if [[ "${f##*/}" =~ \.fstab\.input ]]; then - for i in "$out"/*.{automount,mount,swap}; do - sed -i -e 's:SourcePath=.*$:SourcePath=/etc/fstab:' "$i" - done + # .deb packager seems to dislike files named with backslash. So, as a workaround, we store files + # without backslash in .expected. + for i in "$out"/**/*\\*.{mount,swap}; do + k="${i//\\/}" + if [[ "$i" != "$k" ]]; then + if [[ -f "$i" ]]; then + mv "$i" "$k" + elif [[ -L "$i" ]]; then + dest=$(readlink "$i") + rm "$i" + ln -s "${dest//\\/}" "$k" + fi fi + done - # .deb packager seems to dislike files named with backslash. So, as a workaround, we store files - # without backslash in .expected. - for i in "$out"/**/*\\*.{mount,swap}; do - k="${i//\\/}" - if [[ "$i" != "$k" ]]; then - if [[ -f "$i" ]]; then - mv "$i" "$k" - elif [[ -L "$i" ]]; then - dest=$(readlink "$i") - rm "$i" - ln -s "${dest//\\/}" "$k" + # We store empty files rather than dead symlinks, so that they don't get pruned when packaged up, so compare + # the list of filenames rather than their content + if ! diff -u <(find "$out" -printf '%P\n' | sort) <(find "$exp" -printf '%P\n' | sort); then + : "**** Unexpected output for $input" + return 1 + fi + + # Check the main units. + if ! diff -u "$out" "$exp"; then + : "**** Unexpected output for $input" + return 1 + fi + + # Also check drop-ins. + for i in "$out"/*; do + [[ -d "$i" ]] || continue + + dir="${i##*/}" + + for j in "$i"/*; do + fname="${j##*/}" + expf="$exp/$dir/$fname" + + if [[ -L "$j" && ! -e "$j" ]]; then + # For dead symlink, we store an empty file. + if [[ ! -e "$expf" || -n "$(cat "$expf")" ]]; then + : "**** Unexpected symlink $j created by $input" + return 1 fi + continue + fi + + if ! diff -u "$j" "$expf"; then + : "**** Unexpected output in $j for $input" + return 1 fi done + done - # We store empty files rather than dead symlinks, so that they don't get pruned when packaged up, so compare - # the list of filenames rather than their content - if ! diff -u <(find "$out" -printf '%P\n' | sort) <(find "$exp" -printf '%P\n' | sort); then - echo "**** Unexpected output for $f" - exit 1 - fi + return 0 +) - # Check the main units. - if ! diff -u "$out" "$exp"; then - echo "**** Unexpected output for $f" - exit 1 - fi - - # Also check drop-ins. - for i in "$out"/*; do - [[ -d "$i" ]] || continue - - dir="${i##*/}" - - for j in "$i"/*; do - fname="${j##*/}" - expf="$exp/$dir/$fname" - - if [[ -L "$j" && ! -e "$j" ]]; then - # For dead symlink, we store an empty file. - if [[ ! -e "$expf" || -n "$(cat "$expf")" ]]; then - echo "**** Unexpected symlink $j created by $f" - exit 1 - fi - continue - fi - - if ! diff -u "$j" "$expf"; then - echo "**** Unexpected output in $j for $f" - exit 1 - fi - done - done - ) || exit 1 +for f in "$src"/test-*.input; do + test_one "$f" done From aeded6b0b5a41f80d2f4663d8f023af2888b444d Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 26 Jul 2023 07:04:48 +0900 Subject: [PATCH 7/8] test-fstab-generator: also test with SYSTEMD_IN_INITRD=no --- test/test-fstab-generator.sh | 31 +++++++++++++------ .../sysroot-usr.mount | 1 + .../local-fs.target.requires/sysroot.mount | 1 + .../systemd-remount-fs.service | 0 .../sysroot-usr.mount | 11 +++++++ .../sysroot.mount | 13 ++++++++ .../foo.service.requires/mnt-requiredby.mount | 1 + .../foo.service.wants/mnt-wantedby.mount | 1 + ...der-systemd-growfs@mnt-growfs.service.conf | 4 +++ .../local-fs.target.requires/mnt-after.mount | 1 + .../mnt-automount1.automount | 1 + .../local-fs.target.requires/mnt-before.mount | 1 + .../local-fs.target.requires/mnt-growfs.mount | 1 + .../local-fs.target.requires/mnt-mkfs.mount | 1 + .../local-fs.target.requires/mnt-pcrfs.mount | 1 + .../mnt-reqmounts.mount | 1 + .../mnt-requires.mount | 1 + .../local-fs.target.requires/mnt-rwonly.mount | 1 + .../mnt-timeout.mount | 1 + .../local-fs.target.requires/sysroot.mount | 1 + .../mnt-automount2.automount | 1 + .../local-fs.target.wants/mnt-nofail.mount | 1 + .../systemd-remount-fs.service | 0 .../mnt-after.mount | 13 ++++++++ .../mnt-automount1.automount | 9 ++++++ .../mnt-automount1.mount | 12 +++++++ .../mnt-automount2.automount | 8 +++++ .../mnt-automount2.mount | 11 +++++++ .../mnt-before.mount | 13 ++++++++ .../mnt-growfs.mount | 12 +++++++ .../systemd-growfs@mnt-growfs.service | 0 .../mnt-mkfs.mount | 13 ++++++++ .../systemd-makefs@dev-sdx12.service | 1 + .../mnt-noauto.mount | 12 +++++++ .../mnt-nofail.mount | 11 +++++++ .../mnt-pcrfs.mount | 12 +++++++ .../mnt-reqmounts.mount | 13 ++++++++ .../mnt-requiredby.mount | 12 +++++++ .../mnt-requires.mount | 14 +++++++++ .../mnt-rwonly.mount | 13 ++++++++ .../mnt-timeout.mount | 13 ++++++++ .../mnt-wantedby.mount | 12 +++++++ .../sysroot.mount | 13 ++++++++ .../systemd-makefs@dev-sdx12.service | 18 +++++++++++ 44 files changed, 301 insertions(+), 10 deletions(-) create mode 120000 test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/local-fs.target.requires/sysroot-usr.mount create mode 120000 test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/local-fs.target.requires/sysroot.mount create mode 100644 test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/local-fs.target.wants/systemd-remount-fs.service create mode 100644 test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/sysroot-usr.mount create mode 100644 test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/sysroot.mount create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/foo.service.requires/mnt-requiredby.mount create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/foo.service.wants/mnt-wantedby.mount create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.d/50-order-systemd-growfs@mnt-growfs.service.conf create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-after.mount create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-automount1.automount create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-before.mount create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-growfs.mount create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-mkfs.mount create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-pcrfs.mount create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-reqmounts.mount create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-requires.mount create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-rwonly.mount create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-timeout.mount create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/sysroot.mount create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.wants/mnt-automount2.automount create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.wants/mnt-nofail.mount create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.wants/systemd-remount-fs.service create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-after.mount create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount1.automount create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount1.mount create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount2.automount create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount2.mount create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-before.mount create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-growfs.mount create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-growfs.mount.wants/systemd-growfs@mnt-growfs.service create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-mkfs.mount create mode 120000 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-mkfs.mount.requires/systemd-makefs@dev-sdx12.service create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-noauto.mount create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-nofail.mount create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-pcrfs.mount create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-reqmounts.mount create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-requiredby.mount create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-requires.mount create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-rwonly.mount create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-timeout.mount create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-wantedby.mount create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/sysroot.mount create mode 100644 test/test-fstab-generator/test-18-options.fstab.expected.sysroot/systemd-makefs@dev-sdx12.service diff --git a/test/test-fstab-generator.sh b/test/test-fstab-generator.sh index 47cfdfa797..0c949d46f4 100755 --- a/test/test-fstab-generator.sh +++ b/test/test-fstab-generator.sh @@ -24,11 +24,12 @@ PATH=$PATH:/usr/sbin export SYSTEMD_FORCE_MEASURE=0 test_one() ( - local input out exp i j k dir fname expf + local initrd input out exp i j k dir fname expf input=${1?} + initrd=${2?} - : "*** Running $input" + : "*** Running $input (initrd=$initrd)" out=$(mktemp --tmpdir --directory "test-fstab-generator.XXXXXXXXXX") # shellcheck disable=SC2064 @@ -38,17 +39,21 @@ test_one() ( if [[ "${input##*/}" =~ swap ]] && systemd-detect-virt --container >/dev/null; then exp="${exp}.container" fi + if [[ "$initrd" == no ]]; then + exp="${exp}.sysroot" + fi if [[ "${input##*/}" =~ \.fstab\.input ]]; then - SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD=yes SYSTEMD_SYSFS_CHECK=no SYSTEMD_PROC_CMDLINE="fstab=yes root=fstab" SYSTEMD_FSTAB="$input" SYSTEMD_SYSROOT_FSTAB="/dev/null" $generator "$out" "$out" "$out" + SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD="$initrd" SYSTEMD_SYSFS_CHECK=no SYSTEMD_PROC_CMDLINE="fstab=yes root=fstab" SYSTEMD_FSTAB="$input" SYSTEMD_SYSROOT_FSTAB="/dev/null" $generator "$out" "$out" "$out" else - SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD=yes SYSTEMD_SYSFS_CHECK=no SYSTEMD_PROC_CMDLINE="fstab=no $(cat "$input")" $generator "$out" "$out" "$out" + SYSTEMD_LOG_LEVEL=debug SYSTEMD_IN_INITRD="$initrd" SYSTEMD_SYSFS_CHECK=no SYSTEMD_PROC_CMDLINE="fstab=no $(cat "$input")" $generator "$out" "$out" "$out" fi # The option x-systemd.growfs creates symlink to system's systemd-growfs@.service in .mount.wants directory. + # Also, when $initrd is no, symlink to systemd-remount-fs.service is created. # The system that the test is currently running on may not have or may have outdated unit file. # Let's replace the symlink with an empty file. - for i in "$out"/*/systemd-growfs@*.service; do + for i in "$out"/*/systemd-growfs@*.service "$out"/local-fs.target.wants/systemd-remount-fs.service; do [[ -L "$i" ]] || continue rm "$i" touch "$i" @@ -80,16 +85,21 @@ test_one() ( fi done + # We do not store empty directory. + if [[ -z "$(ls -A "$out")" && ! -d "$exp" ]]; then + return 0 + fi + # We store empty files rather than dead symlinks, so that they don't get pruned when packaged up, so compare # the list of filenames rather than their content if ! diff -u <(find "$out" -printf '%P\n' | sort) <(find "$exp" -printf '%P\n' | sort); then - : "**** Unexpected output for $input" + : "**** Unexpected output for $input (initrd=$initrd)" return 1 fi # Check the main units. if ! diff -u "$out" "$exp"; then - : "**** Unexpected output for $input" + : "**** Unexpected output for $input (initrd=$initrd)" return 1 fi @@ -106,14 +116,14 @@ test_one() ( if [[ -L "$j" && ! -e "$j" ]]; then # For dead symlink, we store an empty file. if [[ ! -e "$expf" || -n "$(cat "$expf")" ]]; then - : "**** Unexpected symlink $j created by $input" + : "**** Unexpected symlink $j created by $input (initrd=$initrd)" return 1 fi continue fi if ! diff -u "$j" "$expf"; then - : "**** Unexpected output in $j for $input" + : "**** Unexpected output in $j for $input (initrd=$initrd)" return 1 fi done @@ -123,5 +133,6 @@ test_one() ( ) for f in "$src"/test-*.input; do - test_one "$f" + test_one "$f" yes + test_one "$f" no done diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/local-fs.target.requires/sysroot-usr.mount b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/local-fs.target.requires/sysroot-usr.mount new file mode 120000 index 0000000000..8bcbb16eae --- /dev/null +++ b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/local-fs.target.requires/sysroot-usr.mount @@ -0,0 +1 @@ +../sysroot-usr.mount \ No newline at end of file diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/local-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/local-fs.target.requires/sysroot.mount new file mode 120000 index 0000000000..0c969cdbd4 --- /dev/null +++ b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/local-fs.target.requires/sysroot.mount @@ -0,0 +1 @@ +../sysroot.mount \ No newline at end of file diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/local-fs.target.wants/systemd-remount-fs.service b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/local-fs.target.wants/systemd-remount-fs.service new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/sysroot-usr.mount b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/sysroot-usr.mount new file mode 100644 index 0000000000..effb6fc6d8 --- /dev/null +++ b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/sysroot-usr.mount @@ -0,0 +1,11 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Documentation=man:fstab(5) man:systemd-fstab-generator(8) +SourcePath=/etc/fstab +Before=local-fs.target +After=blockdev@dev-sdx2.target + +[Mount] +What=/dev/sdx2 +Where=/sysroot/usr diff --git a/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/sysroot.mount b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/sysroot.mount new file mode 100644 index 0000000000..56cecc05a0 --- /dev/null +++ b/test/test-fstab-generator/test-17-initrd-sysroot.fstab.expected.sysroot/sysroot.mount @@ -0,0 +1,13 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Documentation=man:fstab(5) man:systemd-fstab-generator(8) +SourcePath=/etc/fstab +Before=local-fs.target +Requires=systemd-fsck@dev-sdx1.service +After=systemd-fsck@dev-sdx1.service +After=blockdev@dev-sdx1.target + +[Mount] +What=/dev/sdx1 +Where=/sysroot diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/foo.service.requires/mnt-requiredby.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/foo.service.requires/mnt-requiredby.mount new file mode 120000 index 0000000000..6b012b09ef --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/foo.service.requires/mnt-requiredby.mount @@ -0,0 +1 @@ +../mnt-requiredby.mount \ No newline at end of file diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/foo.service.wants/mnt-wantedby.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/foo.service.wants/mnt-wantedby.mount new file mode 120000 index 0000000000..cdf21276b6 --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/foo.service.wants/mnt-wantedby.mount @@ -0,0 +1 @@ +../mnt-wantedby.mount \ No newline at end of file diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.d/50-order-systemd-growfs@mnt-growfs.service.conf b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.d/50-order-systemd-growfs@mnt-growfs.service.conf new file mode 100644 index 0000000000..ac770bcb51 --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.d/50-order-systemd-growfs@mnt-growfs.service.conf @@ -0,0 +1,4 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +After=systemd-growfs@mnt-growfs.service diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-after.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-after.mount new file mode 120000 index 0000000000..68364ef19c --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-after.mount @@ -0,0 +1 @@ +../mnt-after.mount \ No newline at end of file diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-automount1.automount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-automount1.automount new file mode 120000 index 0000000000..3638a8c90e --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-automount1.automount @@ -0,0 +1 @@ +../mnt-automount1.automount \ No newline at end of file diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-before.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-before.mount new file mode 120000 index 0000000000..3a50a40d5f --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-before.mount @@ -0,0 +1 @@ +../mnt-before.mount \ No newline at end of file diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-growfs.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-growfs.mount new file mode 120000 index 0000000000..cb05081e45 --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-growfs.mount @@ -0,0 +1 @@ +../mnt-growfs.mount \ No newline at end of file diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-mkfs.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-mkfs.mount new file mode 120000 index 0000000000..51f897e419 --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-mkfs.mount @@ -0,0 +1 @@ +../mnt-mkfs.mount \ No newline at end of file diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-pcrfs.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-pcrfs.mount new file mode 120000 index 0000000000..276dfc0731 --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-pcrfs.mount @@ -0,0 +1 @@ +../mnt-pcrfs.mount \ No newline at end of file diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-reqmounts.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-reqmounts.mount new file mode 120000 index 0000000000..7efce8da9a --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-reqmounts.mount @@ -0,0 +1 @@ +../mnt-reqmounts.mount \ No newline at end of file diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-requires.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-requires.mount new file mode 120000 index 0000000000..34a6aad26f --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-requires.mount @@ -0,0 +1 @@ +../mnt-requires.mount \ No newline at end of file diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-rwonly.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-rwonly.mount new file mode 120000 index 0000000000..d03abd2353 --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-rwonly.mount @@ -0,0 +1 @@ +../mnt-rwonly.mount \ No newline at end of file diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-timeout.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-timeout.mount new file mode 120000 index 0000000000..b0ec730825 --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/mnt-timeout.mount @@ -0,0 +1 @@ +../mnt-timeout.mount \ No newline at end of file diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/sysroot.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/sysroot.mount new file mode 120000 index 0000000000..0c969cdbd4 --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.requires/sysroot.mount @@ -0,0 +1 @@ +../sysroot.mount \ No newline at end of file diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.wants/mnt-automount2.automount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.wants/mnt-automount2.automount new file mode 120000 index 0000000000..a30481ec1f --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.wants/mnt-automount2.automount @@ -0,0 +1 @@ +../mnt-automount2.automount \ No newline at end of file diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.wants/mnt-nofail.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.wants/mnt-nofail.mount new file mode 120000 index 0000000000..b82bbad730 --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.wants/mnt-nofail.mount @@ -0,0 +1 @@ +../mnt-nofail.mount \ No newline at end of file diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.wants/systemd-remount-fs.service b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/local-fs.target.wants/systemd-remount-fs.service new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-after.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-after.mount new file mode 100644 index 0000000000..2aebb686a7 --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-after.mount @@ -0,0 +1,13 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Documentation=man:fstab(5) man:systemd-fstab-generator(8) +SourcePath=/etc/fstab +After=foo.service +Before=local-fs.target +After=blockdev@dev-sdx3.target + +[Mount] +What=/dev/sdx3 +Where=/mnt/after +Options=x-systemd.after=foo.service diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount1.automount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount1.automount new file mode 100644 index 0000000000..e376689b67 --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount1.automount @@ -0,0 +1,9 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +SourcePath=/etc/fstab +Documentation=man:fstab(5) man:systemd-fstab-generator(8) + +[Automount] +Where=/mnt/automount1 +TimeoutIdleSec=30min diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount1.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount1.mount new file mode 100644 index 0000000000..1413292c79 --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount1.mount @@ -0,0 +1,12 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Documentation=man:fstab(5) man:systemd-fstab-generator(8) +SourcePath=/etc/fstab +Before=local-fs.target +After=blockdev@dev-sdx9.target + +[Mount] +What=/dev/sdx9 +Where=/mnt/automount1 +Options=x-systemd.automount,x-systemd.idle-timeout=30m diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount2.automount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount2.automount new file mode 100644 index 0000000000..e05d3976ef --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount2.automount @@ -0,0 +1,8 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +SourcePath=/etc/fstab +Documentation=man:fstab(5) man:systemd-fstab-generator(8) + +[Automount] +Where=/mnt/automount2 diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount2.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount2.mount new file mode 100644 index 0000000000..1eba08c9f7 --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-automount2.mount @@ -0,0 +1,11 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Documentation=man:fstab(5) man:systemd-fstab-generator(8) +SourcePath=/etc/fstab +After=blockdev@dev-sdx10.target + +[Mount] +What=/dev/sdx10 +Where=/mnt/automount2 +Options=x-systemd.automount,nofail diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-before.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-before.mount new file mode 100644 index 0000000000..eea084b7b6 --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-before.mount @@ -0,0 +1,13 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Documentation=man:fstab(5) man:systemd-fstab-generator(8) +SourcePath=/etc/fstab +Before=foo.service +Before=local-fs.target +After=blockdev@dev-sdx4.target + +[Mount] +What=/dev/sdx4 +Where=/mnt/before +Options=x-systemd.before=foo.service diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-growfs.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-growfs.mount new file mode 100644 index 0000000000..bbe958c076 --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-growfs.mount @@ -0,0 +1,12 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Documentation=man:fstab(5) man:systemd-fstab-generator(8) +SourcePath=/etc/fstab +Before=local-fs.target +After=blockdev@dev-sdx13.target + +[Mount] +What=/dev/sdx13 +Where=/mnt/growfs +Options=x-systemd.growfs diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-growfs.mount.wants/systemd-growfs@mnt-growfs.service b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-growfs.mount.wants/systemd-growfs@mnt-growfs.service new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-mkfs.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-mkfs.mount new file mode 100644 index 0000000000..be4c8fa17f --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-mkfs.mount @@ -0,0 +1,13 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Documentation=man:fstab(5) man:systemd-fstab-generator(8) +SourcePath=/etc/fstab +Before=local-fs.target +After=blockdev@dev-sdx12.target + +[Mount] +What=/dev/sdx12 +Where=/mnt/mkfs +Type=ext4 +Options=x-systemd.makefs diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-mkfs.mount.requires/systemd-makefs@dev-sdx12.service b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-mkfs.mount.requires/systemd-makefs@dev-sdx12.service new file mode 120000 index 0000000000..fe80548a68 --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-mkfs.mount.requires/systemd-makefs@dev-sdx12.service @@ -0,0 +1 @@ +../systemd-makefs@dev-sdx12.service \ No newline at end of file diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-noauto.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-noauto.mount new file mode 100644 index 0000000000..4d52a6e698 --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-noauto.mount @@ -0,0 +1,12 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Documentation=man:fstab(5) man:systemd-fstab-generator(8) +SourcePath=/etc/fstab +Before=local-fs.target +After=blockdev@dev-sdx15.target + +[Mount] +What=/dev/sdx15 +Where=/mnt/noauto +Options=noauto diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-nofail.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-nofail.mount new file mode 100644 index 0000000000..3c20b652b0 --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-nofail.mount @@ -0,0 +1,11 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Documentation=man:fstab(5) man:systemd-fstab-generator(8) +SourcePath=/etc/fstab +After=blockdev@dev-sdx16.target + +[Mount] +What=/dev/sdx16 +Where=/mnt/nofail +Options=nofail diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-pcrfs.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-pcrfs.mount new file mode 100644 index 0000000000..2c070e695a --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-pcrfs.mount @@ -0,0 +1,12 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Documentation=man:fstab(5) man:systemd-fstab-generator(8) +SourcePath=/etc/fstab +Before=local-fs.target +After=blockdev@dev-sdx14.target + +[Mount] +What=/dev/sdx14 +Where=/mnt/pcrfs +Options=x-systemd.pcrfs diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-reqmounts.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-reqmounts.mount new file mode 100644 index 0000000000..c21ccd27ba --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-reqmounts.mount @@ -0,0 +1,13 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Documentation=man:fstab(5) man:systemd-fstab-generator(8) +SourcePath=/etc/fstab +RequiresMountsFor=/hoge +Before=local-fs.target +After=blockdev@dev-sdx6.target + +[Mount] +What=/dev/sdx6 +Where=/mnt/reqmounts +Options=x-systemd.requires-mounts-for=/hoge diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-requiredby.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-requiredby.mount new file mode 100644 index 0000000000..5edc4ddf22 --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-requiredby.mount @@ -0,0 +1,12 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Documentation=man:fstab(5) man:systemd-fstab-generator(8) +SourcePath=/etc/fstab +Before=local-fs.target +After=blockdev@dev-sdx8.target + +[Mount] +What=/dev/sdx8 +Where=/mnt/requiredby +Options=x-systemd.required-by=foo.service diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-requires.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-requires.mount new file mode 100644 index 0000000000..8386616593 --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-requires.mount @@ -0,0 +1,14 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Documentation=man:fstab(5) man:systemd-fstab-generator(8) +SourcePath=/etc/fstab +After=foo.service +Requires=foo.service +Before=local-fs.target +After=blockdev@dev-sdx5.target + +[Mount] +What=/dev/sdx5 +Where=/mnt/requires +Options=x-systemd.requires=foo.service diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-rwonly.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-rwonly.mount new file mode 100644 index 0000000000..8649734386 --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-rwonly.mount @@ -0,0 +1,13 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Documentation=man:fstab(5) man:systemd-fstab-generator(8) +SourcePath=/etc/fstab +Before=local-fs.target +After=blockdev@dev-sdx11.target + +[Mount] +What=/dev/sdx11 +Where=/mnt/rwonly +Options=x-systemd.rw-only +ReadWriteOnly=yes diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-timeout.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-timeout.mount new file mode 100644 index 0000000000..09d772a52b --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-timeout.mount @@ -0,0 +1,13 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Documentation=man:fstab(5) man:systemd-fstab-generator(8) +SourcePath=/etc/fstab +Before=local-fs.target +After=blockdev@dev-sdx2.target + +[Mount] +What=/dev/sdx2 +Where=/mnt/timeout +TimeoutSec=10min +Options=x-systemd.mount-timeout=10m diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-wantedby.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-wantedby.mount new file mode 100644 index 0000000000..e12df820d4 --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/mnt-wantedby.mount @@ -0,0 +1,12 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Documentation=man:fstab(5) man:systemd-fstab-generator(8) +SourcePath=/etc/fstab +Before=local-fs.target +After=blockdev@dev-sdx7.target + +[Mount] +What=/dev/sdx7 +Where=/mnt/wantedby +Options=x-systemd.wanted-by=foo.service diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/sysroot.mount b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/sysroot.mount new file mode 100644 index 0000000000..56cecc05a0 --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/sysroot.mount @@ -0,0 +1,13 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Documentation=man:fstab(5) man:systemd-fstab-generator(8) +SourcePath=/etc/fstab +Before=local-fs.target +Requires=systemd-fsck@dev-sdx1.service +After=systemd-fsck@dev-sdx1.service +After=blockdev@dev-sdx1.target + +[Mount] +What=/dev/sdx1 +Where=/sysroot diff --git a/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/systemd-makefs@dev-sdx12.service b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/systemd-makefs@dev-sdx12.service new file mode 100644 index 0000000000..4670c23e27 --- /dev/null +++ b/test/test-fstab-generator/test-18-options.fstab.expected.sysroot/systemd-makefs@dev-sdx12.service @@ -0,0 +1,18 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Description=Make File System on %f +Documentation=man:systemd-makefs@.service(8) + +DefaultDependencies=no +BindsTo=%i.device +After=%i.device +Before=systemd-fsck@%i.service mnt-mkfs.mount +Conflicts=shutdown.target +Before=shutdown.target + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/lib/systemd/systemd-makefs ext4 /dev/sdx12 +TimeoutSec=infinity From 03de154a1ecea1acef36a469157548b6a55921a5 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 26 Jul 2023 07:37:29 +0900 Subject: [PATCH 8/8] test-fstab-generator: add more tests for systemd.mount-extra= and friends --- .../foo-also_in_initrd.mount | 12 ++++++++++++ .../foo-not_in_initrd.mount | 11 +++++++++++ .../foo-also_in_initrd.mount | 1 + .../foo-not_in_initrd.mount | 1 + .../local-fs.target.requires/usr.mount | 1 + .../usr.mount | 11 +++++++++++ .../sysroot-foo-also_in_initrd.mount | 1 + .../initrd-fs.target.requires/sysroot-usr.mount | 1 + .../initrd-usr-fs.target.requires/sysusr-usr.mount | 1 + .../sysroot-foo-also_in_initrd.mount | 13 +++++++++++++ .../sysroot-usr.mount | 11 +++++++++++ .../sysusr-usr.mount | 11 +++++++++++ .../test-19-mounts-from-cmdline.input | 3 +++ .../dev-sdy5.swap | 10 ++++++++++ .../dev-sdy6.swap | 9 +++++++++ .../swap.target.requires/dev-sdy5.swap | 1 + .../swap.target.requires/dev-sdy6.swap | 1 + .../dev-sdy5.swap | 10 ++++++++++ .../swap.target.requires/dev-sdy5.swap | 1 + .../test-20-swap-from-cmdline.input | 2 ++ 20 files changed, 112 insertions(+) create mode 100644 test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/foo-also_in_initrd.mount create mode 100644 test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/foo-not_in_initrd.mount create mode 120000 test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/local-fs.target.requires/foo-also_in_initrd.mount create mode 120000 test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/local-fs.target.requires/foo-not_in_initrd.mount create mode 120000 test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/local-fs.target.requires/usr.mount create mode 100644 test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/usr.mount create mode 120000 test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-fs.target.requires/sysroot-foo-also_in_initrd.mount create mode 120000 test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-fs.target.requires/sysroot-usr.mount create mode 120000 test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-usr-fs.target.requires/sysusr-usr.mount create mode 100644 test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot-foo-also_in_initrd.mount create mode 100644 test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot-usr.mount create mode 100644 test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysusr-usr.mount create mode 100644 test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/dev-sdy5.swap create mode 100644 test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/dev-sdy6.swap create mode 120000 test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/swap.target.requires/dev-sdy5.swap create mode 120000 test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/swap.target.requires/dev-sdy6.swap create mode 100644 test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy5.swap create mode 120000 test/test-fstab-generator/test-20-swap-from-cmdline.expected/swap.target.requires/dev-sdy5.swap diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/foo-also_in_initrd.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/foo-also_in_initrd.mount new file mode 100644 index 0000000000..8cc17c5d92 --- /dev/null +++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/foo-also_in_initrd.mount @@ -0,0 +1,12 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Documentation=man:fstab(5) man:systemd-fstab-generator(8) +SourcePath=/proc/cmdline +Before=local-fs.target +After=blockdev@dev-sdx6.target + +[Mount] +What=/dev/sdx6 +Where=/foo/also_in_initrd +Options=x-initrd.mount diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/foo-not_in_initrd.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/foo-not_in_initrd.mount new file mode 100644 index 0000000000..8a5e28ebbf --- /dev/null +++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/foo-not_in_initrd.mount @@ -0,0 +1,11 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Documentation=man:fstab(5) man:systemd-fstab-generator(8) +SourcePath=/proc/cmdline +Before=local-fs.target +After=blockdev@dev-sdx7.target + +[Mount] +What=/dev/sdx7 +Where=/foo/not_in_initrd diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/local-fs.target.requires/foo-also_in_initrd.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/local-fs.target.requires/foo-also_in_initrd.mount new file mode 120000 index 0000000000..e4b2711fb9 --- /dev/null +++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/local-fs.target.requires/foo-also_in_initrd.mount @@ -0,0 +1 @@ +../foo-also_in_initrd.mount \ No newline at end of file diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/local-fs.target.requires/foo-not_in_initrd.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/local-fs.target.requires/foo-not_in_initrd.mount new file mode 120000 index 0000000000..85965fe86e --- /dev/null +++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/local-fs.target.requires/foo-not_in_initrd.mount @@ -0,0 +1 @@ +../foo-not_in_initrd.mount \ No newline at end of file diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/local-fs.target.requires/usr.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/local-fs.target.requires/usr.mount new file mode 120000 index 0000000000..a570574e46 --- /dev/null +++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/local-fs.target.requires/usr.mount @@ -0,0 +1 @@ +../usr.mount \ No newline at end of file diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/usr.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/usr.mount new file mode 100644 index 0000000000..ff01ec4fde --- /dev/null +++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected.sysroot/usr.mount @@ -0,0 +1,11 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Documentation=man:fstab(5) man:systemd-fstab-generator(8) +SourcePath=/proc/cmdline +Before=local-fs.target +After=blockdev@dev-sdx5.target + +[Mount] +What=/dev/sdx5 +Where=/usr diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-fs.target.requires/sysroot-foo-also_in_initrd.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-fs.target.requires/sysroot-foo-also_in_initrd.mount new file mode 120000 index 0000000000..314c46cccf --- /dev/null +++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-fs.target.requires/sysroot-foo-also_in_initrd.mount @@ -0,0 +1 @@ +../sysroot-foo-also_in_initrd.mount \ No newline at end of file diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-fs.target.requires/sysroot-usr.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-fs.target.requires/sysroot-usr.mount new file mode 120000 index 0000000000..8bcbb16eae --- /dev/null +++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-fs.target.requires/sysroot-usr.mount @@ -0,0 +1 @@ +../sysroot-usr.mount \ No newline at end of file diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-usr-fs.target.requires/sysusr-usr.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-usr-fs.target.requires/sysusr-usr.mount new file mode 120000 index 0000000000..8fb2e18647 --- /dev/null +++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/initrd-usr-fs.target.requires/sysusr-usr.mount @@ -0,0 +1 @@ +../sysusr-usr.mount \ No newline at end of file diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot-foo-also_in_initrd.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot-foo-also_in_initrd.mount new file mode 100644 index 0000000000..8baf1568b1 --- /dev/null +++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot-foo-also_in_initrd.mount @@ -0,0 +1,13 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Documentation=man:fstab(5) man:systemd-fstab-generator(8) +SourcePath=/proc/cmdline +Before=initrd-fs.target +After=blockdev@dev-sdx6.target + +[Mount] +What=/dev/sdx6 +# Canonicalized from /foo/also_in_initrd +Where=/sysroot/foo/also_in_initrd +Options=x-initrd.mount diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot-usr.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot-usr.mount new file mode 100644 index 0000000000..7f6d33cb3d --- /dev/null +++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysroot-usr.mount @@ -0,0 +1,11 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Documentation=man:fstab(5) man:systemd-fstab-generator(8) +SourcePath=/proc/cmdline +Before=initrd-fs.target + +[Mount] +What=/sysusr/usr +Where=/sysroot/usr +Options=bind diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysusr-usr.mount b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysusr-usr.mount new file mode 100644 index 0000000000..f1fedb3775 --- /dev/null +++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.expected/sysusr-usr.mount @@ -0,0 +1,11 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Documentation=man:fstab(5) man:systemd-fstab-generator(8) +SourcePath=/proc/cmdline +Before=initrd-usr-fs.target +After=blockdev@dev-sdx5.target + +[Mount] +What=/dev/sdx5 +Where=/sysusr/usr diff --git a/test/test-fstab-generator/test-19-mounts-from-cmdline.input b/test/test-fstab-generator/test-19-mounts-from-cmdline.input index f2cc6fc075..f16e494ecb 100644 --- a/test/test-fstab-generator/test-19-mounts-from-cmdline.input +++ b/test/test-fstab-generator/test-19-mounts-from-cmdline.input @@ -3,3 +3,6 @@ rd.systemd.mount-extra=/dev/sdx2:/hoge/without_options:auto rd.systemd.mount-extra=/dev/sdx3:/hoge/without_fstype rd.systemd.mount-extra=/dev/sdx4 rd.systemd.mount-extra=//foo\ufffebar:/hoge/with\x20space:cifs:rw,seclabel +systemd.mount-extra=/dev/sdx5:/usr:auto:defaults +systemd.mount-extra=/dev/sdx6:/foo/also_in_initrd:auto:x-initrd.mount +systemd.mount-extra=/dev/sdx7:/foo/not_in_initrd:auto:defaults diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/dev-sdy5.swap b/test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/dev-sdy5.swap new file mode 100644 index 0000000000..a9009ce3bc --- /dev/null +++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/dev-sdy5.swap @@ -0,0 +1,10 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Documentation=man:fstab(5) man:systemd-fstab-generator(8) +SourcePath=/proc/cmdline +After=blockdev@dev-sdy5.target + +[Swap] +What=/dev/sdy5 +Options=x-initrd.mount diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/dev-sdy6.swap b/test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/dev-sdy6.swap new file mode 100644 index 0000000000..383a8c3865 --- /dev/null +++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/dev-sdy6.swap @@ -0,0 +1,9 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Documentation=man:fstab(5) man:systemd-fstab-generator(8) +SourcePath=/proc/cmdline +After=blockdev@dev-sdy6.target + +[Swap] +What=/dev/sdy6 diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/swap.target.requires/dev-sdy5.swap b/test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/swap.target.requires/dev-sdy5.swap new file mode 120000 index 0000000000..04565dbf44 --- /dev/null +++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/swap.target.requires/dev-sdy5.swap @@ -0,0 +1 @@ +../dev-sdy5.swap \ No newline at end of file diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/swap.target.requires/dev-sdy6.swap b/test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/swap.target.requires/dev-sdy6.swap new file mode 120000 index 0000000000..3b36226323 --- /dev/null +++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected.sysroot/swap.target.requires/dev-sdy6.swap @@ -0,0 +1 @@ +../dev-sdy6.swap \ No newline at end of file diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy5.swap b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy5.swap new file mode 100644 index 0000000000..a9009ce3bc --- /dev/null +++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/dev-sdy5.swap @@ -0,0 +1,10 @@ +# Automatically generated by systemd-fstab-generator + +[Unit] +Documentation=man:fstab(5) man:systemd-fstab-generator(8) +SourcePath=/proc/cmdline +After=blockdev@dev-sdy5.target + +[Swap] +What=/dev/sdy5 +Options=x-initrd.mount diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.expected/swap.target.requires/dev-sdy5.swap b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/swap.target.requires/dev-sdy5.swap new file mode 120000 index 0000000000..04565dbf44 --- /dev/null +++ b/test/test-fstab-generator/test-20-swap-from-cmdline.expected/swap.target.requires/dev-sdy5.swap @@ -0,0 +1 @@ +../dev-sdy5.swap \ No newline at end of file diff --git a/test/test-fstab-generator/test-20-swap-from-cmdline.input b/test/test-fstab-generator/test-20-swap-from-cmdline.input index d92c5300e2..adde91e180 100644 --- a/test/test-fstab-generator/test-20-swap-from-cmdline.input +++ b/test/test-fstab-generator/test-20-swap-from-cmdline.input @@ -2,3 +2,5 @@ rd.systemd.mount-extra=/dev/sdy1:none:swap rd.systemd.mount-extra=/dev/sdy2:none:swap:x-systemd.makefs rd.systemd.swap-extra=/dev/sdy3:x-systemd.makefs,nofail rd.systemd.swap-extra=/dev/sdy4 +systemd.swap-extra=/dev/sdy5:x-initrd.mount +systemd.swap-extra=/dev/sdy6