btrfs-progs: fix unknown type name 'u64' in gccgo
[platform/upstream/btrfs-progs.git] / ioctl.h
1 /*
2  * Copyright (C) 2007 Oracle.  All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public
6  * License v2 as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public
14  * License along with this program; if not, write to the
15  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16  * Boston, MA 021110-1307, USA.
17  */
18
19 #ifndef __BTRFS_IOCTL_H__
20 #define __BTRFS_IOCTL_H__
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 #include <asm/types.h>
27 #include <linux/ioctl.h>
28
29 #ifndef __user
30 #define __user
31 #endif
32
33 #define BTRFS_IOCTL_MAGIC 0x94
34 #define BTRFS_VOL_NAME_MAX 255
35
36 /* this should be 4k */
37 #define BTRFS_PATH_NAME_MAX 4087
38 struct btrfs_ioctl_vol_args {
39         __s64 fd;
40         char name[BTRFS_PATH_NAME_MAX + 1];
41 };
42
43 #define BTRFS_DEVICE_PATH_NAME_MAX 1024
44
45 #define BTRFS_SUBVOL_CREATE_ASYNC       (1ULL << 0)
46 #define BTRFS_SUBVOL_RDONLY             (1ULL << 1)
47 #define BTRFS_SUBVOL_QGROUP_INHERIT     (1ULL << 2)
48 #define BTRFS_DEVICE_SPEC_BY_ID         (1ULL << 3)
49
50 #define BTRFS_VOL_ARG_V2_FLAGS_SUPPORTED                \
51                         (BTRFS_SUBVOL_CREATE_ASYNC |    \
52                         BTRFS_SUBVOL_RDONLY |           \
53                         BTRFS_SUBVOL_QGROUP_INHERIT |   \
54                         BTRFS_DEVICE_SPEC_BY_ID)
55
56 #define BTRFS_FSID_SIZE 16
57 #define BTRFS_UUID_SIZE 16
58
59 #define BTRFS_QGROUP_INHERIT_SET_LIMITS (1ULL << 0)
60
61 struct btrfs_qgroup_limit {
62         __u64   flags;
63         __u64   max_referenced;
64         __u64   max_exclusive;
65         __u64   rsv_referenced;
66         __u64   rsv_exclusive;
67 };
68
69 struct btrfs_qgroup_inherit {
70         __u64   flags;
71         __u64   num_qgroups;
72         __u64   num_ref_copies;
73         __u64   num_excl_copies;
74         struct btrfs_qgroup_limit lim;
75         __u64   qgroups[0];
76 };
77
78 struct btrfs_ioctl_qgroup_limit_args {
79         __u64   qgroupid;
80         struct btrfs_qgroup_limit lim;
81 };
82
83 #define BTRFS_SUBVOL_NAME_MAX 4039
84 struct btrfs_ioctl_vol_args_v2 {
85         __s64 fd;
86         __u64 transid;
87         __u64 flags;
88         union {
89                 struct {
90                         __u64 size;
91                         struct btrfs_qgroup_inherit __user *qgroup_inherit;
92                 };
93                 __u64 unused[4];
94         };
95         union {
96                 char name[BTRFS_SUBVOL_NAME_MAX + 1];
97                 __u64 devid;
98         };
99 };
100
101 /*
102  * structure to report errors and progress to userspace, either as a
103  * result of a finished scrub, a canceled scrub or a progress inquiry
104  */
105 struct btrfs_scrub_progress {
106         __u64 data_extents_scrubbed;    /* # of data extents scrubbed */
107         __u64 tree_extents_scrubbed;    /* # of tree extents scrubbed */
108         __u64 data_bytes_scrubbed;      /* # of data bytes scrubbed */
109         __u64 tree_bytes_scrubbed;      /* # of tree bytes scrubbed */
110         __u64 read_errors;              /* # of read errors encountered (EIO) */
111         __u64 csum_errors;              /* # of failed csum checks */
112         __u64 verify_errors;            /* # of occurences, where the metadata
113                                          * of a tree block did not match the
114                                          * expected values, like generation or
115                                          * logical */
116         __u64 no_csum;                  /* # of 4k data block for which no csum
117                                          * is present, probably the result of
118                                          * data written with nodatasum */
119         __u64 csum_discards;            /* # of csum for which no data was found
120                                          * in the extent tree. */
121         __u64 super_errors;             /* # of bad super blocks encountered */
122         __u64 malloc_errors;            /* # of internal kmalloc errors. These
123                                          * will likely cause an incomplete
124                                          * scrub */
125         __u64 uncorrectable_errors;     /* # of errors where either no intact
126                                          * copy was found or the writeback
127                                          * failed */
128         __u64 corrected_errors;         /* # of errors corrected */
129         __u64 last_physical;            /* last physical address scrubbed. In
130                                          * case a scrub was aborted, this can
131                                          * be used to restart the scrub */
132         __u64 unverified_errors;        /* # of occurences where a read for a
133                                          * full (64k) bio failed, but the re-
134                                          * check succeeded for each 4k piece.
135                                          * Intermittent error. */
136 };
137
138 #define BTRFS_SCRUB_READONLY    1
139 struct btrfs_ioctl_scrub_args {
140         __u64 devid;                            /* in */
141         __u64 start;                            /* in */
142         __u64 end;                              /* in */
143         __u64 flags;                            /* in */
144         struct btrfs_scrub_progress progress;   /* out */
145         /* pad to 1k */
146         __u64 unused[(1024-32-sizeof(struct btrfs_scrub_progress))/8];
147 };
148
149 #define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_ALWAYS    0
150 #define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_AVOID     1
151 struct btrfs_ioctl_dev_replace_start_params {
152         __u64 srcdevid; /* in, if 0, use srcdev_name instead */
153         __u64 cont_reading_from_srcdev_mode;    /* in, see #define
154                                                  * above */
155         __u8 srcdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1];       /* in */
156         __u8 tgtdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1];       /* in */
157 };
158
159 #define BTRFS_IOCTL_DEV_REPLACE_STATE_NEVER_STARTED     0
160 #define BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED           1
161 #define BTRFS_IOCTL_DEV_REPLACE_STATE_FINISHED          2
162 #define BTRFS_IOCTL_DEV_REPLACE_STATE_CANCELED          3
163 #define BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED         4
164 struct btrfs_ioctl_dev_replace_status_params {
165         __u64 replace_state;    /* out, see #define above */
166         __u64 progress_1000;    /* out, 0 <= x <= 1000 */
167         __u64 time_started;     /* out, seconds since 1-Jan-1970 */
168         __u64 time_stopped;     /* out, seconds since 1-Jan-1970 */
169         __u64 num_write_errors; /* out */
170         __u64 num_uncorrectable_read_errors;    /* out */
171 };
172
173 #define BTRFS_IOCTL_DEV_REPLACE_CMD_START                       0
174 #define BTRFS_IOCTL_DEV_REPLACE_CMD_STATUS                      1
175 #define BTRFS_IOCTL_DEV_REPLACE_CMD_CANCEL                      2
176 #define BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_RESULT                -1
177 #define BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR                 0
178 #define BTRFS_IOCTL_DEV_REPLACE_RESULT_NOT_STARTED              1
179 #define BTRFS_IOCTL_DEV_REPLACE_RESULT_ALREADY_STARTED          2
180 #define BTRFS_IOCTL_DEV_REPLACE_RESULT_SCRUB_INPROGRESS         3
181 struct btrfs_ioctl_dev_replace_args {
182         __u64 cmd;      /* in */
183         __u64 result;   /* out */
184
185         union {
186                 struct btrfs_ioctl_dev_replace_start_params start;
187                 struct btrfs_ioctl_dev_replace_status_params status;
188         };      /* in/out */
189
190         __u64 spare[64];
191 };
192
193 struct btrfs_ioctl_dev_info_args {
194         __u64 devid;                            /* in/out */
195         __u8 uuid[BTRFS_UUID_SIZE];             /* in/out */
196         __u64 bytes_used;                       /* out */
197         __u64 total_bytes;                      /* out */
198         __u64 unused[379];                      /* pad to 4k */
199         __u8 path[BTRFS_DEVICE_PATH_NAME_MAX];  /* out */
200 };
201
202 struct btrfs_ioctl_fs_info_args {
203         __u64 max_id;                           /* out */
204         __u64 num_devices;                      /* out */
205         __u8 fsid[BTRFS_FSID_SIZE];             /* out */
206         __u32 nodesize;                         /* out */
207         __u32 sectorsize;                       /* out */
208         __u32 clone_alignment;                  /* out */
209         __u32 reserved32;
210         __u64 reserved[122];                    /* pad to 1k */
211 };
212
213 struct btrfs_ioctl_feature_flags {
214         __u64 compat_flags;
215         __u64 compat_ro_flags;
216         __u64 incompat_flags;
217 };
218
219 /* balance control ioctl modes */
220 #define BTRFS_BALANCE_CTL_PAUSE         1
221 #define BTRFS_BALANCE_CTL_CANCEL        2
222 #define BTRFS_BALANCE_CTL_RESUME        3
223
224 /*
225  * this is packed, because it should be exactly the same as its disk
226  * byte order counterpart (struct btrfs_disk_balance_args)
227  */
228 struct btrfs_balance_args {
229         __u64 profiles;
230
231         /*
232          * usage filter
233          * BTRFS_BALANCE_ARGS_USAGE with a single value means '0..N'
234          * BTRFS_BALANCE_ARGS_USAGE_RANGE - range syntax, min..max
235          */
236         union {
237                 __u64 usage;
238                 struct {
239                         __u32 usage_min;
240                         __u32 usage_max;
241                 };
242         };
243
244         __u64 devid;
245         __u64 pstart;
246         __u64 pend;
247         __u64 vstart;
248         __u64 vend;
249
250         __u64 target;
251
252         __u64 flags;
253
254         /*
255          * BTRFS_BALANCE_ARGS_LIMIT with value 'limit'
256          * BTRFS_BALANCE_ARGS_LIMIT_RANGE - the extend version can use minimum
257          * and maximum
258          */
259         union {
260                 __u64 limit;            /* limit number of processed chunks */
261                 struct {
262                         __u32 limit_min;
263                         __u32 limit_max;
264                 };
265         };
266         __u32 stripes_min;
267         __u32 stripes_max;
268         __u64 unused[6];
269 } __attribute__ ((__packed__));
270
271 /* report balance progress to userspace */
272 struct btrfs_balance_progress {
273         __u64 expected;         /* estimated # of chunks that will be
274                                  * relocated to fulfill the request */
275         __u64 considered;       /* # of chunks we have considered so far */
276         __u64 completed;        /* # of chunks relocated so far */
277 };
278
279 #define BTRFS_BALANCE_STATE_RUNNING     (1ULL << 0)
280 #define BTRFS_BALANCE_STATE_PAUSE_REQ   (1ULL << 1)
281 #define BTRFS_BALANCE_STATE_CANCEL_REQ  (1ULL << 2)
282
283 struct btrfs_ioctl_balance_args {
284         __u64 flags;                            /* in/out */
285         __u64 state;                            /* out */
286
287         struct btrfs_balance_args data;         /* in/out */
288         struct btrfs_balance_args meta;         /* in/out */
289         struct btrfs_balance_args sys;          /* in/out */
290
291         struct btrfs_balance_progress stat;     /* out */
292
293         __u64 unused[72];                       /* pad to 1k */
294 };
295
296 #define BTRFS_INO_LOOKUP_PATH_MAX 4080
297 struct btrfs_ioctl_ino_lookup_args {
298         __u64 treeid;
299         __u64 objectid;
300         char name[BTRFS_INO_LOOKUP_PATH_MAX];
301 };
302
303 struct btrfs_ioctl_search_key {
304         /* which root are we searching.  0 is the tree of tree roots */
305         __u64 tree_id;
306
307         /* keys returned will be >= min and <= max */
308         __u64 min_objectid;
309         __u64 max_objectid;
310
311         /* keys returned will be >= min and <= max */
312         __u64 min_offset;
313         __u64 max_offset;
314
315         /* max and min transids to search for */
316         __u64 min_transid;
317         __u64 max_transid;
318
319         /* keys returned will be >= min and <= max */
320         __u32 min_type;
321         __u32 max_type;
322
323         /*
324          * how many items did userland ask for, and how many are we
325          * returning
326          */
327         __u32 nr_items;
328
329         /* align to 64 bits */
330         __u32 unused;
331
332         /* some extra for later */
333         __u64 unused1;
334         __u64 unused2;
335         __u64 unused3;
336         __u64 unused4;
337 };
338
339 struct btrfs_ioctl_search_header {
340         __u64 transid;
341         __u64 objectid;
342         __u64 offset;
343         __u32 type;
344         __u32 len;
345 } __attribute__((may_alias));
346
347 #define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key))
348 /*
349  * the buf is an array of search headers where
350  * each header is followed by the actual item
351  * the type field is expanded to 32 bits for alignment
352  */
353 struct btrfs_ioctl_search_args {
354         struct btrfs_ioctl_search_key key;
355         char buf[BTRFS_SEARCH_ARGS_BUFSIZE];
356 };
357
358 /*
359  * Extended version of TREE_SEARCH ioctl that can return more than 4k of bytes.
360  * The allocated size of the buffer is set in buf_size.
361  */
362 struct btrfs_ioctl_search_args_v2 {
363         struct btrfs_ioctl_search_key key; /* in/out - search parameters */
364         __u64 buf_size;                    /* in - size of buffer
365                                             * out - on EOVERFLOW: needed size
366                                             *       to store item */
367         __u64 buf[0];                      /* out - found items */
368 };
369
370 /* With a @src_length of zero, the range from @src_offset->EOF is cloned! */
371 struct btrfs_ioctl_clone_range_args {
372         __s64 src_fd;
373         __u64 src_offset, src_length;
374         __u64 dest_offset;
375 };
376
377 /* flags for the defrag range ioctl */
378 #define BTRFS_DEFRAG_RANGE_COMPRESS 1
379 #define BTRFS_DEFRAG_RANGE_START_IO 2
380
381 #define BTRFS_SAME_DATA_DIFFERS 1
382 /* For extent-same ioctl */
383 struct btrfs_ioctl_same_extent_info {
384         __s64 fd;               /* in - destination file */
385         __u64 logical_offset;   /* in - start of extent in destination */
386         __u64 bytes_deduped;    /* out - total # of bytes we were able
387                                  * to dedupe from this file */
388         /* status of this dedupe operation:
389          * 0 if dedup succeeds
390          * < 0 for error
391          * == BTRFS_SAME_DATA_DIFFERS if data differs
392          */
393         __s32 status;           /* out - see above description */
394         __u32 reserved;
395 };
396
397 struct btrfs_ioctl_same_args {
398         __u64 logical_offset;   /* in - start of extent in source */
399         __u64 length;           /* in - length of extent */
400         __u16 dest_count;       /* in - total elements in info array */
401         __u16 reserved1;
402         __u32 reserved2;
403         struct btrfs_ioctl_same_extent_info info[0];
404 };
405
406 struct btrfs_ioctl_defrag_range_args {
407         /* start of the defrag operation */
408         __u64 start;
409
410         /* number of bytes to defrag, use (u64)-1 to say all */
411         __u64 len;
412
413         /*
414          * flags for the operation, which can include turning
415          * on compression for this one defrag
416          */
417         __u64 flags;
418
419         /*
420          * any extent bigger than this will be considered
421          * already defragged.  Use 0 to take the kernel default
422          * Use 1 to say every single extent must be rewritten
423          */
424         __u32 extent_thresh;
425
426         /*
427          * which compression method to use if turning on compression
428          * for this defrag operation.  If unspecified, zlib will
429          * be used
430          */
431         __u32 compress_type;
432
433         /* spare for later */
434         __u32 unused[4];
435 };
436
437 struct btrfs_ioctl_space_info {
438         __u64 flags;
439         __u64 total_bytes;
440         __u64 used_bytes;
441 };
442
443 struct btrfs_ioctl_space_args {
444         __u64 space_slots;
445         __u64 total_spaces;
446         struct btrfs_ioctl_space_info spaces[0];
447 };
448
449 struct btrfs_data_container {
450         __u32   bytes_left;     /* out -- bytes not needed to deliver output */
451         __u32   bytes_missing;  /* out -- additional bytes needed for result */
452         __u32   elem_cnt;       /* out */
453         __u32   elem_missed;    /* out */
454         __u64   val[0];         /* out */
455 };
456
457 struct btrfs_ioctl_ino_path_args {
458         __u64                           inum;           /* in */
459         __u64                           size;           /* in */
460         __u64                           reserved[4];
461         /* struct btrfs_data_container  *fspath;           out */
462         __u64                           fspath;         /* out */
463 };
464
465 struct btrfs_ioctl_logical_ino_args {
466         __u64                           logical;        /* in */
467         __u64                           size;           /* in */
468         __u64                           reserved[4];
469         /* struct btrfs_data_container  *inodes;        out   */
470         __u64                           inodes;
471 };
472
473 enum btrfs_dev_stat_values {
474         /* disk I/O failure stats */
475         BTRFS_DEV_STAT_WRITE_ERRS, /* EIO or EREMOTEIO from lower layers */
476         BTRFS_DEV_STAT_READ_ERRS, /* EIO or EREMOTEIO from lower layers */
477         BTRFS_DEV_STAT_FLUSH_ERRS, /* EIO or EREMOTEIO from lower layers */
478
479         /* stats for indirect indications for I/O failures */
480         BTRFS_DEV_STAT_CORRUPTION_ERRS, /* checksum error, bytenr error or
481                                          * contents is illegal: this is an
482                                          * indication that the block was damaged
483                                          * during read or write, or written to
484                                          * wrong location or read from wrong
485                                          * location */
486         BTRFS_DEV_STAT_GENERATION_ERRS, /* an indication that blocks have not
487                                          * been written */
488
489         BTRFS_DEV_STAT_VALUES_MAX
490 };
491
492 /* Reset statistics after reading; needs SYS_ADMIN capability */
493 #define BTRFS_DEV_STATS_RESET           (1ULL << 0)
494
495 struct btrfs_ioctl_get_dev_stats {
496         __u64 devid;                            /* in */
497         __u64 nr_items;                         /* in/out */
498         __u64 flags;                            /* in/out */
499
500         /* out values: */
501         __u64 values[BTRFS_DEV_STAT_VALUES_MAX];
502
503         __u64 unused[128 - 2 - BTRFS_DEV_STAT_VALUES_MAX]; /* pad to 1k */
504 };
505
506 /* BTRFS_IOC_SNAP_CREATE is no longer used by the btrfs command */
507 #define BTRFS_QUOTA_CTL_ENABLE  1
508 #define BTRFS_QUOTA_CTL_DISABLE 2
509 /* 3 has formerly been reserved for BTRFS_QUOTA_CTL_RESCAN */
510 struct btrfs_ioctl_quota_ctl_args {
511         __u64 cmd;
512         __u64 status;
513 };
514
515 struct btrfs_ioctl_quota_rescan_args {
516         __u64   flags;
517         __u64   progress;
518         __u64   reserved[6];
519 };
520
521 struct btrfs_ioctl_qgroup_assign_args {
522         __u64 assign;
523         __u64 src;
524         __u64 dst;
525 };
526
527 struct btrfs_ioctl_qgroup_create_args {
528         __u64 create;
529         __u64 qgroupid;
530 };
531 struct btrfs_ioctl_timespec {
532         __u64 sec;
533         __u32 nsec;
534 };
535
536 struct btrfs_ioctl_received_subvol_args {
537         char    uuid[BTRFS_UUID_SIZE];  /* in */
538         __u64   stransid;               /* in */
539         __u64   rtransid;               /* out */
540         struct btrfs_ioctl_timespec stime; /* in */
541         struct btrfs_ioctl_timespec rtime; /* out */
542         __u64   flags;                  /* in */
543         __u64   reserved[16];           /* in */
544 };
545
546 /*
547  * Caller doesn't want file data in the send stream, even if the
548  * search of clone sources doesn't find an extent. UPDATE_EXTENT
549  * commands will be sent instead of WRITE commands.
550  */
551 #define BTRFS_SEND_FLAG_NO_FILE_DATA            0x1
552
553 /*
554  * Do not add the leading stream header. Used when multiple snapshots
555  * are sent back to back.
556  */
557 #define BTRFS_SEND_FLAG_OMIT_STREAM_HEADER      0x2
558
559 /*
560  * Omit the command at the end of the stream that indicated the end
561  * of the stream. This option is used when multiple snapshots are
562  * sent back to back.
563  */
564 #define BTRFS_SEND_FLAG_OMIT_END_CMD            0x4
565
566 #define BTRFS_SEND_FLAG_MASK \
567         (BTRFS_SEND_FLAG_NO_FILE_DATA | \
568          BTRFS_SEND_FLAG_OMIT_STREAM_HEADER | \
569          BTRFS_SEND_FLAG_OMIT_END_CMD)
570
571 struct btrfs_ioctl_send_args {
572         __s64 send_fd;                  /* in */
573         __u64 clone_sources_count;      /* in */
574         __u64 __user *clone_sources;    /* in */
575         __u64 parent_root;              /* in */
576         __u64 flags;                    /* in */
577         __u64 reserved[4];              /* in */
578 };
579
580 /* Error codes as returned by the kernel */
581 enum btrfs_err_code {
582         notused,
583         BTRFS_ERROR_DEV_RAID1_MIN_NOT_MET,
584         BTRFS_ERROR_DEV_RAID10_MIN_NOT_MET,
585         BTRFS_ERROR_DEV_RAID5_MIN_NOT_MET,
586         BTRFS_ERROR_DEV_RAID6_MIN_NOT_MET,
587         BTRFS_ERROR_DEV_TGT_REPLACE,
588         BTRFS_ERROR_DEV_MISSING_NOT_FOUND,
589         BTRFS_ERROR_DEV_ONLY_WRITABLE,
590         BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS
591 };
592
593 /* An error code to error string mapping for the kernel
594 *  error codes
595 */
596 static inline char *btrfs_err_str(enum btrfs_err_code err_code)
597 {
598         switch (err_code) {
599                 case BTRFS_ERROR_DEV_RAID1_MIN_NOT_MET:
600                         return "unable to go below two devices on raid1";
601                 case BTRFS_ERROR_DEV_RAID10_MIN_NOT_MET:
602                         return "unable to go below four devices on raid10";
603                 case BTRFS_ERROR_DEV_RAID5_MIN_NOT_MET:
604                         return "unable to go below two devices on raid5";
605                 case BTRFS_ERROR_DEV_RAID6_MIN_NOT_MET:
606                         return "unable to go below three devices on raid6";
607                 case BTRFS_ERROR_DEV_TGT_REPLACE:
608                         return "unable to remove the dev_replace target dev";
609                 case BTRFS_ERROR_DEV_MISSING_NOT_FOUND:
610                         return "no missing devices found to remove";
611                 case BTRFS_ERROR_DEV_ONLY_WRITABLE:
612                         return "unable to remove the only writeable device";
613                 case BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS:
614                         return "add/delete/balance/replace/resize operation "
615                                 "in progress";
616                 default:
617                         return NULL;
618         }
619 }
620
621 #define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, \
622                                    struct btrfs_ioctl_vol_args)
623 #define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \
624                                    struct btrfs_ioctl_vol_args)
625 #define BTRFS_IOC_RESIZE _IOW(BTRFS_IOCTL_MAGIC, 3, \
626                                    struct btrfs_ioctl_vol_args)
627 #define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, \
628                                    struct btrfs_ioctl_vol_args)
629 /* trans start and trans end are dangerous, and only for
630  * use by applications that know how to avoid the
631  * resulting deadlocks
632  */
633 #define BTRFS_IOC_TRANS_START  _IO(BTRFS_IOCTL_MAGIC, 6)
634 #define BTRFS_IOC_TRANS_END    _IO(BTRFS_IOCTL_MAGIC, 7)
635 #define BTRFS_IOC_SYNC         _IO(BTRFS_IOCTL_MAGIC, 8)
636
637 #define BTRFS_IOC_CLONE        _IOW(BTRFS_IOCTL_MAGIC, 9, int)
638 #define BTRFS_IOC_ADD_DEV _IOW(BTRFS_IOCTL_MAGIC, 10, \
639                                    struct btrfs_ioctl_vol_args)
640 #define BTRFS_IOC_RM_DEV _IOW(BTRFS_IOCTL_MAGIC, 11, \
641                                    struct btrfs_ioctl_vol_args)
642 #define BTRFS_IOC_BALANCE _IOW(BTRFS_IOCTL_MAGIC, 12, \
643                                    struct btrfs_ioctl_vol_args)
644
645 #define BTRFS_IOC_CLONE_RANGE _IOW(BTRFS_IOCTL_MAGIC, 13, \
646                                    struct btrfs_ioctl_clone_range_args)
647
648 #define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \
649                                    struct btrfs_ioctl_vol_args)
650 #define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, \
651                                    struct btrfs_ioctl_vol_args)
652 #define BTRFS_IOC_DEFRAG_RANGE _IOW(BTRFS_IOCTL_MAGIC, 16, \
653                                 struct btrfs_ioctl_defrag_range_args)
654 #define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \
655                                    struct btrfs_ioctl_search_args)
656 #define BTRFS_IOC_TREE_SEARCH_V2 _IOWR(BTRFS_IOCTL_MAGIC, 17, \
657                                    struct btrfs_ioctl_search_args_v2)
658 #define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, \
659                                    struct btrfs_ioctl_ino_lookup_args)
660 #define BTRFS_IOC_DEFAULT_SUBVOL _IOW(BTRFS_IOCTL_MAGIC, 19, __u64)
661 #define BTRFS_IOC_SPACE_INFO _IOWR(BTRFS_IOCTL_MAGIC, 20, \
662                                     struct btrfs_ioctl_space_args)
663 #define BTRFS_IOC_START_SYNC _IOR(BTRFS_IOCTL_MAGIC, 24, __u64)
664 #define BTRFS_IOC_WAIT_SYNC  _IOW(BTRFS_IOCTL_MAGIC, 22, __u64)
665 #define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \
666                                    struct btrfs_ioctl_vol_args_v2)
667 #define BTRFS_IOC_SUBVOL_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 24, \
668                                    struct btrfs_ioctl_vol_args_v2)
669 #define BTRFS_IOC_SUBVOL_GETFLAGS _IOR(BTRFS_IOCTL_MAGIC, 25, __u64)
670 #define BTRFS_IOC_SUBVOL_SETFLAGS _IOW(BTRFS_IOCTL_MAGIC, 26, __u64)
671 #define BTRFS_IOC_SCRUB _IOWR(BTRFS_IOCTL_MAGIC, 27, \
672                                 struct btrfs_ioctl_scrub_args)
673 #define BTRFS_IOC_SCRUB_CANCEL _IO(BTRFS_IOCTL_MAGIC, 28)
674 #define BTRFS_IOC_SCRUB_PROGRESS _IOWR(BTRFS_IOCTL_MAGIC, 29, \
675                                         struct btrfs_ioctl_scrub_args)
676 #define BTRFS_IOC_DEV_INFO _IOWR(BTRFS_IOCTL_MAGIC, 30, \
677                                         struct btrfs_ioctl_dev_info_args)
678 #define BTRFS_IOC_FS_INFO _IOR(BTRFS_IOCTL_MAGIC, 31, \
679                                  struct btrfs_ioctl_fs_info_args)
680 #define BTRFS_IOC_BALANCE_V2 _IOWR(BTRFS_IOCTL_MAGIC, 32, \
681                                    struct btrfs_ioctl_balance_args)
682 #define BTRFS_IOC_BALANCE_CTL _IOW(BTRFS_IOCTL_MAGIC, 33, int)
683 #define BTRFS_IOC_BALANCE_PROGRESS _IOR(BTRFS_IOCTL_MAGIC, 34, \
684                                         struct btrfs_ioctl_balance_args)
685 #define BTRFS_IOC_INO_PATHS _IOWR(BTRFS_IOCTL_MAGIC, 35, \
686                                         struct btrfs_ioctl_ino_path_args)
687 #define BTRFS_IOC_LOGICAL_INO _IOWR(BTRFS_IOCTL_MAGIC, 36, \
688                                         struct btrfs_ioctl_ino_path_args)
689 #define BTRFS_IOC_SET_RECEIVED_SUBVOL _IOWR(BTRFS_IOCTL_MAGIC, 37, \
690                                 struct btrfs_ioctl_received_subvol_args)
691 #define BTRFS_IOC_SEND _IOW(BTRFS_IOCTL_MAGIC, 38, struct btrfs_ioctl_send_args)
692 #define BTRFS_IOC_DEVICES_READY _IOR(BTRFS_IOCTL_MAGIC, 39, \
693                                      struct btrfs_ioctl_vol_args)
694 #define BTRFS_IOC_QUOTA_CTL _IOWR(BTRFS_IOCTL_MAGIC, 40, \
695                                         struct btrfs_ioctl_quota_ctl_args)
696 #define BTRFS_IOC_QGROUP_ASSIGN _IOW(BTRFS_IOCTL_MAGIC, 41, \
697                                         struct btrfs_ioctl_qgroup_assign_args)
698 #define BTRFS_IOC_QGROUP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 42, \
699                                         struct btrfs_ioctl_qgroup_create_args)
700 #define BTRFS_IOC_QGROUP_LIMIT _IOR(BTRFS_IOCTL_MAGIC, 43, \
701                                         struct btrfs_ioctl_qgroup_limit_args)
702 #define BTRFS_IOC_QUOTA_RESCAN _IOW(BTRFS_IOCTL_MAGIC, 44, \
703                                struct btrfs_ioctl_quota_rescan_args)
704 #define BTRFS_IOC_QUOTA_RESCAN_STATUS _IOR(BTRFS_IOCTL_MAGIC, 45, \
705                                struct btrfs_ioctl_quota_rescan_args)
706 #define BTRFS_IOC_QUOTA_RESCAN_WAIT _IO(BTRFS_IOCTL_MAGIC, 46)
707 #define BTRFS_IOC_GET_FSLABEL _IOR(BTRFS_IOCTL_MAGIC, 49, \
708                                    char[BTRFS_LABEL_SIZE])
709 #define BTRFS_IOC_SET_FSLABEL _IOW(BTRFS_IOCTL_MAGIC, 50, \
710                                    char[BTRFS_LABEL_SIZE])
711 #define BTRFS_IOC_GET_DEV_STATS _IOWR(BTRFS_IOCTL_MAGIC, 52, \
712                                       struct btrfs_ioctl_get_dev_stats)
713 #define BTRFS_IOC_DEV_REPLACE _IOWR(BTRFS_IOCTL_MAGIC, 53, \
714                                     struct btrfs_ioctl_dev_replace_args)
715 #define BTRFS_IOC_FILE_EXTENT_SAME _IOWR(BTRFS_IOCTL_MAGIC, 54, \
716                                          struct btrfs_ioctl_same_args)
717 #define BTRFS_IOC_GET_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, \
718                                   struct btrfs_ioctl_feature_flags)
719 #define BTRFS_IOC_SET_FEATURES _IOW(BTRFS_IOCTL_MAGIC, 57, \
720                                   struct btrfs_ioctl_feature_flags[2])
721 #define BTRFS_IOC_GET_SUPPORTED_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, \
722                                   struct btrfs_ioctl_feature_flags[3])
723 #define BTRFS_IOC_RM_DEV_V2     _IOW(BTRFS_IOCTL_MAGIC, 58, \
724                                    struct btrfs_ioctl_vol_args_v2)
725 #ifdef __cplusplus
726 }
727 #endif
728
729 #endif