]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fstab-generator: allow overriding path to /sysroot/etc/fstab too
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 14 Jul 2022 11:29:06 +0000 (13:29 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 15 Jul 2022 13:48:05 +0000 (15:48 +0200)
This adds $SYSTEMD_SYSROOT_FSTAB analoguous to $SYSTEMD_FSTAB.

docs/ENVIRONMENT.md
man/systemd-fstab-generator.xml
src/fstab-generator/fstab-generator.c

index 7caa95181459ff956be3c5830683bd4274c21356..fc173289d96aaf3bd6b77470ed0c44db9da4e90c 100644 (file)
@@ -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`.
index 21fa85da7d847af2d22a6ee2947bd22464c4a6f1..21c3ea94a70b4219c130aa0a132135f46695d773 100644 (file)
@@ -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
       <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>
index b4bcc891327743134b68be4ae04165415bced8e2..84d7edb92236c1847797fdd0daa59a2af59322f5 100644 (file)
@@ -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");