chiark / gitweb /
tmpfiles: add new line type 'v' for creating btrfs subvolumes
[elogind.git] / src / shared / btrfs-util.c
index 84c81106fa2a1fdd0cc9438408ac1a637e1ddb2e..9b47330a6f261d5a27f755f49fe6dfe414bc73d4 100644 (file)
@@ -33,6 +33,8 @@
 #include "macro.h"
 #include "strv.h"
 #include "copy.h"
+#include "selinux-util.h"
+#include "smack-util.h"
 #include "btrfs-ctree.h"
 #include "btrfs-util.h"
 
@@ -184,6 +186,24 @@ int btrfs_subvol_make(const char *path) {
         return 0;
 }
 
+int btrfs_subvol_make_label(const char *path) {
+        int r;
+
+        assert(path);
+
+        r = mac_selinux_create_file_prepare(path, S_IFDIR);
+        if (r < 0)
+                return r;
+
+        r = btrfs_subvol_make(path);
+        mac_selinux_create_file_clear();
+
+        if (r < 0)
+                return r;
+
+        return mac_smack_fix(path, false, false);
+}
+
 int btrfs_subvol_remove(const char *path) {
         struct btrfs_ioctl_vol_args args = {};
         _cleanup_close_ int fd = -1;