blob: a162bb0867cabe1c73a1af49d1d9e3802f05a0b3 [file] [log] [blame]
Ben Cheng655a7c02013-10-16 16:09:24 -07001/****************************************************************************
2 ****************************************************************************
3 ***
4 *** This header was automatically generated from a Linux kernel header
5 *** of the same name, to make information necessary for userspace to
6 *** call into the kernel available to libc. It contains only constants,
7 *** structures, and macros generated from the original header, and thus,
8 *** contains no copyrightable information.
9 ***
10 *** To edit the content of this header, modify the corresponding
11 *** source file (e.g. under external/kernel-headers/original/) then
12 *** run bionic/libc/kernel/tools/update_all.py
13 ***
14 *** Any manual change here will be lost the next time this script will
15 *** be run. You've been warned!
16 ***
17 ****************************************************************************
18 ****************************************************************************/
19#ifndef _UAPI_LINUX_BTRFS_H
20#define _UAPI_LINUX_BTRFS_H
21#include <linux/types.h>
22#include <linux/ioctl.h>
Ben Cheng655a7c02013-10-16 16:09:24 -070023#define BTRFS_IOCTL_MAGIC 0x94
24#define BTRFS_VOL_NAME_MAX 255
Christopher Ferris106b3a82016-08-24 12:15:38 -070025#define BTRFS_LABEL_SIZE 256
Ben Cheng655a7c02013-10-16 16:09:24 -070026#define BTRFS_PATH_NAME_MAX 4087
Christopher Ferris106b3a82016-08-24 12:15:38 -070027struct btrfs_ioctl_vol_args {
Tao Baod7db5942015-01-28 10:07:51 -080028 __s64 fd;
29 char name[BTRFS_PATH_NAME_MAX + 1];
Ben Cheng655a7c02013-10-16 16:09:24 -070030};
Christopher Ferris106b3a82016-08-24 12:15:38 -070031#define BTRFS_DEVICE_PATH_NAME_MAX 1024
Christopher Ferris76a1d452018-06-27 14:12:29 -070032#define BTRFS_SUBVOL_NAME_MAX 4039
33#define BTRFS_SUBVOL_CREATE_ASYNC (1ULL << 0)
34#define BTRFS_SUBVOL_RDONLY (1ULL << 1)
35#define BTRFS_SUBVOL_QGROUP_INHERIT (1ULL << 2)
Christopher Ferris106b3a82016-08-24 12:15:38 -070036#define BTRFS_DEVICE_SPEC_BY_ID (1ULL << 3)
37#define BTRFS_VOL_ARG_V2_FLAGS_SUPPORTED (BTRFS_SUBVOL_CREATE_ASYNC | BTRFS_SUBVOL_RDONLY | BTRFS_SUBVOL_QGROUP_INHERIT | BTRFS_DEVICE_SPEC_BY_ID)
Ben Cheng655a7c02013-10-16 16:09:24 -070038#define BTRFS_FSID_SIZE 16
Ben Cheng655a7c02013-10-16 16:09:24 -070039#define BTRFS_UUID_SIZE 16
Christopher Ferrisba8d4f42014-09-03 19:56:49 -070040#define BTRFS_UUID_UNPARSED_SIZE 37
Christopher Ferris106b3a82016-08-24 12:15:38 -070041#define BTRFS_QGROUP_LIMIT_MAX_RFER (1ULL << 0)
42#define BTRFS_QGROUP_LIMIT_MAX_EXCL (1ULL << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -070043#define BTRFS_QGROUP_LIMIT_RSV_RFER (1ULL << 2)
44#define BTRFS_QGROUP_LIMIT_RSV_EXCL (1ULL << 3)
45#define BTRFS_QGROUP_LIMIT_RFER_CMPR (1ULL << 4)
46#define BTRFS_QGROUP_LIMIT_EXCL_CMPR (1ULL << 5)
Christopher Ferris106b3a82016-08-24 12:15:38 -070047struct btrfs_qgroup_limit {
Tao Baod7db5942015-01-28 10:07:51 -080048 __u64 flags;
49 __u64 max_rfer;
50 __u64 max_excl;
Christopher Ferris106b3a82016-08-24 12:15:38 -070051 __u64 rsv_rfer;
Tao Baod7db5942015-01-28 10:07:51 -080052 __u64 rsv_excl;
Ben Cheng655a7c02013-10-16 16:09:24 -070053};
Christopher Ferris106b3a82016-08-24 12:15:38 -070054#define BTRFS_QGROUP_INHERIT_SET_LIMITS (1ULL << 0)
Ben Cheng655a7c02013-10-16 16:09:24 -070055struct btrfs_qgroup_inherit {
Tao Baod7db5942015-01-28 10:07:51 -080056 __u64 flags;
Tao Baod7db5942015-01-28 10:07:51 -080057 __u64 num_qgroups;
58 __u64 num_ref_copies;
59 __u64 num_excl_copies;
60 struct btrfs_qgroup_limit lim;
Tao Baod7db5942015-01-28 10:07:51 -080061 __u64 qgroups[0];
Ben Cheng655a7c02013-10-16 16:09:24 -070062};
63struct btrfs_ioctl_qgroup_limit_args {
Tao Baod7db5942015-01-28 10:07:51 -080064 __u64 qgroupid;
Tao Baod7db5942015-01-28 10:07:51 -080065 struct btrfs_qgroup_limit lim;
Ben Cheng655a7c02013-10-16 16:09:24 -070066};
Christopher Ferris106b3a82016-08-24 12:15:38 -070067struct btrfs_ioctl_vol_args_v2 {
Tao Baod7db5942015-01-28 10:07:51 -080068 __s64 fd;
69 __u64 transid;
70 __u64 flags;
Christopher Ferris106b3a82016-08-24 12:15:38 -070071 union {
Tao Baod7db5942015-01-28 10:07:51 -080072 struct {
73 __u64 size;
74 struct btrfs_qgroup_inherit __user * qgroup_inherit;
Christopher Ferris106b3a82016-08-24 12:15:38 -070075 };
Tao Baod7db5942015-01-28 10:07:51 -080076 __u64 unused[4];
77 };
Christopher Ferris106b3a82016-08-24 12:15:38 -070078 union {
Christopher Ferris106b3a82016-08-24 12:15:38 -070079 char name[BTRFS_SUBVOL_NAME_MAX + 1];
80 __u64 devid;
81 };
Ben Cheng655a7c02013-10-16 16:09:24 -070082};
Christopher Ferrisba8d4f42014-09-03 19:56:49 -070083struct btrfs_scrub_progress {
Tao Baod7db5942015-01-28 10:07:51 -080084 __u64 data_extents_scrubbed;
85 __u64 tree_extents_scrubbed;
86 __u64 data_bytes_scrubbed;
Tao Baod7db5942015-01-28 10:07:51 -080087 __u64 tree_bytes_scrubbed;
88 __u64 read_errors;
89 __u64 csum_errors;
90 __u64 verify_errors;
Tao Baod7db5942015-01-28 10:07:51 -080091 __u64 no_csum;
92 __u64 csum_discards;
93 __u64 super_errors;
94 __u64 malloc_errors;
Tao Baod7db5942015-01-28 10:07:51 -080095 __u64 uncorrectable_errors;
96 __u64 corrected_errors;
97 __u64 last_physical;
98 __u64 unverified_errors;
Christopher Ferrisba8d4f42014-09-03 19:56:49 -070099};
Ben Cheng655a7c02013-10-16 16:09:24 -0700100#define BTRFS_SCRUB_READONLY 1
101struct btrfs_ioctl_scrub_args {
Tao Baod7db5942015-01-28 10:07:51 -0800102 __u64 devid;
Tao Baod7db5942015-01-28 10:07:51 -0800103 __u64 start;
104 __u64 end;
105 __u64 flags;
106 struct btrfs_scrub_progress progress;
Tao Baod7db5942015-01-28 10:07:51 -0800107 __u64 unused[(1024 - 32 - sizeof(struct btrfs_scrub_progress)) / 8];
Ben Cheng655a7c02013-10-16 16:09:24 -0700108};
109#define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_ALWAYS 0
110#define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_AVOID 1
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700111struct btrfs_ioctl_dev_replace_start_params {
Tao Baod7db5942015-01-28 10:07:51 -0800112 __u64 srcdevid;
113 __u64 cont_reading_from_srcdev_mode;
114 __u8 srcdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1];
Tao Baod7db5942015-01-28 10:07:51 -0800115 __u8 tgtdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1];
Ben Cheng655a7c02013-10-16 16:09:24 -0700116};
117#define BTRFS_IOCTL_DEV_REPLACE_STATE_NEVER_STARTED 0
118#define BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED 1
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700119#define BTRFS_IOCTL_DEV_REPLACE_STATE_FINISHED 2
Ben Cheng655a7c02013-10-16 16:09:24 -0700120#define BTRFS_IOCTL_DEV_REPLACE_STATE_CANCELED 3
121#define BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED 4
122struct btrfs_ioctl_dev_replace_status_params {
Tao Baod7db5942015-01-28 10:07:51 -0800123 __u64 replace_state;
124 __u64 progress_1000;
125 __u64 time_started;
126 __u64 time_stopped;
Tao Baod7db5942015-01-28 10:07:51 -0800127 __u64 num_write_errors;
128 __u64 num_uncorrectable_read_errors;
Ben Cheng655a7c02013-10-16 16:09:24 -0700129};
130#define BTRFS_IOCTL_DEV_REPLACE_CMD_START 0
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700131#define BTRFS_IOCTL_DEV_REPLACE_CMD_STATUS 1
Ben Cheng655a7c02013-10-16 16:09:24 -0700132#define BTRFS_IOCTL_DEV_REPLACE_CMD_CANCEL 2
133#define BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR 0
134#define BTRFS_IOCTL_DEV_REPLACE_RESULT_NOT_STARTED 1
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700135#define BTRFS_IOCTL_DEV_REPLACE_RESULT_ALREADY_STARTED 2
Christopher Ferris05d08e92016-02-04 13:16:38 -0800136#define BTRFS_IOCTL_DEV_REPLACE_RESULT_SCRUB_INPROGRESS 3
Ben Cheng655a7c02013-10-16 16:09:24 -0700137struct btrfs_ioctl_dev_replace_args {
Tao Baod7db5942015-01-28 10:07:51 -0800138 __u64 cmd;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800139 __u64 result;
Tao Baod7db5942015-01-28 10:07:51 -0800140 union {
141 struct btrfs_ioctl_dev_replace_start_params start;
142 struct btrfs_ioctl_dev_replace_status_params status;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800143 };
Tao Baod7db5942015-01-28 10:07:51 -0800144 __u64 spare[64];
Ben Cheng655a7c02013-10-16 16:09:24 -0700145};
146struct btrfs_ioctl_dev_info_args {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800147 __u64 devid;
Tao Baod7db5942015-01-28 10:07:51 -0800148 __u8 uuid[BTRFS_UUID_SIZE];
149 __u64 bytes_used;
150 __u64 total_bytes;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800151 __u64 unused[379];
Tao Baod7db5942015-01-28 10:07:51 -0800152 __u8 path[BTRFS_DEVICE_PATH_NAME_MAX];
Ben Cheng655a7c02013-10-16 16:09:24 -0700153};
154struct btrfs_ioctl_fs_info_args {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800155 __u64 max_id;
Tao Baod7db5942015-01-28 10:07:51 -0800156 __u64 num_devices;
157 __u8 fsid[BTRFS_FSID_SIZE];
158 __u32 nodesize;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800159 __u32 sectorsize;
Tao Baod7db5942015-01-28 10:07:51 -0800160 __u32 clone_alignment;
161 __u32 reserved32;
162 __u64 reserved[122];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800163};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700164#define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE (1ULL << 0)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800165#define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID (1ULL << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700166#define BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF (1ULL << 0)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800167#define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL (1ULL << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700168#define BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS (1ULL << 2)
169#define BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO (1ULL << 3)
Christopher Ferris1308ad32017-11-14 17:32:13 -0800170#define BTRFS_FEATURE_INCOMPAT_COMPRESS_ZSTD (1ULL << 4)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800171#define BTRFS_FEATURE_INCOMPAT_BIG_METADATA (1ULL << 5)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700172#define BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF (1ULL << 6)
173#define BTRFS_FEATURE_INCOMPAT_RAID56 (1ULL << 7)
174#define BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA (1ULL << 8)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800175#define BTRFS_FEATURE_INCOMPAT_NO_HOLES (1ULL << 9)
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700176struct btrfs_ioctl_feature_flags {
Tao Baod7db5942015-01-28 10:07:51 -0800177 __u64 compat_flags;
178 __u64 compat_ro_flags;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800179 __u64 incompat_flags;
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700180};
Christopher Ferris38062f92014-07-09 15:33:25 -0700181#define BTRFS_BALANCE_CTL_PAUSE 1
Ben Cheng655a7c02013-10-16 16:09:24 -0700182#define BTRFS_BALANCE_CTL_CANCEL 2
Christopher Ferris49f525c2016-12-12 14:55:36 -0800183struct btrfs_balance_args {
Tao Baod7db5942015-01-28 10:07:51 -0800184 __u64 profiles;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800185 union {
Christopher Ferris525ce912017-07-26 13:12:53 -0700186 __u64 usage;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800187 struct {
Christopher Ferris525ce912017-07-26 13:12:53 -0700188 __u32 usage_min;
189 __u32 usage_max;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800190 };
Christopher Ferris49f525c2016-12-12 14:55:36 -0800191 };
Tao Baod7db5942015-01-28 10:07:51 -0800192 __u64 devid;
193 __u64 pstart;
Tao Baod7db5942015-01-28 10:07:51 -0800194 __u64 pend;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800195 __u64 vstart;
Tao Baod7db5942015-01-28 10:07:51 -0800196 __u64 vend;
197 __u64 target;
Tao Baod7db5942015-01-28 10:07:51 -0800198 __u64 flags;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800199 union {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800200 __u64 limit;
201 struct {
202 __u32 limit_min;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800203 __u32 limit_max;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800204 };
205 };
Christopher Ferris525ce912017-07-26 13:12:53 -0700206 __u32 stripes_min;
207 __u32 stripes_max;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800208 __u64 unused[6];
209} __attribute__((__packed__));
Ben Cheng655a7c02013-10-16 16:09:24 -0700210struct btrfs_balance_progress {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800211 __u64 expected;
Tao Baod7db5942015-01-28 10:07:51 -0800212 __u64 considered;
213 __u64 completed;
Ben Cheng655a7c02013-10-16 16:09:24 -0700214};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800215#define BTRFS_BALANCE_DATA (1ULL << 0)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700216#define BTRFS_BALANCE_SYSTEM (1ULL << 1)
217#define BTRFS_BALANCE_METADATA (1ULL << 2)
218#define BTRFS_BALANCE_TYPE_MASK (BTRFS_BALANCE_DATA | BTRFS_BALANCE_SYSTEM | BTRFS_BALANCE_METADATA)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800219#define BTRFS_BALANCE_FORCE (1ULL << 3)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700220#define BTRFS_BALANCE_RESUME (1ULL << 4)
221#define BTRFS_BALANCE_ARGS_PROFILES (1ULL << 0)
222#define BTRFS_BALANCE_ARGS_USAGE (1ULL << 1)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800223#define BTRFS_BALANCE_ARGS_DEVID (1ULL << 2)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700224#define BTRFS_BALANCE_ARGS_DRANGE (1ULL << 3)
225#define BTRFS_BALANCE_ARGS_VRANGE (1ULL << 4)
226#define BTRFS_BALANCE_ARGS_LIMIT (1ULL << 5)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800227#define BTRFS_BALANCE_ARGS_LIMIT_RANGE (1ULL << 6)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700228#define BTRFS_BALANCE_ARGS_STRIPES_RANGE (1ULL << 7)
229#define BTRFS_BALANCE_ARGS_USAGE_RANGE (1ULL << 10)
230#define BTRFS_BALANCE_ARGS_MASK (BTRFS_BALANCE_ARGS_PROFILES | BTRFS_BALANCE_ARGS_USAGE | BTRFS_BALANCE_ARGS_DEVID | BTRFS_BALANCE_ARGS_DRANGE | BTRFS_BALANCE_ARGS_VRANGE | BTRFS_BALANCE_ARGS_LIMIT | BTRFS_BALANCE_ARGS_LIMIT_RANGE | BTRFS_BALANCE_ARGS_STRIPES_RANGE | BTRFS_BALANCE_ARGS_USAGE_RANGE)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800231#define BTRFS_BALANCE_ARGS_CONVERT (1ULL << 8)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700232#define BTRFS_BALANCE_ARGS_SOFT (1ULL << 9)
Ben Cheng655a7c02013-10-16 16:09:24 -0700233#define BTRFS_BALANCE_STATE_RUNNING (1ULL << 0)
Christopher Ferris38062f92014-07-09 15:33:25 -0700234#define BTRFS_BALANCE_STATE_PAUSE_REQ (1ULL << 1)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800235#define BTRFS_BALANCE_STATE_CANCEL_REQ (1ULL << 2)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700236struct btrfs_ioctl_balance_args {
Tao Baod7db5942015-01-28 10:07:51 -0800237 __u64 flags;
238 __u64 state;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800239 struct btrfs_balance_args data;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700240 struct btrfs_balance_args meta;
Tao Baod7db5942015-01-28 10:07:51 -0800241 struct btrfs_balance_args sys;
242 struct btrfs_balance_progress stat;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800243 __u64 unused[72];
Christopher Ferris106b3a82016-08-24 12:15:38 -0700244};
Ben Cheng655a7c02013-10-16 16:09:24 -0700245#define BTRFS_INO_LOOKUP_PATH_MAX 4080
Christopher Ferris38062f92014-07-09 15:33:25 -0700246struct btrfs_ioctl_ino_lookup_args {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800247 __u64 treeid;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700248 __u64 objectid;
Tao Baod7db5942015-01-28 10:07:51 -0800249 char name[BTRFS_INO_LOOKUP_PATH_MAX];
Christopher Ferris38062f92014-07-09 15:33:25 -0700250};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800251struct btrfs_ioctl_search_key {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700252 __u64 tree_id;
Tao Baod7db5942015-01-28 10:07:51 -0800253 __u64 min_objectid;
254 __u64 max_objectid;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800255 __u64 min_offset;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700256 __u64 max_offset;
Tao Baod7db5942015-01-28 10:07:51 -0800257 __u64 min_transid;
258 __u64 max_transid;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800259 __u32 min_type;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700260 __u32 max_type;
Tao Baod7db5942015-01-28 10:07:51 -0800261 __u32 nr_items;
262 __u32 unused;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800263 __u64 unused1;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700264 __u64 unused2;
Tao Baod7db5942015-01-28 10:07:51 -0800265 __u64 unused3;
266 __u64 unused4;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800267};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700268struct btrfs_ioctl_search_header {
Tao Baod7db5942015-01-28 10:07:51 -0800269 __u64 transid;
270 __u64 objectid;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800271 __u64 offset;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700272 __u32 type;
Tao Baod7db5942015-01-28 10:07:51 -0800273 __u32 len;
Christopher Ferris38062f92014-07-09 15:33:25 -0700274};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800275#define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key))
Christopher Ferris106b3a82016-08-24 12:15:38 -0700276struct btrfs_ioctl_search_args {
Tao Baod7db5942015-01-28 10:07:51 -0800277 struct btrfs_ioctl_search_key key;
278 char buf[BTRFS_SEARCH_ARGS_BUFSIZE];
Christopher Ferris49f525c2016-12-12 14:55:36 -0800279};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700280struct btrfs_ioctl_search_args_v2 {
Tao Baod7db5942015-01-28 10:07:51 -0800281 struct btrfs_ioctl_search_key key;
282 __u64 buf_size;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800283 __u64 buf[0];
Christopher Ferris106b3a82016-08-24 12:15:38 -0700284};
Ben Cheng655a7c02013-10-16 16:09:24 -0700285struct btrfs_ioctl_clone_range_args {
Tao Baod7db5942015-01-28 10:07:51 -0800286 __s64 src_fd;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800287 __u64 src_offset, src_length;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700288 __u64 dest_offset;
Ben Cheng655a7c02013-10-16 16:09:24 -0700289};
290#define BTRFS_DEFRAG_RANGE_COMPRESS 1
Christopher Ferris49f525c2016-12-12 14:55:36 -0800291#define BTRFS_DEFRAG_RANGE_START_IO 2
Christopher Ferris106b3a82016-08-24 12:15:38 -0700292struct btrfs_ioctl_defrag_range_args {
293 __u64 start;
294 __u64 len;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800295 __u64 flags;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700296 __u32 extent_thresh;
297 __u32 compress_type;
298 __u32 unused[4];
Christopher Ferris49f525c2016-12-12 14:55:36 -0800299};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700300#define BTRFS_SAME_DATA_DIFFERS 1
Christopher Ferris38062f92014-07-09 15:33:25 -0700301struct btrfs_ioctl_same_extent_info {
Tao Baod7db5942015-01-28 10:07:51 -0800302 __s64 fd;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800303 __u64 logical_offset;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700304 __u64 bytes_deduped;
Tao Baod7db5942015-01-28 10:07:51 -0800305 __s32 status;
306 __u32 reserved;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800307};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700308struct btrfs_ioctl_same_args {
Tao Baod7db5942015-01-28 10:07:51 -0800309 __u64 logical_offset;
310 __u64 length;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800311 __u16 dest_count;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700312 __u16 reserved1;
Tao Baod7db5942015-01-28 10:07:51 -0800313 __u32 reserved2;
314 struct btrfs_ioctl_same_extent_info info[0];
Christopher Ferris49f525c2016-12-12 14:55:36 -0800315};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700316struct btrfs_ioctl_space_info {
Tao Baod7db5942015-01-28 10:07:51 -0800317 __u64 flags;
318 __u64 total_bytes;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800319 __u64 used_bytes;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700320};
Ben Cheng655a7c02013-10-16 16:09:24 -0700321struct btrfs_ioctl_space_args {
Tao Baod7db5942015-01-28 10:07:51 -0800322 __u64 space_slots;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800323 __u64 total_spaces;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700324 struct btrfs_ioctl_space_info spaces[0];
Ben Cheng655a7c02013-10-16 16:09:24 -0700325};
326struct btrfs_data_container {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800327 __u32 bytes_left;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700328 __u32 bytes_missing;
Tao Baod7db5942015-01-28 10:07:51 -0800329 __u32 elem_cnt;
330 __u32 elem_missed;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800331 __u64 val[0];
Christopher Ferris106b3a82016-08-24 12:15:38 -0700332};
Ben Cheng655a7c02013-10-16 16:09:24 -0700333struct btrfs_ioctl_ino_path_args {
Tao Baod7db5942015-01-28 10:07:51 -0800334 __u64 inum;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800335 __u64 size;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700336 __u64 reserved[4];
Tao Baod7db5942015-01-28 10:07:51 -0800337 __u64 fspath;
Ben Cheng655a7c02013-10-16 16:09:24 -0700338};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800339struct btrfs_ioctl_logical_ino_args {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700340 __u64 logical;
Tao Baod7db5942015-01-28 10:07:51 -0800341 __u64 size;
Christopher Ferris934ec942018-01-31 15:29:16 -0800342 __u64 reserved[3];
343 __u64 flags;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800344 __u64 inodes;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700345};
Christopher Ferris934ec942018-01-31 15:29:16 -0800346#define BTRFS_LOGICAL_INO_ARGS_IGNORE_OFFSET (1ULL << 0)
Ben Cheng655a7c02013-10-16 16:09:24 -0700347enum btrfs_dev_stat_values {
Tao Baod7db5942015-01-28 10:07:51 -0800348 BTRFS_DEV_STAT_WRITE_ERRS,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800349 BTRFS_DEV_STAT_READ_ERRS,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700350 BTRFS_DEV_STAT_FLUSH_ERRS,
Tao Baod7db5942015-01-28 10:07:51 -0800351 BTRFS_DEV_STAT_CORRUPTION_ERRS,
352 BTRFS_DEV_STAT_GENERATION_ERRS,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800353 BTRFS_DEV_STAT_VALUES_MAX
Christopher Ferris106b3a82016-08-24 12:15:38 -0700354};
Ben Cheng655a7c02013-10-16 16:09:24 -0700355#define BTRFS_DEV_STATS_RESET (1ULL << 0)
356struct btrfs_ioctl_get_dev_stats {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800357 __u64 devid;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700358 __u64 nr_items;
Tao Baod7db5942015-01-28 10:07:51 -0800359 __u64 flags;
360 __u64 values[BTRFS_DEV_STAT_VALUES_MAX];
Christopher Ferris49f525c2016-12-12 14:55:36 -0800361 __u64 unused[128 - 2 - BTRFS_DEV_STAT_VALUES_MAX];
Christopher Ferris106b3a82016-08-24 12:15:38 -0700362};
Ben Cheng655a7c02013-10-16 16:09:24 -0700363#define BTRFS_QUOTA_CTL_ENABLE 1
364#define BTRFS_QUOTA_CTL_DISABLE 2
Christopher Ferris49f525c2016-12-12 14:55:36 -0800365#define BTRFS_QUOTA_CTL_RESCAN__NOTUSED 3
Christopher Ferris106b3a82016-08-24 12:15:38 -0700366struct btrfs_ioctl_quota_ctl_args {
Tao Baod7db5942015-01-28 10:07:51 -0800367 __u64 cmd;
368 __u64 status;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800369};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700370struct btrfs_ioctl_quota_rescan_args {
Tao Baod7db5942015-01-28 10:07:51 -0800371 __u64 flags;
372 __u64 progress;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800373 __u64 reserved[6];
Christopher Ferris106b3a82016-08-24 12:15:38 -0700374};
Ben Cheng655a7c02013-10-16 16:09:24 -0700375struct btrfs_ioctl_qgroup_assign_args {
Tao Baod7db5942015-01-28 10:07:51 -0800376 __u64 assign;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800377 __u64 src;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700378 __u64 dst;
Ben Cheng655a7c02013-10-16 16:09:24 -0700379};
380struct btrfs_ioctl_qgroup_create_args {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800381 __u64 create;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700382 __u64 qgroupid;
Ben Cheng655a7c02013-10-16 16:09:24 -0700383};
384struct btrfs_ioctl_timespec {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800385 __u64 sec;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700386 __u32 nsec;
Ben Cheng655a7c02013-10-16 16:09:24 -0700387};
388struct btrfs_ioctl_received_subvol_args {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800389 char uuid[BTRFS_UUID_SIZE];
Christopher Ferris106b3a82016-08-24 12:15:38 -0700390 __u64 stransid;
Tao Baod7db5942015-01-28 10:07:51 -0800391 __u64 rtransid;
392 struct btrfs_ioctl_timespec stime;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800393 struct btrfs_ioctl_timespec rtime;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700394 __u64 flags;
Tao Baod7db5942015-01-28 10:07:51 -0800395 __u64 reserved[16];
Ben Cheng655a7c02013-10-16 16:09:24 -0700396};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800397#define BTRFS_SEND_FLAG_NO_FILE_DATA 0x1
Christopher Ferris106b3a82016-08-24 12:15:38 -0700398#define BTRFS_SEND_FLAG_OMIT_STREAM_HEADER 0x2
Ben Cheng655a7c02013-10-16 16:09:24 -0700399#define BTRFS_SEND_FLAG_OMIT_END_CMD 0x4
Tao Baod7db5942015-01-28 10:07:51 -0800400#define BTRFS_SEND_FLAG_MASK (BTRFS_SEND_FLAG_NO_FILE_DATA | BTRFS_SEND_FLAG_OMIT_STREAM_HEADER | BTRFS_SEND_FLAG_OMIT_END_CMD)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800401struct btrfs_ioctl_send_args {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700402 __s64 send_fd;
Tao Baod7db5942015-01-28 10:07:51 -0800403 __u64 clone_sources_count;
404 __u64 __user * clone_sources;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800405 __u64 parent_root;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700406 __u64 flags;
Tao Baod7db5942015-01-28 10:07:51 -0800407 __u64 reserved[4];
Ben Cheng655a7c02013-10-16 16:09:24 -0700408};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800409enum btrfs_err_code {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700410 BTRFS_ERROR_DEV_RAID1_MIN_NOT_MET = 1,
Tao Baod7db5942015-01-28 10:07:51 -0800411 BTRFS_ERROR_DEV_RAID10_MIN_NOT_MET,
412 BTRFS_ERROR_DEV_RAID5_MIN_NOT_MET,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800413 BTRFS_ERROR_DEV_RAID6_MIN_NOT_MET,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700414 BTRFS_ERROR_DEV_TGT_REPLACE,
Tao Baod7db5942015-01-28 10:07:51 -0800415 BTRFS_ERROR_DEV_MISSING_NOT_FOUND,
416 BTRFS_ERROR_DEV_ONLY_WRITABLE,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800417 BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS
Christopher Ferris106b3a82016-08-24 12:15:38 -0700418};
Tao Baod7db5942015-01-28 10:07:51 -0800419#define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, struct btrfs_ioctl_vol_args)
420#define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, struct btrfs_ioctl_vol_args)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800421#define BTRFS_IOC_RESIZE _IOW(BTRFS_IOCTL_MAGIC, 3, struct btrfs_ioctl_vol_args)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700422#define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, struct btrfs_ioctl_vol_args)
Ben Cheng655a7c02013-10-16 16:09:24 -0700423#define BTRFS_IOC_TRANS_START _IO(BTRFS_IOCTL_MAGIC, 6)
Elliott Hughes8cb52b02013-11-21 13:43:23 -0800424#define BTRFS_IOC_TRANS_END _IO(BTRFS_IOCTL_MAGIC, 7)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800425#define BTRFS_IOC_SYNC _IO(BTRFS_IOCTL_MAGIC, 8)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700426#define BTRFS_IOC_CLONE _IOW(BTRFS_IOCTL_MAGIC, 9, int)
Tao Baod7db5942015-01-28 10:07:51 -0800427#define BTRFS_IOC_ADD_DEV _IOW(BTRFS_IOCTL_MAGIC, 10, struct btrfs_ioctl_vol_args)
428#define BTRFS_IOC_RM_DEV _IOW(BTRFS_IOCTL_MAGIC, 11, struct btrfs_ioctl_vol_args)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800429#define BTRFS_IOC_BALANCE _IOW(BTRFS_IOCTL_MAGIC, 12, struct btrfs_ioctl_vol_args)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700430#define BTRFS_IOC_CLONE_RANGE _IOW(BTRFS_IOCTL_MAGIC, 13, struct btrfs_ioctl_clone_range_args)
Tao Baod7db5942015-01-28 10:07:51 -0800431#define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, struct btrfs_ioctl_vol_args)
432#define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, struct btrfs_ioctl_vol_args)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800433#define BTRFS_IOC_DEFRAG_RANGE _IOW(BTRFS_IOCTL_MAGIC, 16, struct btrfs_ioctl_defrag_range_args)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700434#define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, struct btrfs_ioctl_search_args)
Tao Baod7db5942015-01-28 10:07:51 -0800435#define BTRFS_IOC_TREE_SEARCH_V2 _IOWR(BTRFS_IOCTL_MAGIC, 17, struct btrfs_ioctl_search_args_v2)
436#define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, struct btrfs_ioctl_ino_lookup_args)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800437#define BTRFS_IOC_DEFAULT_SUBVOL _IOW(BTRFS_IOCTL_MAGIC, 19, __u64)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700438#define BTRFS_IOC_SPACE_INFO _IOWR(BTRFS_IOCTL_MAGIC, 20, struct btrfs_ioctl_space_args)
Ben Cheng655a7c02013-10-16 16:09:24 -0700439#define BTRFS_IOC_START_SYNC _IOR(BTRFS_IOCTL_MAGIC, 24, __u64)
440#define BTRFS_IOC_WAIT_SYNC _IOW(BTRFS_IOCTL_MAGIC, 22, __u64)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800441#define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, struct btrfs_ioctl_vol_args_v2)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700442#define BTRFS_IOC_SUBVOL_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 24, struct btrfs_ioctl_vol_args_v2)
Ben Cheng655a7c02013-10-16 16:09:24 -0700443#define BTRFS_IOC_SUBVOL_GETFLAGS _IOR(BTRFS_IOCTL_MAGIC, 25, __u64)
444#define BTRFS_IOC_SUBVOL_SETFLAGS _IOW(BTRFS_IOCTL_MAGIC, 26, __u64)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800445#define BTRFS_IOC_SCRUB _IOWR(BTRFS_IOCTL_MAGIC, 27, struct btrfs_ioctl_scrub_args)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700446#define BTRFS_IOC_SCRUB_CANCEL _IO(BTRFS_IOCTL_MAGIC, 28)
Tao Baod7db5942015-01-28 10:07:51 -0800447#define BTRFS_IOC_SCRUB_PROGRESS _IOWR(BTRFS_IOCTL_MAGIC, 29, struct btrfs_ioctl_scrub_args)
448#define BTRFS_IOC_DEV_INFO _IOWR(BTRFS_IOCTL_MAGIC, 30, struct btrfs_ioctl_dev_info_args)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800449#define BTRFS_IOC_FS_INFO _IOR(BTRFS_IOCTL_MAGIC, 31, struct btrfs_ioctl_fs_info_args)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700450#define BTRFS_IOC_BALANCE_V2 _IOWR(BTRFS_IOCTL_MAGIC, 32, struct btrfs_ioctl_balance_args)
Ben Cheng655a7c02013-10-16 16:09:24 -0700451#define BTRFS_IOC_BALANCE_CTL _IOW(BTRFS_IOCTL_MAGIC, 33, int)
Tao Baod7db5942015-01-28 10:07:51 -0800452#define BTRFS_IOC_BALANCE_PROGRESS _IOR(BTRFS_IOCTL_MAGIC, 34, struct btrfs_ioctl_balance_args)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800453#define BTRFS_IOC_INO_PATHS _IOWR(BTRFS_IOCTL_MAGIC, 35, struct btrfs_ioctl_ino_path_args)
454#define BTRFS_IOC_LOGICAL_INO _IOWR(BTRFS_IOCTL_MAGIC, 36, struct btrfs_ioctl_logical_ino_args)
Tao Baod7db5942015-01-28 10:07:51 -0800455#define BTRFS_IOC_SET_RECEIVED_SUBVOL _IOWR(BTRFS_IOCTL_MAGIC, 37, struct btrfs_ioctl_received_subvol_args)
Ben Cheng655a7c02013-10-16 16:09:24 -0700456#define BTRFS_IOC_SEND _IOW(BTRFS_IOCTL_MAGIC, 38, struct btrfs_ioctl_send_args)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800457#define BTRFS_IOC_DEVICES_READY _IOR(BTRFS_IOCTL_MAGIC, 39, struct btrfs_ioctl_vol_args)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700458#define BTRFS_IOC_QUOTA_CTL _IOWR(BTRFS_IOCTL_MAGIC, 40, struct btrfs_ioctl_quota_ctl_args)
Tao Baod7db5942015-01-28 10:07:51 -0800459#define BTRFS_IOC_QGROUP_ASSIGN _IOW(BTRFS_IOCTL_MAGIC, 41, struct btrfs_ioctl_qgroup_assign_args)
460#define BTRFS_IOC_QGROUP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 42, struct btrfs_ioctl_qgroup_create_args)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800461#define BTRFS_IOC_QGROUP_LIMIT _IOR(BTRFS_IOCTL_MAGIC, 43, struct btrfs_ioctl_qgroup_limit_args)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700462#define BTRFS_IOC_QUOTA_RESCAN _IOW(BTRFS_IOCTL_MAGIC, 44, struct btrfs_ioctl_quota_rescan_args)
Tao Baod7db5942015-01-28 10:07:51 -0800463#define BTRFS_IOC_QUOTA_RESCAN_STATUS _IOR(BTRFS_IOCTL_MAGIC, 45, struct btrfs_ioctl_quota_rescan_args)
Christopher Ferris38062f92014-07-09 15:33:25 -0700464#define BTRFS_IOC_QUOTA_RESCAN_WAIT _IO(BTRFS_IOCTL_MAGIC, 46)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800465#define BTRFS_IOC_GET_FSLABEL _IOR(BTRFS_IOCTL_MAGIC, 49, char[BTRFS_LABEL_SIZE])
Christopher Ferris106b3a82016-08-24 12:15:38 -0700466#define BTRFS_IOC_SET_FSLABEL _IOW(BTRFS_IOCTL_MAGIC, 50, char[BTRFS_LABEL_SIZE])
Tao Baod7db5942015-01-28 10:07:51 -0800467#define BTRFS_IOC_GET_DEV_STATS _IOWR(BTRFS_IOCTL_MAGIC, 52, struct btrfs_ioctl_get_dev_stats)
468#define BTRFS_IOC_DEV_REPLACE _IOWR(BTRFS_IOCTL_MAGIC, 53, struct btrfs_ioctl_dev_replace_args)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800469#define BTRFS_IOC_FILE_EXTENT_SAME _IOWR(BTRFS_IOCTL_MAGIC, 54, struct btrfs_ioctl_same_args)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700470#define BTRFS_IOC_GET_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, struct btrfs_ioctl_feature_flags)
Tao Baod7db5942015-01-28 10:07:51 -0800471#define BTRFS_IOC_SET_FEATURES _IOW(BTRFS_IOCTL_MAGIC, 57, struct btrfs_ioctl_feature_flags[2])
472#define BTRFS_IOC_GET_SUPPORTED_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, struct btrfs_ioctl_feature_flags[3])
Christopher Ferris49f525c2016-12-12 14:55:36 -0800473#define BTRFS_IOC_RM_DEV_V2 _IOW(BTRFS_IOCTL_MAGIC, 58, struct btrfs_ioctl_vol_args_v2)
Christopher Ferris934ec942018-01-31 15:29:16 -0800474#define BTRFS_IOC_LOGICAL_INO_V2 _IOWR(BTRFS_IOCTL_MAGIC, 59, struct btrfs_ioctl_logical_ino_args)
Christopher Ferris38062f92014-07-09 15:33:25 -0700475#endif