From: Adrian Vovk Date: Tue, 9 Feb 2021 21:20:32 +0000 (-0500) Subject: tmpfiles: v/q/Q: Add env var to skip check for rootfs in subvolume X-Git-Tag: v248-rc1~163 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4368c60c395455d95a39694cd30214666c3e4d92;p=thirdparty%2Fsystemd.git tmpfiles: v/q/Q: Add env var to skip check for rootfs in subvolume --- diff --git a/docs/ENVIRONMENT.md b/docs/ENVIRONMENT.md index 7762713d44b..82bb52b344c 100644 --- a/docs/ENVIRONMENT.md +++ b/docs/ENVIRONMENT.md @@ -279,3 +279,9 @@ systemd-sysext: specify API file systems such as `/proc/` or `/sys/` here, or hierarchies that have them as submounts. In particular, do not specify the root directory `/` here. + +systemd-tmpfiles: + +* `SYSTEMD_TMPFILES_FORCE_SUBVOL` - if unset, v/q/Q lines will create subvolumes only if the + OS itself is installed into a subvolume. If set to 1 (or another true value), these lines will always create + subvolumes (if the backing filesystem supports them). If set to 0, these lines will always create directories. diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 6bebf234bc6..63427ae6597 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -27,6 +27,7 @@ #include "def.h" #include "dirent-util.h" #include "dissect-image.h" +#include "env-util.h" #include "escape.h" #include "fd-util.h" #include "fileio.h" @@ -1614,8 +1615,13 @@ static int create_directory_or_subvolume(const char *path, mode_t mode, bool sub return pfd; if (subvol) { - if (btrfs_is_subvol(empty_to_root(arg_root)) <= 0) - + r = getenv_bool("SYSTEMD_TMPFILES_FORCE_SUBVOL"); + if (r < 0) { + if (r != -ENXIO) /* env var is unset */ + log_warning_errno(r, "Cannot parse value of $SYSTEMD_TMPFILES_FORCE_SUBVOL, ignoring."); + r = btrfs_is_subvol(empty_to_root(arg_root)) > 0; + } + if (!r) /* Don't create a subvolume unless the root directory is * one, too. We do this under the assumption that if the * root directory is just a plain directory (i.e. very