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