diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-07-14 13:29:06 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-07-15 15:48:05 +0200 |
commit | 99e3d4767932bce5febb45e8543162d729d17425 (patch) | |
tree | d9202cdc67661aefc7fd1a7aeeb439f8b8501958 | |
parent | 7772c177b811e534bd4351e103a56e320e5b699a (diff) | |
download | systemd-99e3d4767932bce5febb45e8543162d729d17425.tar.gz |
fstab-generator: allow overriding path to /sysroot/etc/fstab too
This adds $SYSTEMD_SYSROOT_FSTAB analoguous to $SYSTEMD_FSTAB.
-rw-r--r-- | docs/ENVIRONMENT.md | 3 | ||||
-rw-r--r-- | man/systemd-fstab-generator.xml | 6 | ||||
-rw-r--r-- | src/fstab-generator/fstab-generator.c | 10 |
3 files changed, 15 insertions, 4 deletions
diff --git a/docs/ENVIRONMENT.md b/docs/ENVIRONMENT.md index 7caa951814..fc173289d9 100644 --- a/docs/ENVIRONMENT.md +++ b/docs/ENVIRONMENT.md @@ -51,6 +51,9 @@ All tools: * `$SYSTEMD_FSTAB` — if set, use this path instead of `/etc/fstab`. Only useful for debugging. +* `$SYSTEMD_SYSROOT_FSTAB` — if set, use this path instead of + `/sysroot/etc/fstab`. Only useful for debugging `systemd-fstab-generator`. + * `$SYSTEMD_CRYPTTAB` — if set, use this path instead of `/etc/crypttab`. Only useful for debugging. Currently only supported by `systemd-cryptsetup-generator`. diff --git a/man/systemd-fstab-generator.xml b/man/systemd-fstab-generator.xml index 21fa85da7d..21c3ea94a7 100644 --- a/man/systemd-fstab-generator.xml +++ b/man/systemd-fstab-generator.xml @@ -46,7 +46,7 @@ for more information about special <filename>/etc/fstab</filename> mount options this generator understands.</para> - <para>One special topic is handling of symbolic links. Historical init + <para>One special topic is handling of symbolic links. Historical init implementations supported symlinks in <filename>/etc/fstab</filename>. Because mount units will refuse mounts where the target is a symbolic link, this generator will resolve any symlinks as far as possible when processing @@ -251,8 +251,8 @@ <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>, <citerefentry><refentrytitle>systemd-cryptsetup-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>, <citerefentry><refentrytitle>systemd-gpt-auto-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>, - <citerefentry><refentrytitle>kernel-command-line</refentrytitle><manvolnum>7</manvolnum></citerefentry> + <citerefentry><refentrytitle>kernel-command-line</refentrytitle><manvolnum>7</manvolnum></citerefentry>, + <ulink url="https://systemd.io/ENVIRONMENT/">Known Environment Variables</ulink> </para> </refsect1> - </refentry> diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index b4bcc89132..84d7edb922 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -570,13 +570,21 @@ static int add_mount( return 0; } +static const char* sysroot_fstab_path(void) { + return getenv("SYSTEMD_SYSROOT_FSTAB") ?: "/sysroot/etc/fstab"; +} + static int parse_fstab(bool initrd) { _cleanup_endmntent_ FILE *f = NULL; const char *fstab; struct mntent *me; int r = 0; - fstab = initrd ? "/sysroot/etc/fstab" : fstab_path(); + if (initrd) + fstab = sysroot_fstab_path(); + else + fstab = fstab_path(); + log_debug("Parsing %s...", fstab); f = setmntent(fstab, "re"); |