]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
homed: when creating home directory as btrfs inside luks volume, place subvol inside it 15376/head
authorLennart Poettering <lennart@poettering.net>
Thu, 9 Apr 2020 09:57:15 +0000 (11:57 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 9 Apr 2020 10:13:11 +0000 (12:13 +0200)
When managing a home directory as LUKS image we currently place a
directory at the top that contains the actual home directory (so that
the home directory of the user won't be cluttered by lost-found and
suchlike). On btrfs let's make that a subvol though. This is a good idea
so that possibly later on we can make use of this for automatic history
management.

Fixes: #15121
src/home/homework-luks.c

index de7535fc600e9386b2e272ec7fa39572c17f90dc..5eb67bc2b3bb36237d386073cc785a43ba77d41d 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "blkid-util.h"
 #include "blockdev-util.h"
+#include "btrfs-util.h"
 #include "chattr-util.h"
 #include "dm-util.h"
 #include "errno-util.h"
@@ -2037,8 +2038,10 @@ int home_create_luks(
                 goto fail;
         }
 
-        if (mkdir(subdir, 0700) < 0) {
-                r = log_error_errno(errno, "Failed to create user directory in mounted image file: %m");
+        /* Prefer using a btrfs subvolume if we can, fall back to directory otherwise */
+        r = btrfs_subvol_make_fallback(subdir, 0700);
+        if (r < 0) {
+                log_error_errno(r, "Failed to create user directory in mounted image file: %m");
                 goto fail;
         }