Print the root generation in btrfs-debug-tree
[btrfs-progs-unstable/devel.git] / ioctl.h
bloba391695cc4f1f675fda4b3070630346901cb0d5e
1 /*
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.
19 #ifndef __IOCTL_
20 #define __IOCTL_
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 {
30 __s64 fd;
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 {
38 __s64 fd;
39 __u64 transid;
40 __u64 flags;
41 __u64 unused[4];
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;
53 __u64 read_errors;
54 __u64 csum_errors;
55 __u64 verify_errors;
56 __u64 no_csum;
57 __u64 csum_discards;
58 __u64 super_errors;
59 __u64 malloc_errors;
60 __u64 uncorrectable_errors;
61 __u64 corrected_errors;
62 __u64 last_physical;
63 __u64 unverified_errors;
66 #define BTRFS_SCRUB_READONLY 1
67 struct btrfs_ioctl_scrub_args {
68 __u64 devid; /* in */
69 __u64 start; /* in */
70 __u64 end; /* in */
71 __u64 flags; /* in */
72 struct btrfs_scrub_progress progress; /* out */
73 /* pad to 1k */
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 */
96 __u64 tree_id;
98 /* keys returned will be >= min and <= max */
99 __u64 min_objectid;
100 __u64 max_objectid;
102 /* keys returned will be >= min and <= max */
103 __u64 min_offset;
104 __u64 max_offset;
106 /* max and min transids to search for */
107 __u64 min_transid;
108 __u64 max_transid;
110 /* keys returned will be >= min and <= max */
111 __u32 min_type;
112 __u32 max_type;
115 * how many items did userland ask for, and how many are we
116 * returning
118 __u32 nr_items;
120 /* align to 64 bits */
121 __u32 unused;
123 /* some extra for later */
124 __u64 unused1;
125 __u64 unused2;
126 __u64 unused3;
127 __u64 unused4;
130 struct btrfs_ioctl_search_header {
131 __u64 transid;
132 __u64 objectid;
133 __u64 offset;
134 __u32 type;
135 __u32 len;
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 {
151 __u64 treeid;
152 __u64 objectid;
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 */
162 __u64 start;
164 /* number of bytes to defrag, use (u64)-1 to say all */
165 __u64 len;
168 * flags for the operation, which can include turning
169 * on compression for this one defrag
171 __u64 flags;
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
178 __u32 extent_thresh;
181 * which compression method to use if turning on compression
182 * for this defrag operation. If unspecified, zlib will
183 * be used
185 __u32 compress_type;
187 /* spare for later */
188 __u32 unused[4];
191 struct btrfs_ioctl_space_info {
192 __u64 flags;
193 __u64 total_bytes;
194 __u64 used_bytes;
197 struct btrfs_ioctl_space_args {
198 __u64 space_slots;
199 __u64 total_spaces;
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)
252 #endif