]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tmpfiles: v/q/Q: Add env var to skip check for rootfs in subvolume
authorAdrian Vovk <adrianvovk@gmail.com>
Tue, 9 Feb 2021 21:20:32 +0000 (16:20 -0500)
committerLennart Poettering <lennart@poettering.net>
Wed, 10 Feb 2021 20:10:28 +0000 (21:10 +0100)
docs/ENVIRONMENT.md
src/tmpfiles/tmpfiles.c

index 7762713d44bd5176ba1e511c01cd5af2b6e3260f..82bb52b344c2f6c5fecdcf13d85bf926298fafd9 100644 (file)
@@ -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.
index 6bebf234bc60c9049f6782558f5cdcb450354d2a..63427ae6597590258e3cc56c6c84e250afa4bdb0 100644 (file)
@@ -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