summaryrefslogtreecommitdiffstats
path: root/src/fstab-generator
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-07-14 13:29:06 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-07-15 15:48:05 +0200
commit99e3d4767932bce5febb45e8543162d729d17425 (patch)
treed9202cdc67661aefc7fd1a7aeeb439f8b8501958 /src/fstab-generator
parentfstab-generator: properly report the source of data (diff)
downloadsystemd-99e3d4767932bce5febb45e8543162d729d17425.tar.xz
systemd-99e3d4767932bce5febb45e8543162d729d17425.zip
fstab-generator: allow overriding path to /sysroot/etc/fstab too
This adds $SYSTEMD_SYSROOT_FSTAB analoguous to $SYSTEMD_FSTAB.
Diffstat (limited to 'src/fstab-generator')
-rw-r--r--src/fstab-generator/fstab-generator.c10
1 files changed, 9 insertions, 1 deletions
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");