2 * Copyright (C) 2007 Oracle. All rights reserved.
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.
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.
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.
21 #include <asm/types.h>
22 #include <linux/ioctl.h>
24 #define BTRFS_IOCTL_MAGIC 0x94
25 #define BTRFS_VOL_NAME_MAX 255
27 /* this should be 4k */
28 #define BTRFS_PATH_NAME_MAX 4087
29 struct btrfs_ioctl_vol_args {
31 char name[BTRFS_PATH_NAME_MAX + 1];
34 #define BTRFS_SUBVOL_RDONLY (1ULL << 1)
35 #define BTRFS_SUBVOL_NAME_MAX 4039
37 struct btrfs_ioctl_vol_args_v2 {
42 char name[BTRFS_SUBVOL_NAME_MAX + 1];
45 #define BTRFS_FSID_SIZE 16
46 #define BTRFS_UUID_SIZE 16
48 struct btrfs_scrub_progress {
49 __u64 data_extents_scrubbed;
50 __u64 tree_extents_scrubbed;
51 __u64 data_bytes_scrubbed;
52 __u64 tree_bytes_scrubbed;
60 __u64 uncorrectable_errors;
61 __u64 corrected_errors;
63 __u64 unverified_errors;
66 #define BTRFS_SCRUB_READONLY 1
67 struct btrfs_ioctl_scrub_args {
72 struct btrfs_scrub_progress progress; /* out */
74 __u64 unused[(1024-32-sizeof(struct btrfs_scrub_progress))/8];
77 #define BTRFS_DEVICE_PATH_NAME_MAX 1024
78 struct btrfs_ioctl_dev_info_args {
79 __u64 devid; /* in/out */
80 __u8 uuid[BTRFS_UUID_SIZE]; /* in/out */
81 __u64 bytes_used; /* out */
82 __u64 total_bytes; /* out */
83 __u64 unused[379]; /* pad to 4k */
84 __u8 path[BTRFS_DEVICE_PATH_NAME_MAX]; /* out */
87 struct btrfs_ioctl_fs_info_args {
88 __u64 max_id; /* out */
89 __u64 num_devices; /* out */
90 __u8 fsid[BTRFS_FSID_SIZE]; /* out */
91 __u64 reserved[124]; /* pad to 1k */
94 struct btrfs_ioctl_search_key {
95 /* which root are we searching. 0 is the tree of tree roots */
98 /* keys returned will be >= min and <= max */
102 /* keys returned will be >= min and <= max */
106 /* max and min transids to search for */
110 /* keys returned will be >= min and <= max */
115 * how many items did userland ask for, and how many are we
120 /* align to 64 bits */
123 /* some extra for later */
130 struct btrfs_ioctl_search_header {
136 } __attribute__((may_alias));
138 #define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key))
140 * the buf is an array of search headers where
141 * each header is followed by the actual item
142 * the type field is expanded to 32 bits for alignment
144 struct btrfs_ioctl_search_args {
145 struct btrfs_ioctl_search_key key;
146 char buf[BTRFS_SEARCH_ARGS_BUFSIZE];
149 #define BTRFS_INO_LOOKUP_PATH_MAX 4080
150 struct btrfs_ioctl_ino_lookup_args {
153 char name[BTRFS_INO_LOOKUP_PATH_MAX];
156 /* flags for the defrag range ioctl */
157 #define BTRFS_DEFRAG_RANGE_COMPRESS 1
158 #define BTRFS_DEFRAG_RANGE_START_IO 2
160 struct btrfs_ioctl_defrag_range_args {
161 /* start of the defrag operation */
164 /* number of bytes to defrag, use (u64)-1 to say all */
168 * flags for the operation, which can include turning
169 * on compression for this one defrag
174 * any extent bigger than this will be considered
175 * already defragged. Use 0 to take the kernel default
176 * Use 1 to say every single extent must be rewritten
181 * which compression method to use if turning on compression
182 * for this defrag operation. If unspecified, zlib will
187 /* spare for later */
191 struct btrfs_ioctl_space_info {
197 struct btrfs_ioctl_space_args {
200 struct btrfs_ioctl_space_info spaces[0];
203 struct btrfs_data_container {
204 __u32 bytes_left; /* out -- bytes not needed to deliver output */
205 __u32 bytes_missing; /* out -- additional bytes needed for result */
206 __u32 elem_cnt; /* out */
207 __u32 elem_missed; /* out */
208 __u64 val[0]; /* out */
211 struct btrfs_ioctl_ino_path_args {
215 /* struct btrfs_data_container *fspath; out */
216 __u64 fspath; /* out */
219 struct btrfs_ioctl_logical_ino_args {
220 __u64 logical; /* in */
223 /* struct btrfs_data_container *inodes; out */
227 /* BTRFS_IOC_SNAP_CREATE is no longer used by the btrfs command */
228 #define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, \
229 struct btrfs_ioctl_vol_args)
230 #define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \
231 struct btrfs_ioctl_vol_args)
232 #define BTRFS_IOC_RESIZE _IOW(BTRFS_IOCTL_MAGIC, 3, \
233 struct btrfs_ioctl_vol_args)
234 #define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, \
235 struct btrfs_ioctl_vol_args)
236 /* trans start and trans end are dangerous, and only for
237 * use by applications that know how to avoid the
238 * resulting deadlocks
240 #define BTRFS_IOC_TRANS_START _IO(BTRFS_IOCTL_MAGIC, 6)
241 #define BTRFS_IOC_TRANS_END _IO(BTRFS_IOCTL_MAGIC, 7)
242 #define BTRFS_IOC_SYNC _IO(BTRFS_IOCTL_MAGIC, 8)
244 #define BTRFS_IOC_CLONE _IOW(BTRFS_IOCTL_MAGIC, 9, int)
245 #define BTRFS_IOC_ADD_DEV _IOW(BTRFS_IOCTL_MAGIC, 10, \
246 struct btrfs_ioctl_vol_args)
247 #define BTRFS_IOC_RM_DEV _IOW(BTRFS_IOCTL_MAGIC, 11, \
248 struct btrfs_ioctl_vol_args)
249 #define BTRFS_IOC_BALANCE _IOW(BTRFS_IOCTL_MAGIC, 12, \
250 struct btrfs_ioctl_vol_args)
251 /* 13 is for CLONE_RANGE */
252 #define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \
253 struct btrfs_ioctl_vol_args)
254 #define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, \
255 struct btrfs_ioctl_vol_args)
256 #define BTRFS_IOC_DEFRAG_RANGE _IOW(BTRFS_IOCTL_MAGIC, 16, \
257 struct btrfs_ioctl_defrag_range_args)
258 #define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \
259 struct btrfs_ioctl_search_args)
260 #define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, \
261 struct btrfs_ioctl_ino_lookup_args)
262 #define BTRFS_IOC_DEFAULT_SUBVOL _IOW(BTRFS_IOCTL_MAGIC, 19, u64)
263 #define BTRFS_IOC_SPACE_INFO _IOWR(BTRFS_IOCTL_MAGIC, 20, \
264 struct btrfs_ioctl_space_args)
265 #define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \
266 struct btrfs_ioctl_vol_args_v2)
267 #define BTRFS_IOC_SCRUB _IOWR(BTRFS_IOCTL_MAGIC, 27, \
268 struct btrfs_ioctl_scrub_args)
269 #define BTRFS_IOC_SCRUB_CANCEL _IO(BTRFS_IOCTL_MAGIC, 28)
270 #define BTRFS_IOC_SCRUB_PROGRESS _IOWR(BTRFS_IOCTL_MAGIC, 29, \
271 struct btrfs_ioctl_scrub_args)
272 #define BTRFS_IOC_DEV_INFO _IOWR(BTRFS_IOCTL_MAGIC, 30, \
273 struct btrfs_ioctl_dev_info_args)
274 #define BTRFS_IOC_FS_INFO _IOR(BTRFS_IOCTL_MAGIC, 31, \
275 struct btrfs_ioctl_fs_info_args)
276 #define BTRFS_IOC_INO_PATHS _IOWR(BTRFS_IOCTL_MAGIC, 35, \
277 struct btrfs_ioctl_ino_path_args)
278 #define BTRFS_IOC_LOGICAL_INO _IOWR(BTRFS_IOCTL_MAGIC, 36, \
279 struct btrfs_ioctl_ino_path_args)