]>
Commit | Line | Data |
---|---|---|
ff462013 SH |
1 | typedef uint8_t u8; |
2 | typedef uint16_t u16; | |
3 | typedef uint32_t u32; | |
4 | typedef uint64_t u64; | |
5 | ||
6 | struct btrfs_ioctl_space_info { | |
7 | unsigned long long flags; | |
8 | unsigned long long total_bytes; | |
9 | unsigned long long used_bytes; | |
10 | }; | |
11 | ||
12 | struct btrfs_ioctl_space_args { | |
13 | unsigned long long space_slots; | |
14 | unsigned long long total_spaces; | |
15 | struct btrfs_ioctl_space_info spaces[0]; | |
16 | }; | |
17 | ||
18 | #define BTRFS_IOCTL_MAGIC 0x94 | |
19 | #define BTRFS_IOC_SUBVOL_GETFLAGS _IOR(BTRFS_IOCTL_MAGIC, 25, unsigned long long) | |
20 | #define BTRFS_IOC_SPACE_INFO _IOWR(BTRFS_IOCTL_MAGIC, 20, \ | |
21 | struct btrfs_ioctl_space_args) | |
22 | ||
23 | #define BTRFS_FSID_SIZE 16 | |
24 | struct btrfs_ioctl_fs_info_args { | |
25 | unsigned long long max_id; | |
26 | unsigned long long num_devices; | |
27 | char fsid[BTRFS_FSID_SIZE]; | |
28 | unsigned long long reserved[124]; | |
29 | }; | |
30 | ||
31 | #define BTRFS_IOC_FS_INFO _IOR(BTRFS_IOCTL_MAGIC, 31, \ | |
32 | struct btrfs_ioctl_fs_info_args) | |
33 | ||
34 | ||
35 | #define BTRFS_SUBVOL_NAME_MAX 4039 | |
36 | #define BTRFS_PATH_NAME_MAX 4087 | |
37 | ||
38 | struct btrfs_ioctl_vol_args { | |
39 | signed long long fd; | |
40 | char name[BTRFS_PATH_NAME_MAX + 1]; | |
41 | }; | |
42 | ||
43 | #define BTRFS_IOCTL_MAGIC 0x94 | |
44 | #define BTRFS_IOC_SUBVOL_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 24, \ | |
45 | struct btrfs_ioctl_vol_args_v2) | |
46 | #define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \ | |
47 | struct btrfs_ioctl_vol_args_v2) | |
48 | #define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \ | |
49 | struct btrfs_ioctl_vol_args) | |
50 | #define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, \ | |
51 | struct btrfs_ioctl_vol_args) | |
52 | ||
53 | #define BTRFS_QGROUP_INHERIT_SET_LIMITS (1ULL << 0) | |
54 | ||
55 | struct btrfs_ioctl_vol_args_v2 { | |
56 | signed long long fd; | |
57 | unsigned long long transid; | |
58 | unsigned long long flags; | |
59 | union { | |
60 | struct { | |
61 | unsigned long long size; | |
62 | //struct btrfs_qgroup_inherit *qgroup_inherit; | |
63 | void *qgroup_inherit; | |
64 | }; | |
65 | unsigned long long unused[4]; | |
66 | }; | |
67 | char name[BTRFS_SUBVOL_NAME_MAX + 1]; | |
68 | }; | |
69 | ||
70 | /* | |
71 | * root backrefs tie subvols and snapshots to the directory entries that | |
72 | * reference them | |
73 | */ | |
74 | #define BTRFS_ROOT_BACKREF_KEY 144 | |
75 | ||
76 | /* | |
77 | * root items point to tree roots. There are typically in the root | |
78 | * tree used by the super block to find all the other trees | |
79 | */ | |
80 | #define BTRFS_ROOT_ITEM_KEY 132 | |
81 | ||
82 | /* | |
83 | * root refs make a fast index for listing all of the snapshots and | |
84 | * subvolumes referenced by a given root. They point directly to the | |
85 | * directory item in the root that references the subvol | |
86 | */ | |
87 | #define BTRFS_ROOT_REF_KEY 156 | |
88 | ||
89 | #define BTRFS_ROOT_TREE_DIR_OBJECTID 6ULL | |
90 | #define BTRFS_DIR_ITEM_KEY 84 | |
91 | ||
92 | /* | |
93 | * * this is used for both forward and backward root refs | |
94 | * */ | |
95 | struct btrfs_root_ref { | |
96 | __le64 dirid; | |
97 | __le64 sequence; | |
98 | __le16 name_len; | |
99 | } __attribute__ ((__packed__)); | |
100 | ||
101 | struct btrfs_disk_key { | |
102 | __le64 objectid; | |
103 | u8 type; | |
104 | __le64 offset; | |
105 | } __attribute__ ((__packed__)); | |
106 | ||
107 | struct btrfs_dir_item { | |
108 | struct btrfs_disk_key location; | |
109 | __le64 transid; | |
110 | __le16 data_len; | |
111 | __le16 name_len; | |
112 | u8 type; | |
113 | } __attribute__ ((__packed__)); | |
114 | ||
115 | #define BTRFS_IOCTL_MAGIC 0x94 | |
116 | #define BTRFS_VOL_NAME_MAX 255 | |
117 | #define BTRFS_PATH_NAME_MAX 4087 | |
118 | ||
119 | struct btrfs_ioctl_search_key { | |
120 | /* which root are we searching. 0 is the tree of tree roots */ | |
121 | __u64 tree_id; | |
122 | ||
123 | /* keys returned will be >= min and <= max */ | |
124 | __u64 min_objectid; | |
125 | __u64 max_objectid; | |
126 | ||
127 | /* keys returned will be >= min and <= max */ | |
128 | __u64 min_offset; | |
129 | __u64 max_offset; | |
130 | ||
131 | /* max and min transids to search for */ | |
132 | __u64 min_transid; | |
133 | __u64 max_transid; | |
134 | ||
135 | /* keys returned will be >= min and <= max */ | |
136 | __u32 min_type; | |
137 | __u32 max_type; | |
138 | ||
139 | /* | |
140 | * how many items did userland ask for, and how many are we | |
141 | * returning | |
142 | */ | |
143 | __u32 nr_items; | |
144 | ||
145 | /* align to 64 bits */ | |
146 | __u32 unused; | |
147 | ||
148 | /* some extra for later */ | |
149 | __u64 unused1; | |
150 | __u64 unused2; | |
151 | __u64 unused3; | |
152 | __u64 unused4; | |
153 | }; | |
154 | ||
155 | struct btrfs_ioctl_search_header { | |
156 | __u64 transid; | |
157 | __u64 objectid; | |
158 | __u64 offset; | |
159 | __u32 type; | |
160 | __u32 len; | |
161 | } __attribute__((may_alias)); | |
162 | ||
163 | #define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key)) | |
164 | /* | |
165 | * the buf is an array of search headers where | |
166 | * each header is followed by the actual item | |
167 | * the type field is expanded to 32 bits for alignment | |
168 | */ | |
169 | struct btrfs_ioctl_search_args { | |
170 | struct btrfs_ioctl_search_key key; | |
171 | char buf[BTRFS_SEARCH_ARGS_BUFSIZE]; | |
172 | }; | |
173 | ||
174 | #define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \ | |
175 | struct btrfs_ioctl_search_args) | |
176 | #define BTRFS_UUID_SIZE 16 | |
177 | ||
178 | struct btrfs_timespec { | |
179 | __le64 sec; | |
180 | __le32 nsec; | |
181 | } __attribute__ ((__packed__)); | |
182 | ||
183 | struct btrfs_inode_item { | |
184 | /* nfs style generation number */ | |
185 | __le64 generation; | |
186 | /* transid that last touched this inode */ | |
187 | __le64 transid; | |
188 | __le64 size; | |
189 | __le64 nbytes; | |
190 | __le64 block_group; | |
191 | __le32 nlink; | |
192 | __le32 uid; | |
193 | __le32 gid; | |
194 | __le32 mode; | |
195 | __le64 rdev; | |
196 | __le64 flags; | |
197 | ||
198 | /* modification sequence number for NFS */ | |
199 | __le64 sequence; | |
200 | ||
201 | /* | |
202 | * a little future expansion, for more than this we can | |
203 | * just grow the inode item and version it | |
204 | */ | |
205 | __le64 reserved[4]; | |
206 | struct btrfs_timespec atime; | |
207 | struct btrfs_timespec ctime; | |
208 | struct btrfs_timespec mtime; | |
209 | struct btrfs_timespec otime; | |
210 | } __attribute__ ((__packed__)); | |
211 | ||
212 | struct btrfs_root_item_v0 { | |
213 | struct btrfs_inode_item inode; | |
214 | __le64 generation; | |
215 | __le64 root_dirid; | |
216 | __le64 bytenr; | |
217 | __le64 byte_limit; | |
218 | __le64 bytes_used; | |
219 | __le64 last_snapshot; | |
220 | __le64 flags; | |
221 | __le32 refs; | |
222 | struct btrfs_disk_key drop_progress; | |
223 | u8 drop_level; | |
224 | u8 level; | |
225 | } __attribute__ ((__packed__)); | |
226 | ||
227 | struct btrfs_root_item { | |
228 | struct btrfs_inode_item inode; | |
229 | __le64 generation; | |
230 | __le64 root_dirid; | |
231 | __le64 bytenr; | |
232 | __le64 byte_limit; | |
233 | __le64 bytes_used; | |
234 | __le64 last_snapshot; | |
235 | __le64 flags; | |
236 | __le32 refs; | |
237 | struct btrfs_disk_key drop_progress; | |
238 | u8 drop_level; | |
239 | u8 level; | |
240 | ||
241 | /* | |
242 | * The following fields appear after subvol_uuids+subvol_times | |
243 | * were introduced. | |
244 | */ | |
245 | ||
246 | /* | |
247 | * This generation number is used to test if the new fields are valid | |
248 | * and up to date while reading the root item. Everytime the root item | |
249 | * is written out, the "generation" field is copied into this field. If | |
250 | * anyone ever mounted the fs with an older kernel, we will have | |
251 | * mismatching generation values here and thus must invalidate the | |
252 | * new fields. See btrfs_update_root and btrfs_find_last_root for | |
253 | * details. | |
254 | * the offset of generation_v2 is also used as the start for the memset | |
255 | * when invalidating the fields. | |
256 | */ | |
257 | __le64 generation_v2; | |
258 | u8 uuid[BTRFS_UUID_SIZE]; | |
259 | u8 parent_uuid[BTRFS_UUID_SIZE]; | |
260 | u8 received_uuid[BTRFS_UUID_SIZE]; | |
261 | __le64 ctransid; /* updated when an inode changes */ | |
262 | __le64 otransid; /* trans when created */ | |
263 | __le64 stransid; /* trans when sent. non-zero for received subvol */ | |
264 | __le64 rtransid; /* trans when received. non-zero for received subvol */ | |
265 | struct btrfs_timespec ctime; | |
266 | struct btrfs_timespec otime; | |
267 | struct btrfs_timespec stime; | |
268 | struct btrfs_timespec rtime; | |
269 | __le64 reserved[8]; /* for future */ | |
270 | } __attribute__ ((__packed__)); | |
271 | ||
272 | #define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, \ | |
273 | struct btrfs_ioctl_ino_lookup_args) | |
274 | ||
275 | #define BTRFS_INO_LOOKUP_PATH_MAX 4080 | |
276 | struct btrfs_ioctl_ino_lookup_args { | |
277 | __u64 treeid; | |
278 | __u64 objectid; | |
279 | char name[BTRFS_INO_LOOKUP_PATH_MAX]; | |
280 | }; | |
281 | ||
282 | /* | |
283 | * All files have objectids in this range. | |
284 | */ | |
285 | #define BTRFS_FIRST_FREE_OBJECTID 256ULL | |
286 | #define BTRFS_LAST_FREE_OBJECTID -256ULL | |
287 | #define BTRFS_FIRST_CHUNK_TREE_OBJECTID 256ULL |