1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
3 * Copyright (C) 2007 Oracle. All rights reserved.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License v2 as published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 021110-1307, USA.
20 #ifndef _UAPI_LINUX_BTRFS_H
21 #define _UAPI_LINUX_BTRFS_H
22 #include <linux/types.h>
23 #include <linux/ioctl.h>
25 #define BTRFS_IOCTL_MAGIC 0x94
26 #define BTRFS_VOL_NAME_MAX 255
27 #define BTRFS_LABEL_SIZE 256
29 /* this should be 4k */
30 #define BTRFS_PATH_NAME_MAX 4087
31 struct btrfs_ioctl_vol_args {
33 char name[BTRFS_PATH_NAME_MAX + 1];
36 #define BTRFS_DEVICE_PATH_NAME_MAX 1024
37 #define BTRFS_SUBVOL_NAME_MAX 4039
39 #define BTRFS_SUBVOL_CREATE_ASYNC (1ULL << 0)
40 #define BTRFS_SUBVOL_RDONLY (1ULL << 1)
41 #define BTRFS_SUBVOL_QGROUP_INHERIT (1ULL << 2)
43 #define BTRFS_DEVICE_SPEC_BY_ID (1ULL << 3)
45 #define BTRFS_VOL_ARG_V2_FLAGS_SUPPORTED \
46 (BTRFS_SUBVOL_CREATE_ASYNC | \
47 BTRFS_SUBVOL_RDONLY | \
48 BTRFS_SUBVOL_QGROUP_INHERIT | \
49 BTRFS_DEVICE_SPEC_BY_ID)
51 #define BTRFS_FSID_SIZE 16
52 #define BTRFS_UUID_SIZE 16
53 #define BTRFS_UUID_UNPARSED_SIZE 37
56 * flags definition for qgroup limits
59 * struct btrfs_qgroup_limit.flags
60 * struct btrfs_qgroup_limit_item.flags
62 #define BTRFS_QGROUP_LIMIT_MAX_RFER (1ULL << 0)
63 #define BTRFS_QGROUP_LIMIT_MAX_EXCL (1ULL << 1)
64 #define BTRFS_QGROUP_LIMIT_RSV_RFER (1ULL << 2)
65 #define BTRFS_QGROUP_LIMIT_RSV_EXCL (1ULL << 3)
66 #define BTRFS_QGROUP_LIMIT_RFER_CMPR (1ULL << 4)
67 #define BTRFS_QGROUP_LIMIT_EXCL_CMPR (1ULL << 5)
69 struct btrfs_qgroup_limit {
78 * flags definition for qgroup inheritance
81 * struct btrfs_qgroup_inherit.flags
83 #define BTRFS_QGROUP_INHERIT_SET_LIMITS (1ULL << 0)
85 struct btrfs_qgroup_inherit {
89 __u64 num_excl_copies;
90 struct btrfs_qgroup_limit lim;
94 struct btrfs_ioctl_qgroup_limit_args {
96 struct btrfs_qgroup_limit lim;
100 * flags for subvolumes
103 * struct btrfs_ioctl_vol_args_v2.flags
105 * BTRFS_SUBVOL_RDONLY is also provided/consumed by the following ioctls:
106 * - BTRFS_IOC_SUBVOL_GETFLAGS
107 * - BTRFS_IOC_SUBVOL_SETFLAGS
110 struct btrfs_ioctl_vol_args_v2 {
117 struct btrfs_qgroup_inherit __user *qgroup_inherit;
122 char name[BTRFS_SUBVOL_NAME_MAX + 1];
128 * structure to report errors and progress to userspace, either as a
129 * result of a finished scrub, a canceled scrub or a progress inquiry
131 struct btrfs_scrub_progress {
132 __u64 data_extents_scrubbed; /* # of data extents scrubbed */
133 __u64 tree_extents_scrubbed; /* # of tree extents scrubbed */
134 __u64 data_bytes_scrubbed; /* # of data bytes scrubbed */
135 __u64 tree_bytes_scrubbed; /* # of tree bytes scrubbed */
136 __u64 read_errors; /* # of read errors encountered (EIO) */
137 __u64 csum_errors; /* # of failed csum checks */
138 __u64 verify_errors; /* # of occurences, where the metadata
139 * of a tree block did not match the
140 * expected values, like generation or
142 __u64 no_csum; /* # of 4k data block for which no csum
143 * is present, probably the result of
144 * data written with nodatasum */
145 __u64 csum_discards; /* # of csum for which no data was found
146 * in the extent tree. */
147 __u64 super_errors; /* # of bad super blocks encountered */
148 __u64 malloc_errors; /* # of internal kmalloc errors. These
149 * will likely cause an incomplete
151 __u64 uncorrectable_errors; /* # of errors where either no intact
152 * copy was found or the writeback
154 __u64 corrected_errors; /* # of errors corrected */
155 __u64 last_physical; /* last physical address scrubbed. In
156 * case a scrub was aborted, this can
157 * be used to restart the scrub */
158 __u64 unverified_errors; /* # of occurences where a read for a
159 * full (64k) bio failed, but the re-
160 * check succeeded for each 4k piece.
161 * Intermittent error. */
164 #define BTRFS_SCRUB_READONLY 1
165 struct btrfs_ioctl_scrub_args {
166 __u64 devid; /* in */
167 __u64 start; /* in */
169 __u64 flags; /* in */
170 struct btrfs_scrub_progress progress; /* out */
172 __u64 unused[(1024-32-sizeof(struct btrfs_scrub_progress))/8];
175 #define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_ALWAYS 0
176 #define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_AVOID 1
177 struct btrfs_ioctl_dev_replace_start_params {
178 __u64 srcdevid; /* in, if 0, use srcdev_name instead */
179 __u64 cont_reading_from_srcdev_mode; /* in, see #define
181 __u8 srcdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1]; /* in */
182 __u8 tgtdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1]; /* in */
185 #define BTRFS_IOCTL_DEV_REPLACE_STATE_NEVER_STARTED 0
186 #define BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED 1
187 #define BTRFS_IOCTL_DEV_REPLACE_STATE_FINISHED 2
188 #define BTRFS_IOCTL_DEV_REPLACE_STATE_CANCELED 3
189 #define BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED 4
190 struct btrfs_ioctl_dev_replace_status_params {
191 __u64 replace_state; /* out, see #define above */
192 __u64 progress_1000; /* out, 0 <= x <= 1000 */
193 __u64 time_started; /* out, seconds since 1-Jan-1970 */
194 __u64 time_stopped; /* out, seconds since 1-Jan-1970 */
195 __u64 num_write_errors; /* out */
196 __u64 num_uncorrectable_read_errors; /* out */
199 #define BTRFS_IOCTL_DEV_REPLACE_CMD_START 0
200 #define BTRFS_IOCTL_DEV_REPLACE_CMD_STATUS 1
201 #define BTRFS_IOCTL_DEV_REPLACE_CMD_CANCEL 2
202 #define BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR 0
203 #define BTRFS_IOCTL_DEV_REPLACE_RESULT_NOT_STARTED 1
204 #define BTRFS_IOCTL_DEV_REPLACE_RESULT_ALREADY_STARTED 2
205 #define BTRFS_IOCTL_DEV_REPLACE_RESULT_SCRUB_INPROGRESS 3
206 struct btrfs_ioctl_dev_replace_args {
208 __u64 result; /* out */
211 struct btrfs_ioctl_dev_replace_start_params start;
212 struct btrfs_ioctl_dev_replace_status_params status;
218 struct btrfs_ioctl_dev_info_args {
219 __u64 devid; /* in/out */
220 __u8 uuid[BTRFS_UUID_SIZE]; /* in/out */
221 __u64 bytes_used; /* out */
222 __u64 total_bytes; /* out */
223 __u64 unused[379]; /* pad to 4k */
224 __u8 path[BTRFS_DEVICE_PATH_NAME_MAX]; /* out */
227 struct btrfs_ioctl_fs_info_args {
228 __u64 max_id; /* out */
229 __u64 num_devices; /* out */
230 __u8 fsid[BTRFS_FSID_SIZE]; /* out */
231 __u32 nodesize; /* out */
232 __u32 sectorsize; /* out */
233 __u32 clone_alignment; /* out */
235 __u64 reserved[122]; /* pad to 1k */
242 * struct btrfs_ioctl_feature_flags
244 #define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE (1ULL << 0)
246 * Older kernels (< 4.9) on big-endian systems produced broken free space tree
247 * bitmaps, and btrfs-progs also used to corrupt the free space tree (versions
248 * < 4.7.3). If this bit is clear, then the free space tree cannot be trusted.
249 * btrfs-progs can also intentionally clear this bit to ask the kernel to
250 * rebuild the free space tree, however this might not work on older kernels
251 * that do not know about this bit. If not sure, clear the cache manually on
252 * first mount when booting older kernel versions.
254 #define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID (1ULL << 1)
256 #define BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF (1ULL << 0)
257 #define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL (1ULL << 1)
258 #define BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS (1ULL << 2)
259 #define BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO (1ULL << 3)
260 #define BTRFS_FEATURE_INCOMPAT_COMPRESS_ZSTD (1ULL << 4)
263 * older kernels tried to do bigger metadata blocks, but the
264 * code was pretty buggy. Lets not let them try anymore.
266 #define BTRFS_FEATURE_INCOMPAT_BIG_METADATA (1ULL << 5)
268 #define BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF (1ULL << 6)
269 #define BTRFS_FEATURE_INCOMPAT_RAID56 (1ULL << 7)
270 #define BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA (1ULL << 8)
271 #define BTRFS_FEATURE_INCOMPAT_NO_HOLES (1ULL << 9)
272 #define BTRFS_FEATURE_INCOMPAT_METADATA_UUID (1ULL << 10)
274 struct btrfs_ioctl_feature_flags {
276 __u64 compat_ro_flags;
277 __u64 incompat_flags;
280 /* balance control ioctl modes */
281 #define BTRFS_BALANCE_CTL_PAUSE 1
282 #define BTRFS_BALANCE_CTL_CANCEL 2
285 * this is packed, because it should be exactly the same as its disk
286 * byte order counterpart (struct btrfs_disk_balance_args)
288 struct btrfs_balance_args {
308 * BTRFS_BALANCE_ARGS_LIMIT with value 'limit'
309 * BTRFS_BALANCE_ARGS_LIMIT_RANGE - the extend version can use minimum
313 __u64 limit; /* limit number of processed chunks */
321 * Process chunks that cross stripes_min..stripes_max devices,
322 * BTRFS_BALANCE_ARGS_STRIPES_RANGE
328 } __attribute__ ((__packed__));
330 /* report balance progress to userspace */
331 struct btrfs_balance_progress {
332 __u64 expected; /* estimated # of chunks that will be
333 * relocated to fulfill the request */
334 __u64 considered; /* # of chunks we have considered so far */
335 __u64 completed; /* # of chunks relocated so far */
339 * flags definition for balance
341 * Restriper's general type filter
344 * btrfs_ioctl_balance_args.flags
345 * btrfs_balance_control.flags (internal)
347 #define BTRFS_BALANCE_DATA (1ULL << 0)
348 #define BTRFS_BALANCE_SYSTEM (1ULL << 1)
349 #define BTRFS_BALANCE_METADATA (1ULL << 2)
351 #define BTRFS_BALANCE_TYPE_MASK (BTRFS_BALANCE_DATA | \
352 BTRFS_BALANCE_SYSTEM | \
353 BTRFS_BALANCE_METADATA)
355 #define BTRFS_BALANCE_FORCE (1ULL << 3)
356 #define BTRFS_BALANCE_RESUME (1ULL << 4)
359 * flags definitions for per-type balance args
364 * struct btrfs_balance_args
366 #define BTRFS_BALANCE_ARGS_PROFILES (1ULL << 0)
367 #define BTRFS_BALANCE_ARGS_USAGE (1ULL << 1)
368 #define BTRFS_BALANCE_ARGS_DEVID (1ULL << 2)
369 #define BTRFS_BALANCE_ARGS_DRANGE (1ULL << 3)
370 #define BTRFS_BALANCE_ARGS_VRANGE (1ULL << 4)
371 #define BTRFS_BALANCE_ARGS_LIMIT (1ULL << 5)
372 #define BTRFS_BALANCE_ARGS_LIMIT_RANGE (1ULL << 6)
373 #define BTRFS_BALANCE_ARGS_STRIPES_RANGE (1ULL << 7)
374 #define BTRFS_BALANCE_ARGS_USAGE_RANGE (1ULL << 10)
376 #define BTRFS_BALANCE_ARGS_MASK \
377 (BTRFS_BALANCE_ARGS_PROFILES | \
378 BTRFS_BALANCE_ARGS_USAGE | \
379 BTRFS_BALANCE_ARGS_DEVID | \
380 BTRFS_BALANCE_ARGS_DRANGE | \
381 BTRFS_BALANCE_ARGS_VRANGE | \
382 BTRFS_BALANCE_ARGS_LIMIT | \
383 BTRFS_BALANCE_ARGS_LIMIT_RANGE | \
384 BTRFS_BALANCE_ARGS_STRIPES_RANGE | \
385 BTRFS_BALANCE_ARGS_USAGE_RANGE)
388 * Profile changing flags. When SOFT is set we won't relocate chunk if
389 * it already has the target profile (even though it may be
392 #define BTRFS_BALANCE_ARGS_CONVERT (1ULL << 8)
393 #define BTRFS_BALANCE_ARGS_SOFT (1ULL << 9)
397 * flags definition for balance state
400 * struct btrfs_ioctl_balance_args.state
402 #define BTRFS_BALANCE_STATE_RUNNING (1ULL << 0)
403 #define BTRFS_BALANCE_STATE_PAUSE_REQ (1ULL << 1)
404 #define BTRFS_BALANCE_STATE_CANCEL_REQ (1ULL << 2)
406 struct btrfs_ioctl_balance_args {
407 __u64 flags; /* in/out */
408 __u64 state; /* out */
410 struct btrfs_balance_args data; /* in/out */
411 struct btrfs_balance_args meta; /* in/out */
412 struct btrfs_balance_args sys; /* in/out */
414 struct btrfs_balance_progress stat; /* out */
416 __u64 unused[72]; /* pad to 1k */
419 #define BTRFS_INO_LOOKUP_PATH_MAX 4080
420 struct btrfs_ioctl_ino_lookup_args {
423 char name[BTRFS_INO_LOOKUP_PATH_MAX];
426 #define BTRFS_INO_LOOKUP_USER_PATH_MAX (4080 - BTRFS_VOL_NAME_MAX - 1)
427 struct btrfs_ioctl_ino_lookup_user_args {
428 /* in, inode number containing the subvolume of 'subvolid' */
432 /* out, name of the subvolume of 'treeid' */
433 char name[BTRFS_VOL_NAME_MAX + 1];
435 * out, constructed path from the directory with which the ioctl is
438 char path[BTRFS_INO_LOOKUP_USER_PATH_MAX];
441 /* Search criteria for the btrfs SEARCH ioctl family. */
442 struct btrfs_ioctl_search_key {
444 * The tree we're searching in. 1 is the tree of tree roots, 2 is the
445 * extent tree, etc...
447 * A special tree_id value of 0 will cause a search in the subvolume
448 * tree that the inode which is passed to the ioctl is part of.
450 __u64 tree_id; /* in */
453 * When doing a tree search, we're actually taking a slice from a
454 * linear search space of 136-bit keys.
456 * A full 136-bit tree key is composed as:
457 * (objectid << 72) + (type << 64) + offset
459 * The individual min and max values for objectid, type and offset
460 * define the min_key and max_key values for the search range. All
461 * metadata items with a key in the interval [min_key, max_key] will be
464 * Additionally, we can filter the items returned on transaction id of
465 * the metadata block they're stored in by specifying a transid range.
466 * Be aware that this transaction id only denotes when the metadata
467 * page that currently contains the item got written the last time as
468 * result of a COW operation. The number does not have any meaning
469 * related to the transaction in which an individual item that is being
470 * returned was created or changed.
472 __u64 min_objectid; /* in */
473 __u64 max_objectid; /* in */
474 __u64 min_offset; /* in */
475 __u64 max_offset; /* in */
476 __u64 min_transid; /* in */
477 __u64 max_transid; /* in */
478 __u32 min_type; /* in */
479 __u32 max_type; /* in */
482 * input: The maximum amount of results desired.
483 * output: The actual amount of items returned, restricted by any of:
484 * - reaching the upper bound of the search range
485 * - reaching the input nr_items amount of items
486 * - completely filling the supplied memory buffer
488 __u32 nr_items; /* in/out */
490 /* align to 64 bits */
493 /* some extra for later */
500 struct btrfs_ioctl_search_header {
508 #define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key))
510 * the buf is an array of search headers where
511 * each header is followed by the actual item
512 * the type field is expanded to 32 bits for alignment
514 struct btrfs_ioctl_search_args {
515 struct btrfs_ioctl_search_key key;
516 char buf[BTRFS_SEARCH_ARGS_BUFSIZE];
519 struct btrfs_ioctl_search_args_v2 {
520 struct btrfs_ioctl_search_key key; /* in/out - search parameters */
521 __u64 buf_size; /* in - size of buffer
522 * out - on EOVERFLOW: needed size
524 __u64 buf[0]; /* out - found items */
527 struct btrfs_ioctl_clone_range_args {
529 __u64 src_offset, src_length;
534 * flags definition for the defrag range ioctl
537 * struct btrfs_ioctl_defrag_range_args.flags
539 #define BTRFS_DEFRAG_RANGE_COMPRESS 1
540 #define BTRFS_DEFRAG_RANGE_START_IO 2
541 struct btrfs_ioctl_defrag_range_args {
542 /* start of the defrag operation */
545 /* number of bytes to defrag, use (u64)-1 to say all */
549 * flags for the operation, which can include turning
550 * on compression for this one defrag
555 * any extent bigger than this will be considered
556 * already defragged. Use 0 to take the kernel default
557 * Use 1 to say every single extent must be rewritten
562 * which compression method to use if turning on compression
563 * for this defrag operation. If unspecified, zlib will
568 /* spare for later */
573 #define BTRFS_SAME_DATA_DIFFERS 1
574 /* For extent-same ioctl */
575 struct btrfs_ioctl_same_extent_info {
576 __s64 fd; /* in - destination file */
577 __u64 logical_offset; /* in - start of extent in destination */
578 __u64 bytes_deduped; /* out - total # of bytes we were able
579 * to dedupe from this file */
580 /* status of this dedupe operation:
581 * 0 if dedup succeeds
583 * == BTRFS_SAME_DATA_DIFFERS if data differs
585 __s32 status; /* out - see above description */
589 struct btrfs_ioctl_same_args {
590 __u64 logical_offset; /* in - start of extent in source */
591 __u64 length; /* in - length of extent */
592 __u16 dest_count; /* in - total elements in info array */
595 struct btrfs_ioctl_same_extent_info info[0];
598 struct btrfs_ioctl_space_info {
604 struct btrfs_ioctl_space_args {
607 struct btrfs_ioctl_space_info spaces[0];
610 struct btrfs_data_container {
611 __u32 bytes_left; /* out -- bytes not needed to deliver output */
612 __u32 bytes_missing; /* out -- additional bytes needed for result */
613 __u32 elem_cnt; /* out */
614 __u32 elem_missed; /* out */
615 __u64 val[0]; /* out */
618 struct btrfs_ioctl_ino_path_args {
622 /* struct btrfs_data_container *fspath; out */
623 __u64 fspath; /* out */
626 struct btrfs_ioctl_logical_ino_args {
627 __u64 logical; /* in */
629 __u64 reserved[3]; /* must be 0 for now */
630 __u64 flags; /* in, v2 only */
631 /* struct btrfs_data_container *inodes; out */
634 /* Return every ref to the extent, not just those containing logical block.
635 * Requires logical == extent bytenr. */
636 #define BTRFS_LOGICAL_INO_ARGS_IGNORE_OFFSET (1ULL << 0)
638 enum btrfs_dev_stat_values {
639 /* disk I/O failure stats */
640 BTRFS_DEV_STAT_WRITE_ERRS, /* EIO or EREMOTEIO from lower layers */
641 BTRFS_DEV_STAT_READ_ERRS, /* EIO or EREMOTEIO from lower layers */
642 BTRFS_DEV_STAT_FLUSH_ERRS, /* EIO or EREMOTEIO from lower layers */
644 /* stats for indirect indications for I/O failures */
645 BTRFS_DEV_STAT_CORRUPTION_ERRS, /* checksum error, bytenr error or
646 * contents is illegal: this is an
647 * indication that the block was damaged
648 * during read or write, or written to
649 * wrong location or read from wrong
651 BTRFS_DEV_STAT_GENERATION_ERRS, /* an indication that blocks have not
654 BTRFS_DEV_STAT_VALUES_MAX
657 /* Reset statistics after reading; needs SYS_ADMIN capability */
658 #define BTRFS_DEV_STATS_RESET (1ULL << 0)
660 struct btrfs_ioctl_get_dev_stats {
661 __u64 devid; /* in */
662 __u64 nr_items; /* in/out */
663 __u64 flags; /* in/out */
666 __u64 values[BTRFS_DEV_STAT_VALUES_MAX];
669 * This pads the struct to 1032 bytes. It was originally meant to pad to
670 * 1024 bytes, but when adding the flags field, the padding calculation
673 __u64 unused[128 - 2 - BTRFS_DEV_STAT_VALUES_MAX];
676 #define BTRFS_QUOTA_CTL_ENABLE 1
677 #define BTRFS_QUOTA_CTL_DISABLE 2
678 #define BTRFS_QUOTA_CTL_RESCAN__NOTUSED 3
679 struct btrfs_ioctl_quota_ctl_args {
684 struct btrfs_ioctl_quota_rescan_args {
690 struct btrfs_ioctl_qgroup_assign_args {
696 struct btrfs_ioctl_qgroup_create_args {
700 struct btrfs_ioctl_timespec {
705 struct btrfs_ioctl_received_subvol_args {
706 char uuid[BTRFS_UUID_SIZE]; /* in */
707 __u64 stransid; /* in */
708 __u64 rtransid; /* out */
709 struct btrfs_ioctl_timespec stime; /* in */
710 struct btrfs_ioctl_timespec rtime; /* out */
711 __u64 flags; /* in */
712 __u64 reserved[16]; /* in */
716 * Caller doesn't want file data in the send stream, even if the
717 * search of clone sources doesn't find an extent. UPDATE_EXTENT
718 * commands will be sent instead of WRITE commands.
720 #define BTRFS_SEND_FLAG_NO_FILE_DATA 0x1
723 * Do not add the leading stream header. Used when multiple snapshots
724 * are sent back to back.
726 #define BTRFS_SEND_FLAG_OMIT_STREAM_HEADER 0x2
729 * Omit the command at the end of the stream that indicated the end
730 * of the stream. This option is used when multiple snapshots are
733 #define BTRFS_SEND_FLAG_OMIT_END_CMD 0x4
735 #define BTRFS_SEND_FLAG_MASK \
736 (BTRFS_SEND_FLAG_NO_FILE_DATA | \
737 BTRFS_SEND_FLAG_OMIT_STREAM_HEADER | \
738 BTRFS_SEND_FLAG_OMIT_END_CMD)
740 struct btrfs_ioctl_send_args {
741 __s64 send_fd; /* in */
742 __u64 clone_sources_count; /* in */
743 __u64 __user *clone_sources; /* in */
744 __u64 parent_root; /* in */
745 __u64 flags; /* in */
746 __u64 reserved[4]; /* in */
750 * Information about a fs tree root.
752 * All items are filled by the ioctl
754 struct btrfs_ioctl_get_subvol_info_args {
755 /* Id of this subvolume */
758 /* Name of this subvolume, used to get the real name at mount point */
759 char name[BTRFS_VOL_NAME_MAX + 1];
762 * Id of the subvolume which contains this subvolume.
763 * Zero for top-level subvolume or a deleted subvolume.
768 * Inode number of the directory which contains this subvolume.
769 * Zero for top-level subvolume or a deleted subvolume
773 /* Latest transaction id of this subvolume */
776 /* Flags of this subvolume */
779 /* UUID of this subvolume */
780 __u8 uuid[BTRFS_UUID_SIZE];
783 * UUID of the subvolume of which this subvolume is a snapshot.
784 * All zero for a non-snapshot subvolume.
786 __u8 parent_uuid[BTRFS_UUID_SIZE];
789 * UUID of the subvolume from which this subvolume was received.
790 * All zero for non-received subvolume.
792 __u8 received_uuid[BTRFS_UUID_SIZE];
794 /* Transaction id indicating when change/create/send/receive happened */
799 /* Time corresponding to c/o/s/rtransid */
800 struct btrfs_ioctl_timespec ctime;
801 struct btrfs_ioctl_timespec otime;
802 struct btrfs_ioctl_timespec stime;
803 struct btrfs_ioctl_timespec rtime;
809 #define BTRFS_MAX_ROOTREF_BUFFER_NUM 255
810 struct btrfs_ioctl_get_subvol_rootref_args {
811 /* in/out, minimum id of rootref's treeid to be searched */
818 } rootref[BTRFS_MAX_ROOTREF_BUFFER_NUM];
820 /* out, number of found items */
825 /* Error codes as returned by the kernel */
826 enum btrfs_err_code {
827 BTRFS_ERROR_DEV_RAID1_MIN_NOT_MET = 1,
828 BTRFS_ERROR_DEV_RAID10_MIN_NOT_MET,
829 BTRFS_ERROR_DEV_RAID5_MIN_NOT_MET,
830 BTRFS_ERROR_DEV_RAID6_MIN_NOT_MET,
831 BTRFS_ERROR_DEV_TGT_REPLACE,
832 BTRFS_ERROR_DEV_MISSING_NOT_FOUND,
833 BTRFS_ERROR_DEV_ONLY_WRITABLE,
834 BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS
837 #define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, \
838 struct btrfs_ioctl_vol_args)
839 #define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \
840 struct btrfs_ioctl_vol_args)
841 #define BTRFS_IOC_RESIZE _IOW(BTRFS_IOCTL_MAGIC, 3, \
842 struct btrfs_ioctl_vol_args)
843 #define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, \
844 struct btrfs_ioctl_vol_args)
845 #define BTRFS_IOC_FORGET_DEV _IOW(BTRFS_IOCTL_MAGIC, 5, \
846 struct btrfs_ioctl_vol_args)
847 /* trans start and trans end are dangerous, and only for
848 * use by applications that know how to avoid the
849 * resulting deadlocks
851 #define BTRFS_IOC_TRANS_START _IO(BTRFS_IOCTL_MAGIC, 6)
852 #define BTRFS_IOC_TRANS_END _IO(BTRFS_IOCTL_MAGIC, 7)
853 #define BTRFS_IOC_SYNC _IO(BTRFS_IOCTL_MAGIC, 8)
855 #define BTRFS_IOC_CLONE _IOW(BTRFS_IOCTL_MAGIC, 9, int)
856 #define BTRFS_IOC_ADD_DEV _IOW(BTRFS_IOCTL_MAGIC, 10, \
857 struct btrfs_ioctl_vol_args)
858 #define BTRFS_IOC_RM_DEV _IOW(BTRFS_IOCTL_MAGIC, 11, \
859 struct btrfs_ioctl_vol_args)
860 #define BTRFS_IOC_BALANCE _IOW(BTRFS_IOCTL_MAGIC, 12, \
861 struct btrfs_ioctl_vol_args)
863 #define BTRFS_IOC_CLONE_RANGE _IOW(BTRFS_IOCTL_MAGIC, 13, \
864 struct btrfs_ioctl_clone_range_args)
866 #define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \
867 struct btrfs_ioctl_vol_args)
868 #define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, \
869 struct btrfs_ioctl_vol_args)
870 #define BTRFS_IOC_DEFRAG_RANGE _IOW(BTRFS_IOCTL_MAGIC, 16, \
871 struct btrfs_ioctl_defrag_range_args)
872 #define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \
873 struct btrfs_ioctl_search_args)
874 #define BTRFS_IOC_TREE_SEARCH_V2 _IOWR(BTRFS_IOCTL_MAGIC, 17, \
875 struct btrfs_ioctl_search_args_v2)
876 #define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, \
877 struct btrfs_ioctl_ino_lookup_args)
878 #define BTRFS_IOC_DEFAULT_SUBVOL _IOW(BTRFS_IOCTL_MAGIC, 19, __u64)
879 #define BTRFS_IOC_SPACE_INFO _IOWR(BTRFS_IOCTL_MAGIC, 20, \
880 struct btrfs_ioctl_space_args)
881 #define BTRFS_IOC_START_SYNC _IOR(BTRFS_IOCTL_MAGIC, 24, __u64)
882 #define BTRFS_IOC_WAIT_SYNC _IOW(BTRFS_IOCTL_MAGIC, 22, __u64)
883 #define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \
884 struct btrfs_ioctl_vol_args_v2)
885 #define BTRFS_IOC_SUBVOL_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 24, \
886 struct btrfs_ioctl_vol_args_v2)
887 #define BTRFS_IOC_SUBVOL_GETFLAGS _IOR(BTRFS_IOCTL_MAGIC, 25, __u64)
888 #define BTRFS_IOC_SUBVOL_SETFLAGS _IOW(BTRFS_IOCTL_MAGIC, 26, __u64)
889 #define BTRFS_IOC_SCRUB _IOWR(BTRFS_IOCTL_MAGIC, 27, \
890 struct btrfs_ioctl_scrub_args)
891 #define BTRFS_IOC_SCRUB_CANCEL _IO(BTRFS_IOCTL_MAGIC, 28)
892 #define BTRFS_IOC_SCRUB_PROGRESS _IOWR(BTRFS_IOCTL_MAGIC, 29, \
893 struct btrfs_ioctl_scrub_args)
894 #define BTRFS_IOC_DEV_INFO _IOWR(BTRFS_IOCTL_MAGIC, 30, \
895 struct btrfs_ioctl_dev_info_args)
896 #define BTRFS_IOC_FS_INFO _IOR(BTRFS_IOCTL_MAGIC, 31, \
897 struct btrfs_ioctl_fs_info_args)
898 #define BTRFS_IOC_BALANCE_V2 _IOWR(BTRFS_IOCTL_MAGIC, 32, \
899 struct btrfs_ioctl_balance_args)
900 #define BTRFS_IOC_BALANCE_CTL _IOW(BTRFS_IOCTL_MAGIC, 33, int)
901 #define BTRFS_IOC_BALANCE_PROGRESS _IOR(BTRFS_IOCTL_MAGIC, 34, \
902 struct btrfs_ioctl_balance_args)
903 #define BTRFS_IOC_INO_PATHS _IOWR(BTRFS_IOCTL_MAGIC, 35, \
904 struct btrfs_ioctl_ino_path_args)
905 #define BTRFS_IOC_LOGICAL_INO _IOWR(BTRFS_IOCTL_MAGIC, 36, \
906 struct btrfs_ioctl_logical_ino_args)
907 #define BTRFS_IOC_SET_RECEIVED_SUBVOL _IOWR(BTRFS_IOCTL_MAGIC, 37, \
908 struct btrfs_ioctl_received_subvol_args)
909 #define BTRFS_IOC_SEND _IOW(BTRFS_IOCTL_MAGIC, 38, struct btrfs_ioctl_send_args)
910 #define BTRFS_IOC_DEVICES_READY _IOR(BTRFS_IOCTL_MAGIC, 39, \
911 struct btrfs_ioctl_vol_args)
912 #define BTRFS_IOC_QUOTA_CTL _IOWR(BTRFS_IOCTL_MAGIC, 40, \
913 struct btrfs_ioctl_quota_ctl_args)
914 #define BTRFS_IOC_QGROUP_ASSIGN _IOW(BTRFS_IOCTL_MAGIC, 41, \
915 struct btrfs_ioctl_qgroup_assign_args)
916 #define BTRFS_IOC_QGROUP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 42, \
917 struct btrfs_ioctl_qgroup_create_args)
918 #define BTRFS_IOC_QGROUP_LIMIT _IOR(BTRFS_IOCTL_MAGIC, 43, \
919 struct btrfs_ioctl_qgroup_limit_args)
920 #define BTRFS_IOC_QUOTA_RESCAN _IOW(BTRFS_IOCTL_MAGIC, 44, \
921 struct btrfs_ioctl_quota_rescan_args)
922 #define BTRFS_IOC_QUOTA_RESCAN_STATUS _IOR(BTRFS_IOCTL_MAGIC, 45, \
923 struct btrfs_ioctl_quota_rescan_args)
924 #define BTRFS_IOC_QUOTA_RESCAN_WAIT _IO(BTRFS_IOCTL_MAGIC, 46)
925 #define BTRFS_IOC_GET_FSLABEL FS_IOC_GETFSLABEL
926 #define BTRFS_IOC_SET_FSLABEL FS_IOC_SETFSLABEL
927 #define BTRFS_IOC_GET_DEV_STATS _IOWR(BTRFS_IOCTL_MAGIC, 52, \
928 struct btrfs_ioctl_get_dev_stats)
929 #define BTRFS_IOC_DEV_REPLACE _IOWR(BTRFS_IOCTL_MAGIC, 53, \
930 struct btrfs_ioctl_dev_replace_args)
931 #define BTRFS_IOC_FILE_EXTENT_SAME _IOWR(BTRFS_IOCTL_MAGIC, 54, \
932 struct btrfs_ioctl_same_args)
933 #define BTRFS_IOC_GET_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, \
934 struct btrfs_ioctl_feature_flags)
935 #define BTRFS_IOC_SET_FEATURES _IOW(BTRFS_IOCTL_MAGIC, 57, \
936 struct btrfs_ioctl_feature_flags[2])
937 #define BTRFS_IOC_GET_SUPPORTED_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, \
938 struct btrfs_ioctl_feature_flags[3])
939 #define BTRFS_IOC_RM_DEV_V2 _IOW(BTRFS_IOCTL_MAGIC, 58, \
940 struct btrfs_ioctl_vol_args_v2)
941 #define BTRFS_IOC_LOGICAL_INO_V2 _IOWR(BTRFS_IOCTL_MAGIC, 59, \
942 struct btrfs_ioctl_logical_ino_args)
943 #define BTRFS_IOC_GET_SUBVOL_INFO _IOR(BTRFS_IOCTL_MAGIC, 60, \
944 struct btrfs_ioctl_get_subvol_info_args)
945 #define BTRFS_IOC_GET_SUBVOL_ROOTREF _IOWR(BTRFS_IOCTL_MAGIC, 61, \
946 struct btrfs_ioctl_get_subvol_rootref_args)
947 #define BTRFS_IOC_INO_LOOKUP_USER _IOWR(BTRFS_IOCTL_MAGIC, 62, \
948 struct btrfs_ioctl_ino_lookup_user_args)
950 #endif /* _UAPI_LINUX_BTRFS_H */