803fb7
From cb18a928a4db39a0eac1ab1fda1c80fd4cc4e22b Mon Sep 17 00:00:00 2001
803fb7
From: Michael Olbrich <m.olbrich@pengutronix.de>
803fb7
Date: Wed, 18 Mar 2015 14:04:55 +0100
803fb7
Subject: [PATCH] missing.h: add more btrfs types and defines
803fb7
803fb7
(cherry picked from commit 8e8ba79229bb82248a568f5929143a66f4be45b7)
803fb7
---
803fb7
 src/shared/missing.h | 151 +++++++++++++++++++++++++++++++++++++++++++++++++++
803fb7
 1 file changed, 151 insertions(+)
803fb7
803fb7
diff --git a/src/shared/missing.h b/src/shared/missing.h
803fb7
index 6ef4dbdf4..4b36a9c93 100644
803fb7
--- a/src/shared/missing.h
803fb7
+++ b/src/shared/missing.h
803fb7
@@ -294,12 +294,59 @@ static inline int getrandom(void *buffer, size_t count, unsigned flags) {
803fb7
 #define BTRFS_UUID_SIZE 16
803fb7
 #endif
803fb7
 
803fb7
+#ifndef BTRFS_SUBVOL_RDONLY
803fb7
+#define BTRFS_SUBVOL_RDONLY (1ULL << 1)
803fb7
+#endif
803fb7
+
803fb7
+#ifndef BTRFS_SUBVOL_NAME_MAX
803fb7
+#define BTRFS_SUBVOL_NAME_MAX 4039
803fb7
+#endif
803fb7
+
803fb7
+#ifndef BTRFS_INO_LOOKUP_PATH_MAX
803fb7
+#define BTRFS_INO_LOOKUP_PATH_MAX 4080
803fb7
+#endif
803fb7
+
803fb7
+#ifndef BTRFS_SEARCH_ARGS_BUFSIZE
803fb7
+#define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key))
803fb7
+#endif
803fb7
+
803fb7
 #ifndef HAVE_LINUX_BTRFS_H
803fb7
 struct btrfs_ioctl_vol_args {
803fb7
         int64_t fd;
803fb7
         char name[BTRFS_PATH_NAME_MAX + 1];
803fb7
 };
803fb7
 
803fb7
+struct btrfs_qgroup_limit {
803fb7
+        __u64 flags;
803fb7
+        __u64 max_rfer;
803fb7
+        __u64 max_excl;
803fb7
+        __u64 rsv_rfer;
803fb7
+        __u64 rsv_excl;
803fb7
+};
803fb7
+
803fb7
+struct btrfs_qgroup_inherit {
803fb7
+        __u64 flags;
803fb7
+        __u64 num_qgroups;
803fb7
+        __u64 num_ref_copies;
803fb7
+        __u64 num_excl_copies;
803fb7
+        struct btrfs_qgroup_limit lim;
803fb7
+        __u64 qgroups[0];
803fb7
+};
803fb7
+
803fb7
+struct btrfs_ioctl_vol_args_v2 {
803fb7
+        __s64 fd;
803fb7
+        __u64 transid;
803fb7
+        __u64 flags;
803fb7
+        union {
803fb7
+                struct {
803fb7
+                        __u64 size;
803fb7
+                        struct btrfs_qgroup_inherit *qgroup_inherit;
803fb7
+                };
803fb7
+                __u64 unused[4];
803fb7
+        };
803fb7
+        char name[BTRFS_SUBVOL_NAME_MAX + 1];
803fb7
+};
803fb7
+
803fb7
 struct btrfs_ioctl_dev_info_args {
803fb7
         uint64_t devid;                         /* in/out */
803fb7
         uint8_t uuid[BTRFS_UUID_SIZE];          /* in/out */
803fb7
@@ -315,6 +362,68 @@ struct btrfs_ioctl_fs_info_args {
803fb7
         uint8_t fsid[BTRFS_FSID_SIZE];          /* out */
803fb7
         uint64_t reserved[124];                 /* pad to 1k */
803fb7
 };
803fb7
+
803fb7
+struct btrfs_ioctl_ino_lookup_args {
803fb7
+        __u64 treeid;
803fb7
+        __u64 objectid;
803fb7
+        char name[BTRFS_INO_LOOKUP_PATH_MAX];
803fb7
+};
803fb7
+
803fb7
+struct btrfs_ioctl_search_key {
803fb7
+        /* which root are we searching.  0 is the tree of tree roots */
803fb7
+        __u64 tree_id;
803fb7
+
803fb7
+        /* keys returned will be >= min and <= max */
803fb7
+        __u64 min_objectid;
803fb7
+        __u64 max_objectid;
803fb7
+
803fb7
+        /* keys returned will be >= min and <= max */
803fb7
+        __u64 min_offset;
803fb7
+        __u64 max_offset;
803fb7
+
803fb7
+        /* max and min transids to search for */
803fb7
+        __u64 min_transid;
803fb7
+        __u64 max_transid;
803fb7
+
803fb7
+        /* keys returned will be >= min and <= max */
803fb7
+        __u32 min_type;
803fb7
+        __u32 max_type;
803fb7
+
803fb7
+        /*
803fb7
+         * how many items did userland ask for, and how many are we
803fb7
+         * returning
803fb7
+         */
803fb7
+        __u32 nr_items;
803fb7
+
803fb7
+        /* align to 64 bits */
803fb7
+        __u32 unused;
803fb7
+
803fb7
+        /* some extra for later */
803fb7
+        __u64 unused1;
803fb7
+        __u64 unused2;
803fb7
+        __u64 unused3;
803fb7
+        __u64 unused4;
803fb7
+};
803fb7
+
803fb7
+struct btrfs_ioctl_search_header {
803fb7
+        __u64 transid;
803fb7
+        __u64 objectid;
803fb7
+        __u64 offset;
803fb7
+        __u32 type;
803fb7
+        __u32 len;
803fb7
+};
803fb7
+
803fb7
+
803fb7
+struct btrfs_ioctl_search_args {
803fb7
+        struct btrfs_ioctl_search_key key;
803fb7
+        char buf[BTRFS_SEARCH_ARGS_BUFSIZE];
803fb7
+};
803fb7
+
803fb7
+struct btrfs_ioctl_clone_range_args {
803fb7
+        __s64 src_fd;
803fb7
+        __u64 src_offset, src_length;
803fb7
+        __u64 dest_offset;
803fb7
+};
803fb7
 #endif
803fb7
 
803fb7
 #ifndef BTRFS_IOC_DEFRAG
803fb7
@@ -322,6 +431,48 @@ struct btrfs_ioctl_fs_info_args {
803fb7
                                  struct btrfs_ioctl_vol_args)
803fb7
 #endif
803fb7
 
803fb7
+#ifndef BTRFS_IOC_CLONE
803fb7
+#define BTRFS_IOC_CLONE _IOW(BTRFS_IOCTL_MAGIC, 9, int)
803fb7
+#endif
803fb7
+
803fb7
+#ifndef BTRFS_IOC_CLONE_RANGE
803fb7
+#define BTRFS_IOC_CLONE_RANGE _IOW(BTRFS_IOCTL_MAGIC, 13, \
803fb7
+                                 struct btrfs_ioctl_clone_range_args)
803fb7
+#endif
803fb7
+
803fb7
+#ifndef BTRFS_IOC_SUBVOL_CREATE
803fb7
+#define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \
803fb7
+                                 struct btrfs_ioctl_vol_args)
803fb7
+#endif
803fb7
+
803fb7
+#ifndef BTRFS_IOC_SNAP_DESTROY
803fb7
+#define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, \
803fb7
+                                 struct btrfs_ioctl_vol_args)
803fb7
+#endif
803fb7
+
803fb7
+#ifndef BTRFS_IOC_TREE_SEARCH
803fb7
+#define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \
803fb7
+                                 struct btrfs_ioctl_search_args)
803fb7
+#endif
803fb7
+
803fb7
+#ifndef BTRFS_IOC_INO_LOOKUP
803fb7
+#define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, \
803fb7
+                                 struct btrfs_ioctl_ino_lookup_args)
803fb7
+#endif
803fb7
+
803fb7
+#ifndef BTRFS_IOC_SNAP_CREATE_V2
803fb7
+#define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \
803fb7
+                                 struct btrfs_ioctl_vol_args_v2)
803fb7
+#endif
803fb7
+
803fb7
+#ifndef BTRFS_IOC_SUBVOL_GETFLAGS
803fb7
+#define BTRFS_IOC_SUBVOL_GETFLAGS _IOR(BTRFS_IOCTL_MAGIC, 25, __u64)
803fb7
+#endif
803fb7
+
803fb7
+#ifndef BTRFS_IOC_SUBVOL_SETFLAGS
803fb7
+#define BTRFS_IOC_SUBVOL_SETFLAGS _IOW(BTRFS_IOCTL_MAGIC, 26, __u64)
803fb7
+#endif
803fb7
+
803fb7
 #ifndef BTRFS_IOC_DEV_INFO
803fb7
 #define BTRFS_IOC_DEV_INFO _IOWR(BTRFS_IOCTL_MAGIC, 30, \
803fb7
                                  struct btrfs_ioctl_dev_info_args)