blob: 8e3c6fe9fa5cb6f4e2ba46dad88a8302023f97a6 [file] [log] [blame]
Colin Cross07a58322022-02-08 19:45:27 -08001/****************************************************************************
2 ****************************************************************************
3 ***
4 *** This header was automatically generated from a Linux kernel header
5 *** of the same name, to make information necessary for userspace to
6 *** call into the kernel available to libc. It contains only constants,
7 *** structures, and macros generated from the original header, and thus,
8 *** contains no copyrightable information.
9 ***
10 *** To edit the content of this header, modify the corresponding
11 *** source file (e.g. under external/kernel-headers/original/) then
12 *** run bionic/libc/kernel/tools/update_all.py
13 ***
14 *** Any manual change here will be lost the next time this script will
15 *** be run. You've been warned!
16 ***
17 ****************************************************************************
18 ****************************************************************************/
19#ifndef _BTRFS_CTREE_H_
20#define _BTRFS_CTREE_H_
21#include <linux/btrfs.h>
22#include <linux/types.h>
23#include <stddef.h>
24#define BTRFS_ROOT_TREE_OBJECTID 1ULL
25#define BTRFS_EXTENT_TREE_OBJECTID 2ULL
26#define BTRFS_CHUNK_TREE_OBJECTID 3ULL
27#define BTRFS_DEV_TREE_OBJECTID 4ULL
28#define BTRFS_FS_TREE_OBJECTID 5ULL
29#define BTRFS_ROOT_TREE_DIR_OBJECTID 6ULL
30#define BTRFS_CSUM_TREE_OBJECTID 7ULL
31#define BTRFS_QUOTA_TREE_OBJECTID 8ULL
32#define BTRFS_UUID_TREE_OBJECTID 9ULL
33#define BTRFS_FREE_SPACE_TREE_OBJECTID 10ULL
Jordan Demeulenaere2d505822022-08-11 17:20:14 +020034#define BTRFS_BLOCK_GROUP_TREE_OBJECTID 11ULL
Colin Cross07a58322022-02-08 19:45:27 -080035#define BTRFS_DEV_STATS_OBJECTID 0ULL
36#define BTRFS_BALANCE_OBJECTID - 4ULL
37#define BTRFS_ORPHAN_OBJECTID - 5ULL
38#define BTRFS_TREE_LOG_OBJECTID - 6ULL
39#define BTRFS_TREE_LOG_FIXUP_OBJECTID - 7ULL
40#define BTRFS_TREE_RELOC_OBJECTID - 8ULL
41#define BTRFS_DATA_RELOC_TREE_OBJECTID - 9ULL
42#define BTRFS_EXTENT_CSUM_OBJECTID - 10ULL
43#define BTRFS_FREE_SPACE_OBJECTID - 11ULL
44#define BTRFS_FREE_INO_OBJECTID - 12ULL
45#define BTRFS_MULTIPLE_OBJECTIDS - 255ULL
46#define BTRFS_FIRST_FREE_OBJECTID 256ULL
47#define BTRFS_LAST_FREE_OBJECTID - 256ULL
48#define BTRFS_FIRST_CHUNK_TREE_OBJECTID 256ULL
49#define BTRFS_DEV_ITEMS_OBJECTID 1ULL
50#define BTRFS_BTREE_INODE_OBJECTID 1
51#define BTRFS_EMPTY_SUBVOL_DIR_OBJECTID 2
52#define BTRFS_DEV_REPLACE_DEVID 0ULL
53#define BTRFS_INODE_ITEM_KEY 1
54#define BTRFS_INODE_REF_KEY 12
55#define BTRFS_INODE_EXTREF_KEY 13
56#define BTRFS_XATTR_ITEM_KEY 24
57#define BTRFS_VERITY_DESC_ITEM_KEY 36
58#define BTRFS_VERITY_MERKLE_ITEM_KEY 37
59#define BTRFS_ORPHAN_ITEM_KEY 48
60#define BTRFS_DIR_LOG_ITEM_KEY 60
61#define BTRFS_DIR_LOG_INDEX_KEY 72
62#define BTRFS_DIR_ITEM_KEY 84
63#define BTRFS_DIR_INDEX_KEY 96
64#define BTRFS_EXTENT_DATA_KEY 108
65#define BTRFS_EXTENT_CSUM_KEY 128
66#define BTRFS_ROOT_ITEM_KEY 132
67#define BTRFS_ROOT_BACKREF_KEY 144
68#define BTRFS_ROOT_REF_KEY 156
69#define BTRFS_EXTENT_ITEM_KEY 168
70#define BTRFS_METADATA_ITEM_KEY 169
71#define BTRFS_TREE_BLOCK_REF_KEY 176
72#define BTRFS_EXTENT_DATA_REF_KEY 178
73#define BTRFS_EXTENT_REF_V0_KEY 180
74#define BTRFS_SHARED_BLOCK_REF_KEY 182
75#define BTRFS_SHARED_DATA_REF_KEY 184
76#define BTRFS_BLOCK_GROUP_ITEM_KEY 192
77#define BTRFS_FREE_SPACE_INFO_KEY 198
78#define BTRFS_FREE_SPACE_EXTENT_KEY 199
79#define BTRFS_FREE_SPACE_BITMAP_KEY 200
80#define BTRFS_DEV_EXTENT_KEY 204
81#define BTRFS_DEV_ITEM_KEY 216
82#define BTRFS_CHUNK_ITEM_KEY 228
83#define BTRFS_QGROUP_STATUS_KEY 240
84#define BTRFS_QGROUP_INFO_KEY 242
85#define BTRFS_QGROUP_LIMIT_KEY 244
86#define BTRFS_QGROUP_RELATION_KEY 246
87#define BTRFS_BALANCE_ITEM_KEY 248
88#define BTRFS_TEMPORARY_ITEM_KEY 248
89#define BTRFS_DEV_STATS_KEY 249
90#define BTRFS_PERSISTENT_ITEM_KEY 249
91#define BTRFS_DEV_REPLACE_KEY 250
92#if BTRFS_UUID_SIZE != 16
93#error "UUID items require BTRFS_UUID_SIZE == 16!"
94#endif
95#define BTRFS_UUID_KEY_SUBVOL 251
96#define BTRFS_UUID_KEY_RECEIVED_SUBVOL 252
97#define BTRFS_STRING_ITEM_KEY 253
98#define BTRFS_MAX_METADATA_BLOCKSIZE 65536
99#define BTRFS_CSUM_SIZE 32
100enum btrfs_csum_type {
101 BTRFS_CSUM_TYPE_CRC32 = 0,
102 BTRFS_CSUM_TYPE_XXHASH = 1,
103 BTRFS_CSUM_TYPE_SHA256 = 2,
104 BTRFS_CSUM_TYPE_BLAKE2 = 3,
105};
106#define BTRFS_FT_UNKNOWN 0
107#define BTRFS_FT_REG_FILE 1
108#define BTRFS_FT_DIR 2
109#define BTRFS_FT_CHRDEV 3
110#define BTRFS_FT_BLKDEV 4
111#define BTRFS_FT_FIFO 5
112#define BTRFS_FT_SOCK 6
113#define BTRFS_FT_SYMLINK 7
114#define BTRFS_FT_XATTR 8
115#define BTRFS_FT_MAX 9
116struct btrfs_disk_key {
117 __le64 objectid;
118 __u8 type;
119 __le64 offset;
120} __attribute__((__packed__));
121struct btrfs_key {
122 __u64 objectid;
123 __u8 type;
124 __u64 offset;
125} __attribute__((__packed__));
126struct btrfs_dev_item {
127 __le64 devid;
128 __le64 total_bytes;
129 __le64 bytes_used;
130 __le32 io_align;
131 __le32 io_width;
132 __le32 sector_size;
133 __le64 type;
134 __le64 generation;
135 __le64 start_offset;
136 __le32 dev_group;
137 __u8 seek_speed;
138 __u8 bandwidth;
139 __u8 uuid[BTRFS_UUID_SIZE];
140 __u8 fsid[BTRFS_UUID_SIZE];
141} __attribute__((__packed__));
142struct btrfs_stripe {
143 __le64 devid;
144 __le64 offset;
145 __u8 dev_uuid[BTRFS_UUID_SIZE];
146} __attribute__((__packed__));
147struct btrfs_chunk {
148 __le64 length;
149 __le64 owner;
150 __le64 stripe_len;
151 __le64 type;
152 __le32 io_align;
153 __le32 io_width;
154 __le32 sector_size;
155 __le16 num_stripes;
156 __le16 sub_stripes;
157 struct btrfs_stripe stripe;
158} __attribute__((__packed__));
159#define BTRFS_FREE_SPACE_EXTENT 1
160#define BTRFS_FREE_SPACE_BITMAP 2
161struct btrfs_free_space_entry {
162 __le64 offset;
163 __le64 bytes;
164 __u8 type;
165} __attribute__((__packed__));
166struct btrfs_free_space_header {
167 struct btrfs_disk_key location;
168 __le64 generation;
169 __le64 num_entries;
170 __le64 num_bitmaps;
171} __attribute__((__packed__));
172#define BTRFS_HEADER_FLAG_WRITTEN (1ULL << 0)
173#define BTRFS_HEADER_FLAG_RELOC (1ULL << 1)
174#define BTRFS_SUPER_FLAG_ERROR (1ULL << 2)
175#define BTRFS_SUPER_FLAG_SEEDING (1ULL << 32)
176#define BTRFS_SUPER_FLAG_METADUMP (1ULL << 33)
177#define BTRFS_SUPER_FLAG_METADUMP_V2 (1ULL << 34)
178#define BTRFS_SUPER_FLAG_CHANGING_FSID (1ULL << 35)
179#define BTRFS_SUPER_FLAG_CHANGING_FSID_V2 (1ULL << 36)
180struct btrfs_extent_item {
181 __le64 refs;
182 __le64 generation;
183 __le64 flags;
184} __attribute__((__packed__));
185struct btrfs_extent_item_v0 {
186 __le32 refs;
187} __attribute__((__packed__));
188#define BTRFS_EXTENT_FLAG_DATA (1ULL << 0)
189#define BTRFS_EXTENT_FLAG_TREE_BLOCK (1ULL << 1)
190#define BTRFS_BLOCK_FLAG_FULL_BACKREF (1ULL << 8)
191#define BTRFS_EXTENT_FLAG_SUPER (1ULL << 48)
192struct btrfs_tree_block_info {
193 struct btrfs_disk_key key;
194 __u8 level;
195} __attribute__((__packed__));
196struct btrfs_extent_data_ref {
197 __le64 root;
198 __le64 objectid;
199 __le64 offset;
200 __le32 count;
201} __attribute__((__packed__));
202struct btrfs_shared_data_ref {
203 __le32 count;
204} __attribute__((__packed__));
205struct btrfs_extent_inline_ref {
206 __u8 type;
207 __le64 offset;
208} __attribute__((__packed__));
209struct btrfs_dev_extent {
210 __le64 chunk_tree;
211 __le64 chunk_objectid;
212 __le64 chunk_offset;
213 __le64 length;
214 __u8 chunk_tree_uuid[BTRFS_UUID_SIZE];
215} __attribute__((__packed__));
216struct btrfs_inode_ref {
217 __le64 index;
218 __le16 name_len;
219} __attribute__((__packed__));
220struct btrfs_inode_extref {
221 __le64 parent_objectid;
222 __le64 index;
223 __le16 name_len;
224 __u8 name[0];
225} __attribute__((__packed__));
226struct btrfs_timespec {
227 __le64 sec;
228 __le32 nsec;
229} __attribute__((__packed__));
230struct btrfs_inode_item {
231 __le64 generation;
232 __le64 transid;
233 __le64 size;
234 __le64 nbytes;
235 __le64 block_group;
236 __le32 nlink;
237 __le32 uid;
238 __le32 gid;
239 __le32 mode;
240 __le64 rdev;
241 __le64 flags;
242 __le64 sequence;
243 __le64 reserved[4];
244 struct btrfs_timespec atime;
245 struct btrfs_timespec ctime;
246 struct btrfs_timespec mtime;
247 struct btrfs_timespec otime;
248} __attribute__((__packed__));
249struct btrfs_dir_log_item {
250 __le64 end;
251} __attribute__((__packed__));
252struct btrfs_dir_item {
253 struct btrfs_disk_key location;
254 __le64 transid;
255 __le16 data_len;
256 __le16 name_len;
257 __u8 type;
258} __attribute__((__packed__));
259#define BTRFS_ROOT_SUBVOL_RDONLY (1ULL << 0)
260#define BTRFS_ROOT_SUBVOL_DEAD (1ULL << 48)
261struct btrfs_root_item {
262 struct btrfs_inode_item inode;
263 __le64 generation;
264 __le64 root_dirid;
265 __le64 bytenr;
266 __le64 byte_limit;
267 __le64 bytes_used;
268 __le64 last_snapshot;
269 __le64 flags;
270 __le32 refs;
271 struct btrfs_disk_key drop_progress;
272 __u8 drop_level;
273 __u8 level;
274 __le64 generation_v2;
275 __u8 uuid[BTRFS_UUID_SIZE];
276 __u8 parent_uuid[BTRFS_UUID_SIZE];
277 __u8 received_uuid[BTRFS_UUID_SIZE];
278 __le64 ctransid;
279 __le64 otransid;
280 __le64 stransid;
281 __le64 rtransid;
282 struct btrfs_timespec ctime;
283 struct btrfs_timespec otime;
284 struct btrfs_timespec stime;
285 struct btrfs_timespec rtime;
286 __le64 reserved[8];
287} __attribute__((__packed__));
288struct btrfs_root_ref {
289 __le64 dirid;
290 __le64 sequence;
291 __le16 name_len;
292} __attribute__((__packed__));
293struct btrfs_disk_balance_args {
294 __le64 profiles;
295 union {
296 __le64 usage;
297 struct {
298 __le32 usage_min;
299 __le32 usage_max;
300 };
301 };
302 __le64 devid;
303 __le64 pstart;
304 __le64 pend;
305 __le64 vstart;
306 __le64 vend;
307 __le64 target;
308 __le64 flags;
309 union {
310 __le64 limit;
311 struct {
312 __le32 limit_min;
313 __le32 limit_max;
314 };
315 };
316 __le32 stripes_min;
317 __le32 stripes_max;
318 __le64 unused[6];
319} __attribute__((__packed__));
320struct btrfs_balance_item {
321 __le64 flags;
322 struct btrfs_disk_balance_args data;
323 struct btrfs_disk_balance_args meta;
324 struct btrfs_disk_balance_args sys;
325 __le64 unused[4];
326} __attribute__((__packed__));
327enum {
328 BTRFS_FILE_EXTENT_INLINE = 0,
329 BTRFS_FILE_EXTENT_REG = 1,
330 BTRFS_FILE_EXTENT_PREALLOC = 2,
331 BTRFS_NR_FILE_EXTENT_TYPES = 3,
332};
333struct btrfs_file_extent_item {
334 __le64 generation;
335 __le64 ram_bytes;
336 __u8 compression;
337 __u8 encryption;
338 __le16 other_encoding;
339 __u8 type;
340 __le64 disk_bytenr;
341 __le64 disk_num_bytes;
342 __le64 offset;
343 __le64 num_bytes;
344} __attribute__((__packed__));
345struct btrfs_csum_item {
346 __u8 csum;
347} __attribute__((__packed__));
348struct btrfs_dev_stats_item {
349 __le64 values[BTRFS_DEV_STAT_VALUES_MAX];
350} __attribute__((__packed__));
351#define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_ALWAYS 0
352#define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_AVOID 1
353struct btrfs_dev_replace_item {
354 __le64 src_devid;
355 __le64 cursor_left;
356 __le64 cursor_right;
357 __le64 cont_reading_from_srcdev_mode;
358 __le64 replace_state;
359 __le64 time_started;
360 __le64 time_stopped;
361 __le64 num_write_errors;
362 __le64 num_uncorrectable_read_errors;
363} __attribute__((__packed__));
364#define BTRFS_BLOCK_GROUP_DATA (1ULL << 0)
365#define BTRFS_BLOCK_GROUP_SYSTEM (1ULL << 1)
366#define BTRFS_BLOCK_GROUP_METADATA (1ULL << 2)
367#define BTRFS_BLOCK_GROUP_RAID0 (1ULL << 3)
368#define BTRFS_BLOCK_GROUP_RAID1 (1ULL << 4)
369#define BTRFS_BLOCK_GROUP_DUP (1ULL << 5)
370#define BTRFS_BLOCK_GROUP_RAID10 (1ULL << 6)
371#define BTRFS_BLOCK_GROUP_RAID5 (1ULL << 7)
372#define BTRFS_BLOCK_GROUP_RAID6 (1ULL << 8)
373#define BTRFS_BLOCK_GROUP_RAID1C3 (1ULL << 9)
374#define BTRFS_BLOCK_GROUP_RAID1C4 (1ULL << 10)
375#define BTRFS_BLOCK_GROUP_RESERVED (BTRFS_AVAIL_ALLOC_BIT_SINGLE | BTRFS_SPACE_INFO_GLOBAL_RSV)
376enum btrfs_raid_types {
377 BTRFS_RAID_RAID10,
378 BTRFS_RAID_RAID1,
379 BTRFS_RAID_DUP,
380 BTRFS_RAID_RAID0,
381 BTRFS_RAID_SINGLE,
382 BTRFS_RAID_RAID5,
383 BTRFS_RAID_RAID6,
384 BTRFS_RAID_RAID1C3,
385 BTRFS_RAID_RAID1C4,
386 BTRFS_NR_RAID_TYPES
387};
388#define BTRFS_BLOCK_GROUP_TYPE_MASK (BTRFS_BLOCK_GROUP_DATA | BTRFS_BLOCK_GROUP_SYSTEM | BTRFS_BLOCK_GROUP_METADATA)
389#define BTRFS_BLOCK_GROUP_PROFILE_MASK (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1 | BTRFS_BLOCK_GROUP_RAID1C3 | BTRFS_BLOCK_GROUP_RAID1C4 | BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6 | BTRFS_BLOCK_GROUP_DUP | BTRFS_BLOCK_GROUP_RAID10)
390#define BTRFS_BLOCK_GROUP_RAID56_MASK (BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6)
391#define BTRFS_BLOCK_GROUP_RAID1_MASK (BTRFS_BLOCK_GROUP_RAID1 | BTRFS_BLOCK_GROUP_RAID1C3 | BTRFS_BLOCK_GROUP_RAID1C4)
392#define BTRFS_AVAIL_ALLOC_BIT_SINGLE (1ULL << 48)
393#define BTRFS_SPACE_INFO_GLOBAL_RSV (1ULL << 49)
394#define BTRFS_EXTENDED_PROFILE_MASK (BTRFS_BLOCK_GROUP_PROFILE_MASK | BTRFS_AVAIL_ALLOC_BIT_SINGLE)
395struct btrfs_block_group_item {
396 __le64 used;
397 __le64 chunk_objectid;
398 __le64 flags;
399} __attribute__((__packed__));
400struct btrfs_free_space_info {
401 __le32 extent_count;
402 __le32 flags;
403} __attribute__((__packed__));
404#define BTRFS_FREE_SPACE_USING_BITMAPS (1ULL << 0)
405#define BTRFS_QGROUP_LEVEL_SHIFT 48
406#define BTRFS_QGROUP_STATUS_FLAG_ON (1ULL << 0)
407#define BTRFS_QGROUP_STATUS_FLAG_RESCAN (1ULL << 1)
408#define BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT (1ULL << 2)
409#define BTRFS_QGROUP_STATUS_VERSION 1
410struct btrfs_qgroup_status_item {
411 __le64 version;
412 __le64 generation;
413 __le64 flags;
414 __le64 rescan;
415} __attribute__((__packed__));
416struct btrfs_qgroup_info_item {
417 __le64 generation;
418 __le64 rfer;
419 __le64 rfer_cmpr;
420 __le64 excl;
421 __le64 excl_cmpr;
422} __attribute__((__packed__));
423struct btrfs_qgroup_limit_item {
424 __le64 flags;
425 __le64 max_rfer;
426 __le64 max_excl;
427 __le64 rsv_rfer;
428 __le64 rsv_excl;
429} __attribute__((__packed__));
430struct btrfs_verity_descriptor_item {
431 __le64 size;
432 __le64 reserved[2];
433 __u8 encryption;
434} __attribute__((__packed__));
435#endif