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 /* BTRFS_IOC_SNAP_CREATE is no longer used by the btrfs command */
204 #define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, \
205 struct btrfs_ioctl_vol_args)
206 #define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \
207 struct btrfs_ioctl_vol_args)
208 #define BTRFS_IOC_RESIZE _IOW(BTRFS_IOCTL_MAGIC, 3, \
209 struct btrfs_ioctl_vol_args)
210 #define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, \
211 struct btrfs_ioctl_vol_args)
212 /* trans start and trans end are dangerous, and only for
213 * use by applications that know how to avoid the
214 * resulting deadlocks
216 #define BTRFS_IOC_TRANS_START _IO(BTRFS_IOCTL_MAGIC, 6)
217 #define BTRFS_IOC_TRANS_END _IO(BTRFS_IOCTL_MAGIC, 7)
218 #define BTRFS_IOC_SYNC _IO(BTRFS_IOCTL_MAGIC, 8)
220 #define BTRFS_IOC_CLONE _IOW(BTRFS_IOCTL_MAGIC, 9, int)
221 #define BTRFS_IOC_ADD_DEV _IOW(BTRFS_IOCTL_MAGIC, 10, \
222 struct btrfs_ioctl_vol_args)
223 #define BTRFS_IOC_RM_DEV _IOW(BTRFS_IOCTL_MAGIC, 11, \
224 struct btrfs_ioctl_vol_args)
225 #define BTRFS_IOC_BALANCE _IOW(BTRFS_IOCTL_MAGIC, 12, \
226 struct btrfs_ioctl_vol_args)
227 /* 13 is for CLONE_RANGE */
228 #define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \
229 struct btrfs_ioctl_vol_args)
230 #define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, \
231 struct btrfs_ioctl_vol_args)
232 #define BTRFS_IOC_DEFRAG_RANGE _IOW(BTRFS_IOCTL_MAGIC, 16, \
233 struct btrfs_ioctl_defrag_range_args)
234 #define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \
235 struct btrfs_ioctl_search_args)
236 #define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, \
237 struct btrfs_ioctl_ino_lookup_args)
238 #define BTRFS_IOC_DEFAULT_SUBVOL _IOW(BTRFS_IOCTL_MAGIC, 19, u64)
239 #define BTRFS_IOC_SPACE_INFO _IOWR(BTRFS_IOCTL_MAGIC, 20, \
240 struct btrfs_ioctl_space_args)
241 #define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \
242 struct btrfs_ioctl_vol_args_v2)
243 #define BTRFS_IOC_SCRUB _IOWR(BTRFS_IOCTL_MAGIC, 27, \
244 struct btrfs_ioctl_scrub_args)
245 #define BTRFS_IOC_SCRUB_CANCEL _IO(BTRFS_IOCTL_MAGIC, 28)
246 #define BTRFS_IOC_SCRUB_PROGRESS _IOWR(BTRFS_IOCTL_MAGIC, 29, \
247 struct btrfs_ioctl_scrub_args)
248 #define BTRFS_IOC_DEV_INFO _IOWR(BTRFS_IOCTL_MAGIC, 30, \
249 struct btrfs_ioctl_dev_info_args)
250 #define BTRFS_IOC_FS_INFO _IOR(BTRFS_IOCTL_MAGIC, 31, \
251 struct btrfs_ioctl_fs_info_args)