btrfs-progs: Add extra chunk item check to avoid btrfs-progs crash.
[platform/upstream/btrfs-progs.git] / ioctl.h
diff --git a/ioctl.h b/ioctl.h
index 2cf9c73..d550ca6 100644 (file)
--- a/ioctl.h
+++ b/ioctl.h
@@ -16,8 +16,9 @@
  * Boston, MA 021110-1307, USA.
  */
 
-#ifndef __IOCTL_
-#define __IOCTL_
+#ifndef __BTRFS_IOCTL_H__
+#define __BTRFS_IOCTL_H__
+
 #include <asm/types.h>
 #include <linux/ioctl.h>
 #include <time.h>
@@ -141,9 +142,11 @@ struct btrfs_ioctl_dev_replace_status_params {
 #define BTRFS_IOCTL_DEV_REPLACE_CMD_START                      0
 #define BTRFS_IOCTL_DEV_REPLACE_CMD_STATUS                     1
 #define BTRFS_IOCTL_DEV_REPLACE_CMD_CANCEL                     2
+#define BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_RESULT               -1
 #define BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR                        0
 #define BTRFS_IOCTL_DEV_REPLACE_RESULT_NOT_STARTED             1
 #define BTRFS_IOCTL_DEV_REPLACE_RESULT_ALREADY_STARTED         2
+#define BTRFS_IOCTL_DEV_REPLACE_RESULT_SCRUB_INPROGRESS                3
 struct btrfs_ioctl_dev_replace_args {
        __u64 cmd;      /* in */
        __u64 result;   /* out */
@@ -194,7 +197,9 @@ struct btrfs_balance_args {
 
        __u64 flags;
 
-       __u64 unused[8];
+       __u64 limit;
+
+       __u64 unused[7];
 } __attribute__ ((__packed__));
 
 struct btrfs_balance_progress {
@@ -275,6 +280,18 @@ struct btrfs_ioctl_search_args {
        char buf[BTRFS_SEARCH_ARGS_BUFSIZE];
 };
 
+/*
+ * Extended version of TREE_SEARCH ioctl that can return more than 4k of bytes.
+ * The allocated size of the buffer is set in buf_size.
+ */
+struct btrfs_ioctl_search_args_v2 {
+        struct btrfs_ioctl_search_key key; /* in/out - search parameters */
+        __u64 buf_size;                           /* in - size of buffer
+                                            * out - on EOVERFLOW: needed size
+                                            *       to store item */
+        __u64 buf[0];                      /* out - found items */
+};
+
 #define BTRFS_INO_LOOKUP_PATH_MAX 4080
 struct btrfs_ioctl_ino_lookup_args {
        __u64 treeid;
@@ -480,9 +497,9 @@ static inline char *btrfs_err_str(enum btrfs_err_code err_code)
                case BTRFS_ERROR_DEV_RAID10_MIN_NOT_MET:
                        return "unable to go below four devices on raid10";
                case BTRFS_ERROR_DEV_RAID5_MIN_NOT_MET:
-                       return "unable to go below three devices on raid5";
+                       return "unable to go below two devices on raid5";
                case BTRFS_ERROR_DEV_RAID6_MIN_NOT_MET:
-                       return "unable to go below four devices on raid6";
+                       return "unable to go below three devices on raid6";
                case BTRFS_ERROR_DEV_TGT_REPLACE:
                        return "unable to remove the dev_replace target dev";
                case BTRFS_ERROR_DEV_MISSING_NOT_FOUND:
@@ -506,6 +523,7 @@ static inline char *btrfs_err_str(enum btrfs_err_code err_code)
 #define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, \
                                   struct btrfs_ioctl_vol_args)
 
+/* With a @src_length of zero, the range from @src_offset->EOF is cloned! */
 struct btrfs_ioctl_clone_range_args {
        __s64 src_fd;
        __u64 src_offset, src_length;
@@ -537,9 +555,11 @@ struct btrfs_ioctl_clone_range_args {
                                struct btrfs_ioctl_defrag_range_args)
 #define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \
                                   struct btrfs_ioctl_search_args)
+#define BTRFS_IOC_TREE_SEARCH_V2 _IOWR(BTRFS_IOCTL_MAGIC, 17, \
+                                  struct btrfs_ioctl_search_args_v2)
 #define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, \
                                   struct btrfs_ioctl_ino_lookup_args)
-#define BTRFS_IOC_DEFAULT_SUBVOL _IOW(BTRFS_IOCTL_MAGIC, 19, u64)
+#define BTRFS_IOC_DEFAULT_SUBVOL _IOW(BTRFS_IOCTL_MAGIC, 19, __u64)
 #define BTRFS_IOC_SPACE_INFO _IOWR(BTRFS_IOCTL_MAGIC, 20, \
                                    struct btrfs_ioctl_space_args)
 #define BTRFS_IOC_START_SYNC _IOR(BTRFS_IOCTL_MAGIC, 24, __u64)