diff options
-rw-r--r-- | src/basic/fs-util.c | 6 | ||||
-rw-r--r-- | src/basic/fs-util.h | 3 |
2 files changed, 7 insertions, 2 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; diff --git a/src/basic/fs-util.h b/src/basic/fs-util.h index a19836d138..1023ab73ca 100644 --- a/src/basic/fs-util.h +++ b/src/basic/fs-util.h @@ -133,7 +133,8 @@ int open_mkdir_at(int dirfd, const char *path, int flags, mode_t mode); int openat_report_new(int dirfd, const char *pathname, int flags, mode_t mode, bool *ret_newly_created); typedef enum XOpenFlags { - XO_LABEL = 1 << 0, + XO_LABEL = 1 << 0, + XO_SUBVOLUME = 1 << 1, } XOpenFlags; int xopenat(int dir_fd, const char *path, int open_flags, XOpenFlags xopen_flags, mode_t mode); |