summaryrefslogtreecommitdiffstats
path: root/src/basic/fs-util.c
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2023-08-14 15:32:22 +0200
committerDaan De Meyer <daan.j.demeyer@gmail.com>2023-08-14 18:46:08 +0200
commitbc6a6130ace354ac774cbc8e55dad2eec4a02643 (patch)
tree0f29d23fef348b31a74dde371fe490b6f7e16f82 /src/basic/fs-util.c
parentbtrfs-util: Move subvolume creation to basic/btrfs.h (diff)
downloadsystemd-bc6a6130ace354ac774cbc8e55dad2eec4a02643.tar.xz
systemd-bc6a6130ace354ac774cbc8e55dad2eec4a02643.zip
fs-util: Add XO_SUBVOLUME flag for xopenat()
When specified, xopenat() will try to create a btrfs subvolume and fall back to creating a regular directory.
Diffstat (limited to 'src/basic/fs-util.c')
-rw-r--r--src/basic/fs-util.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c
index 804440ef2a..a9336f1a67 100644
--- a/src/basic/fs-util.c
+++ b/src/basic/fs-util.c
@@ -9,6 +9,7 @@
#include <unistd.h>
#include "alloc-util.h"
+#include "btrfs.h"
#include "dirent-util.h"
#include "fd-util.h"
#include "fileio.h"
@@ -1110,7 +1111,10 @@ int xopenat(int dir_fd, const char *path, int open_flags, XOpenFlags xopen_flags
}
if (FLAGS_SET(open_flags, O_DIRECTORY|O_CREAT)) {
- r = RET_NERRNO(mkdirat(dir_fd, path, mode));
+ if (FLAGS_SET(xopen_flags, XO_SUBVOLUME))
+ r = btrfs_subvol_make_fallback(dir_fd, path, mode);
+ else
+ r = RET_NERRNO(mkdirat(dir_fd, path, mode));
if (r == -EEXIST) {
if (FLAGS_SET(open_flags, O_EXCL))
return -EEXIST;