blob: 02422c05a94b222220a39d93d345b05e7416b524 [file] [log] [blame]
Christopher Ferris106b3a82016-08-24 12:15:38 -07001/****************************************************************************
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_
Christopher Ferris525ce912017-07-26 13:12:53 -070021#include <linux/btrfs.h>
22#include <linux/types.h>
Christopher Ferris32ff3f82020-12-14 13:10:04 -080023#include <stddef.h>
Christopher Ferris8b7fdc92023-02-21 13:36:32 -080024#define BTRFS_MAGIC 0x4D5F53665248425FULL
25#define BTRFS_MAX_LEVEL 8
26#define BTRFS_NAME_LEN 255
27#define BTRFS_LINK_MAX 65535U
Christopher Ferris106b3a82016-08-24 12:15:38 -070028#define BTRFS_ROOT_TREE_OBJECTID 1ULL
29#define BTRFS_EXTENT_TREE_OBJECTID 2ULL
Christopher Ferris106b3a82016-08-24 12:15:38 -070030#define BTRFS_CHUNK_TREE_OBJECTID 3ULL
31#define BTRFS_DEV_TREE_OBJECTID 4ULL
32#define BTRFS_FS_TREE_OBJECTID 5ULL
33#define BTRFS_ROOT_TREE_DIR_OBJECTID 6ULL
Christopher Ferris106b3a82016-08-24 12:15:38 -070034#define BTRFS_CSUM_TREE_OBJECTID 7ULL
35#define BTRFS_QUOTA_TREE_OBJECTID 8ULL
36#define BTRFS_UUID_TREE_OBJECTID 9ULL
37#define BTRFS_FREE_SPACE_TREE_OBJECTID 10ULL
Christopher Ferris10a76e62022-06-08 13:31:52 -070038#define BTRFS_BLOCK_GROUP_TREE_OBJECTID 11ULL
Christopher Ferris106b3a82016-08-24 12:15:38 -070039#define BTRFS_DEV_STATS_OBJECTID 0ULL
40#define BTRFS_BALANCE_OBJECTID - 4ULL
41#define BTRFS_ORPHAN_OBJECTID - 5ULL
42#define BTRFS_TREE_LOG_OBJECTID - 6ULL
Christopher Ferris106b3a82016-08-24 12:15:38 -070043#define BTRFS_TREE_LOG_FIXUP_OBJECTID - 7ULL
44#define BTRFS_TREE_RELOC_OBJECTID - 8ULL
45#define BTRFS_DATA_RELOC_TREE_OBJECTID - 9ULL
46#define BTRFS_EXTENT_CSUM_OBJECTID - 10ULL
Christopher Ferris106b3a82016-08-24 12:15:38 -070047#define BTRFS_FREE_SPACE_OBJECTID - 11ULL
48#define BTRFS_FREE_INO_OBJECTID - 12ULL
49#define BTRFS_MULTIPLE_OBJECTIDS - 255ULL
50#define BTRFS_FIRST_FREE_OBJECTID 256ULL
Christopher Ferris106b3a82016-08-24 12:15:38 -070051#define BTRFS_LAST_FREE_OBJECTID - 256ULL
52#define BTRFS_FIRST_CHUNK_TREE_OBJECTID 256ULL
53#define BTRFS_DEV_ITEMS_OBJECTID 1ULL
54#define BTRFS_BTREE_INODE_OBJECTID 1
Christopher Ferris106b3a82016-08-24 12:15:38 -070055#define BTRFS_EMPTY_SUBVOL_DIR_OBJECTID 2
56#define BTRFS_DEV_REPLACE_DEVID 0ULL
57#define BTRFS_INODE_ITEM_KEY 1
58#define BTRFS_INODE_REF_KEY 12
Christopher Ferris106b3a82016-08-24 12:15:38 -070059#define BTRFS_INODE_EXTREF_KEY 13
60#define BTRFS_XATTR_ITEM_KEY 24
Christopher Ferris2abfa9e2021-11-01 16:26:06 -070061#define BTRFS_VERITY_DESC_ITEM_KEY 36
62#define BTRFS_VERITY_MERKLE_ITEM_KEY 37
Christopher Ferris106b3a82016-08-24 12:15:38 -070063#define BTRFS_ORPHAN_ITEM_KEY 48
64#define BTRFS_DIR_LOG_ITEM_KEY 60
Christopher Ferris106b3a82016-08-24 12:15:38 -070065#define BTRFS_DIR_LOG_INDEX_KEY 72
66#define BTRFS_DIR_ITEM_KEY 84
67#define BTRFS_DIR_INDEX_KEY 96
68#define BTRFS_EXTENT_DATA_KEY 108
Christopher Ferris106b3a82016-08-24 12:15:38 -070069#define BTRFS_EXTENT_CSUM_KEY 128
70#define BTRFS_ROOT_ITEM_KEY 132
71#define BTRFS_ROOT_BACKREF_KEY 144
72#define BTRFS_ROOT_REF_KEY 156
Christopher Ferris106b3a82016-08-24 12:15:38 -070073#define BTRFS_EXTENT_ITEM_KEY 168
74#define BTRFS_METADATA_ITEM_KEY 169
75#define BTRFS_TREE_BLOCK_REF_KEY 176
76#define BTRFS_EXTENT_DATA_REF_KEY 178
Christopher Ferris106b3a82016-08-24 12:15:38 -070077#define BTRFS_EXTENT_REF_V0_KEY 180
78#define BTRFS_SHARED_BLOCK_REF_KEY 182
79#define BTRFS_SHARED_DATA_REF_KEY 184
80#define BTRFS_BLOCK_GROUP_ITEM_KEY 192
Christopher Ferris106b3a82016-08-24 12:15:38 -070081#define BTRFS_FREE_SPACE_INFO_KEY 198
82#define BTRFS_FREE_SPACE_EXTENT_KEY 199
83#define BTRFS_FREE_SPACE_BITMAP_KEY 200
84#define BTRFS_DEV_EXTENT_KEY 204
Christopher Ferris106b3a82016-08-24 12:15:38 -070085#define BTRFS_DEV_ITEM_KEY 216
86#define BTRFS_CHUNK_ITEM_KEY 228
87#define BTRFS_QGROUP_STATUS_KEY 240
88#define BTRFS_QGROUP_INFO_KEY 242
Christopher Ferris106b3a82016-08-24 12:15:38 -070089#define BTRFS_QGROUP_LIMIT_KEY 244
90#define BTRFS_QGROUP_RELATION_KEY 246
91#define BTRFS_BALANCE_ITEM_KEY 248
92#define BTRFS_TEMPORARY_ITEM_KEY 248
Christopher Ferris106b3a82016-08-24 12:15:38 -070093#define BTRFS_DEV_STATS_KEY 249
94#define BTRFS_PERSISTENT_ITEM_KEY 249
95#define BTRFS_DEV_REPLACE_KEY 250
96#if BTRFS_UUID_SIZE != 16
Christopher Ferris106b3a82016-08-24 12:15:38 -070097#error "UUID items require BTRFS_UUID_SIZE == 16!"
98#endif
99#define BTRFS_UUID_KEY_SUBVOL 251
100#define BTRFS_UUID_KEY_RECEIVED_SUBVOL 252
Christopher Ferris106b3a82016-08-24 12:15:38 -0700101#define BTRFS_STRING_ITEM_KEY 253
Christopher Ferris05667cd2021-02-16 16:01:34 -0800102#define BTRFS_MAX_METADATA_BLOCKSIZE 65536
Christopher Ferris106b3a82016-08-24 12:15:38 -0700103#define BTRFS_CSUM_SIZE 32
Christopher Ferris9584fa42019-12-09 15:36:13 -0800104enum btrfs_csum_type {
105 BTRFS_CSUM_TYPE_CRC32 = 0,
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800106 BTRFS_CSUM_TYPE_XXHASH = 1,
107 BTRFS_CSUM_TYPE_SHA256 = 2,
108 BTRFS_CSUM_TYPE_BLAKE2 = 3,
Christopher Ferris9584fa42019-12-09 15:36:13 -0800109};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700110#define BTRFS_FT_UNKNOWN 0
Christopher Ferris106b3a82016-08-24 12:15:38 -0700111#define BTRFS_FT_REG_FILE 1
112#define BTRFS_FT_DIR 2
113#define BTRFS_FT_CHRDEV 3
114#define BTRFS_FT_BLKDEV 4
Christopher Ferris106b3a82016-08-24 12:15:38 -0700115#define BTRFS_FT_FIFO 5
116#define BTRFS_FT_SOCK 6
117#define BTRFS_FT_SYMLINK 7
118#define BTRFS_FT_XATTR 8
Christopher Ferris106b3a82016-08-24 12:15:38 -0700119#define BTRFS_FT_MAX 9
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800120#define BTRFS_FT_ENCRYPTED 0x80
121#define BTRFS_INODE_NODATASUM (1U << 0)
122#define BTRFS_INODE_NODATACOW (1U << 1)
123#define BTRFS_INODE_READONLY (1U << 2)
124#define BTRFS_INODE_NOCOMPRESS (1U << 3)
125#define BTRFS_INODE_PREALLOC (1U << 4)
126#define BTRFS_INODE_SYNC (1U << 5)
127#define BTRFS_INODE_IMMUTABLE (1U << 6)
128#define BTRFS_INODE_APPEND (1U << 7)
129#define BTRFS_INODE_NODUMP (1U << 8)
130#define BTRFS_INODE_NOATIME (1U << 9)
131#define BTRFS_INODE_DIRSYNC (1U << 10)
132#define BTRFS_INODE_COMPRESS (1U << 11)
133#define BTRFS_INODE_ROOT_ITEM_INIT (1U << 31)
134#define BTRFS_INODE_FLAG_MASK (BTRFS_INODE_NODATASUM | BTRFS_INODE_NODATACOW | BTRFS_INODE_READONLY | BTRFS_INODE_NOCOMPRESS | BTRFS_INODE_PREALLOC | BTRFS_INODE_SYNC | BTRFS_INODE_IMMUTABLE | BTRFS_INODE_APPEND | BTRFS_INODE_NODUMP | BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC | BTRFS_INODE_COMPRESS | BTRFS_INODE_ROOT_ITEM_INIT)
135#define BTRFS_INODE_RO_VERITY (1U << 0)
136#define BTRFS_INODE_RO_FLAG_MASK (BTRFS_INODE_RO_VERITY)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700137struct btrfs_disk_key {
138 __le64 objectid;
139 __u8 type;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700140 __le64 offset;
141} __attribute__((__packed__));
142struct btrfs_key {
143 __u64 objectid;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700144 __u8 type;
145 __u64 offset;
146} __attribute__((__packed__));
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800147struct btrfs_header {
148 __u8 csum[BTRFS_CSUM_SIZE];
149 __u8 fsid[BTRFS_FSID_SIZE];
150 __le64 bytenr;
151 __le64 flags;
152 __u8 chunk_tree_uuid[BTRFS_UUID_SIZE];
153 __le64 generation;
154 __le64 owner;
155 __le32 nritems;
156 __u8 level;
157} __attribute__((__packed__));
158#define BTRFS_SYSTEM_CHUNK_ARRAY_SIZE 2048
159#define BTRFS_NUM_BACKUP_ROOTS 4
160struct btrfs_root_backup {
161 __le64 tree_root;
162 __le64 tree_root_gen;
163 __le64 chunk_root;
164 __le64 chunk_root_gen;
165 __le64 extent_root;
166 __le64 extent_root_gen;
167 __le64 fs_root;
168 __le64 fs_root_gen;
169 __le64 dev_root;
170 __le64 dev_root_gen;
171 __le64 csum_root;
172 __le64 csum_root_gen;
173 __le64 total_bytes;
174 __le64 bytes_used;
175 __le64 num_devices;
176 __le64 unused_64[4];
177 __u8 tree_root_level;
178 __u8 chunk_root_level;
179 __u8 extent_root_level;
180 __u8 fs_root_level;
181 __u8 dev_root_level;
182 __u8 csum_root_level;
183 __u8 unused_8[10];
184} __attribute__((__packed__));
185struct btrfs_item {
186 struct btrfs_disk_key key;
187 __le32 offset;
188 __le32 size;
189} __attribute__((__packed__));
190struct btrfs_leaf {
191 struct btrfs_header header;
192 struct btrfs_item items[];
193} __attribute__((__packed__));
194struct btrfs_key_ptr {
195 struct btrfs_disk_key key;
196 __le64 blockptr;
197 __le64 generation;
198} __attribute__((__packed__));
199struct btrfs_node {
200 struct btrfs_header header;
201 struct btrfs_key_ptr ptrs[];
202} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700203struct btrfs_dev_item {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700204 __le64 devid;
205 __le64 total_bytes;
206 __le64 bytes_used;
207 __le32 io_align;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700208 __le32 io_width;
209 __le32 sector_size;
210 __le64 type;
211 __le64 generation;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700212 __le64 start_offset;
213 __le32 dev_group;
214 __u8 seek_speed;
215 __u8 bandwidth;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700216 __u8 uuid[BTRFS_UUID_SIZE];
217 __u8 fsid[BTRFS_UUID_SIZE];
218} __attribute__((__packed__));
219struct btrfs_stripe {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700220 __le64 devid;
221 __le64 offset;
222 __u8 dev_uuid[BTRFS_UUID_SIZE];
223} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700224struct btrfs_chunk {
225 __le64 length;
226 __le64 owner;
227 __le64 stripe_len;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700228 __le64 type;
229 __le32 io_align;
230 __le32 io_width;
231 __le32 sector_size;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700232 __le16 num_stripes;
233 __le16 sub_stripes;
234 struct btrfs_stripe stripe;
235} __attribute__((__packed__));
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800236struct btrfs_super_block {
237 __u8 csum[BTRFS_CSUM_SIZE];
238 __u8 fsid[BTRFS_FSID_SIZE];
239 __le64 bytenr;
240 __le64 flags;
241 __le64 magic;
242 __le64 generation;
243 __le64 root;
244 __le64 chunk_root;
245 __le64 log_root;
246 __le64 __unused_log_root_transid;
247 __le64 total_bytes;
248 __le64 bytes_used;
249 __le64 root_dir_objectid;
250 __le64 num_devices;
251 __le32 sectorsize;
252 __le32 nodesize;
253 __le32 __unused_leafsize;
254 __le32 stripesize;
255 __le32 sys_chunk_array_size;
256 __le64 chunk_root_generation;
257 __le64 compat_flags;
258 __le64 compat_ro_flags;
259 __le64 incompat_flags;
260 __le16 csum_type;
261 __u8 root_level;
262 __u8 chunk_root_level;
263 __u8 log_root_level;
264 struct btrfs_dev_item dev_item;
265 char label[BTRFS_LABEL_SIZE];
266 __le64 cache_generation;
267 __le64 uuid_tree_generation;
268 __u8 metadata_uuid[BTRFS_FSID_SIZE];
269 __u64 nr_global_roots;
270 __le64 reserved[27];
271 __u8 sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE];
272 struct btrfs_root_backup super_roots[BTRFS_NUM_BACKUP_ROOTS];
273 __u8 padding[565];
274} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700275#define BTRFS_FREE_SPACE_EXTENT 1
276#define BTRFS_FREE_SPACE_BITMAP 2
277struct btrfs_free_space_entry {
278 __le64 offset;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700279 __le64 bytes;
280 __u8 type;
281} __attribute__((__packed__));
282struct btrfs_free_space_header {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700283 struct btrfs_disk_key location;
284 __le64 generation;
285 __le64 num_entries;
286 __le64 num_bitmaps;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700287} __attribute__((__packed__));
288#define BTRFS_HEADER_FLAG_WRITTEN (1ULL << 0)
289#define BTRFS_HEADER_FLAG_RELOC (1ULL << 1)
290#define BTRFS_SUPER_FLAG_ERROR (1ULL << 2)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700291#define BTRFS_SUPER_FLAG_SEEDING (1ULL << 32)
292#define BTRFS_SUPER_FLAG_METADUMP (1ULL << 33)
Christopher Ferris76a1d452018-06-27 14:12:29 -0700293#define BTRFS_SUPER_FLAG_METADUMP_V2 (1ULL << 34)
294#define BTRFS_SUPER_FLAG_CHANGING_FSID (1ULL << 35)
Christopher Ferrisd842e432019-03-07 10:21:59 -0800295#define BTRFS_SUPER_FLAG_CHANGING_FSID_V2 (1ULL << 36)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700296struct btrfs_extent_item {
297 __le64 refs;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700298 __le64 generation;
299 __le64 flags;
300} __attribute__((__packed__));
301struct btrfs_extent_item_v0 {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700302 __le32 refs;
303} __attribute__((__packed__));
304#define BTRFS_EXTENT_FLAG_DATA (1ULL << 0)
305#define BTRFS_EXTENT_FLAG_TREE_BLOCK (1ULL << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700306#define BTRFS_BLOCK_FLAG_FULL_BACKREF (1ULL << 8)
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800307#define BTRFS_BACKREF_REV_MAX 256
308#define BTRFS_BACKREF_REV_SHIFT 56
309#define BTRFS_BACKREF_REV_MASK (((u64) BTRFS_BACKREF_REV_MAX - 1) << BTRFS_BACKREF_REV_SHIFT)
310#define BTRFS_OLD_BACKREF_REV 0
311#define BTRFS_MIXED_BACKREF_REV 1
Christopher Ferris106b3a82016-08-24 12:15:38 -0700312#define BTRFS_EXTENT_FLAG_SUPER (1ULL << 48)
313struct btrfs_tree_block_info {
314 struct btrfs_disk_key key;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700315 __u8 level;
316} __attribute__((__packed__));
317struct btrfs_extent_data_ref {
318 __le64 root;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700319 __le64 objectid;
320 __le64 offset;
321 __le32 count;
322} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700323struct btrfs_shared_data_ref {
324 __le32 count;
325} __attribute__((__packed__));
326struct btrfs_extent_inline_ref {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700327 __u8 type;
328 __le64 offset;
329} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700330struct btrfs_dev_extent {
331 __le64 chunk_tree;
332 __le64 chunk_objectid;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700333 __le64 chunk_offset;
334 __le64 length;
335 __u8 chunk_tree_uuid[BTRFS_UUID_SIZE];
336} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700337struct btrfs_inode_ref {
338 __le64 index;
339 __le16 name_len;
340} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700341struct btrfs_inode_extref {
342 __le64 parent_objectid;
343 __le64 index;
344 __le16 name_len;
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700345 __u8 name[];
Christopher Ferris106b3a82016-08-24 12:15:38 -0700346} __attribute__((__packed__));
347struct btrfs_timespec {
348 __le64 sec;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700349 __le32 nsec;
350} __attribute__((__packed__));
351struct btrfs_inode_item {
352 __le64 generation;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700353 __le64 transid;
354 __le64 size;
355 __le64 nbytes;
356 __le64 block_group;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700357 __le32 nlink;
358 __le32 uid;
359 __le32 gid;
360 __le32 mode;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700361 __le64 rdev;
362 __le64 flags;
363 __le64 sequence;
364 __le64 reserved[4];
Christopher Ferris106b3a82016-08-24 12:15:38 -0700365 struct btrfs_timespec atime;
366 struct btrfs_timespec ctime;
367 struct btrfs_timespec mtime;
368 struct btrfs_timespec otime;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700369} __attribute__((__packed__));
370struct btrfs_dir_log_item {
371 __le64 end;
372} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700373struct btrfs_dir_item {
374 struct btrfs_disk_key location;
375 __le64 transid;
376 __le16 data_len;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700377 __le16 name_len;
378 __u8 type;
379} __attribute__((__packed__));
380#define BTRFS_ROOT_SUBVOL_RDONLY (1ULL << 0)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700381#define BTRFS_ROOT_SUBVOL_DEAD (1ULL << 48)
382struct btrfs_root_item {
383 struct btrfs_inode_item inode;
384 __le64 generation;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700385 __le64 root_dirid;
386 __le64 bytenr;
387 __le64 byte_limit;
388 __le64 bytes_used;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700389 __le64 last_snapshot;
390 __le64 flags;
391 __le32 refs;
392 struct btrfs_disk_key drop_progress;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700393 __u8 drop_level;
394 __u8 level;
395 __le64 generation_v2;
396 __u8 uuid[BTRFS_UUID_SIZE];
Christopher Ferris106b3a82016-08-24 12:15:38 -0700397 __u8 parent_uuid[BTRFS_UUID_SIZE];
398 __u8 received_uuid[BTRFS_UUID_SIZE];
399 __le64 ctransid;
400 __le64 otransid;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700401 __le64 stransid;
402 __le64 rtransid;
403 struct btrfs_timespec ctime;
404 struct btrfs_timespec otime;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700405 struct btrfs_timespec stime;
406 struct btrfs_timespec rtime;
407 __le64 reserved[8];
408} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700409struct btrfs_root_ref {
410 __le64 dirid;
411 __le64 sequence;
412 __le16 name_len;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700413} __attribute__((__packed__));
414struct btrfs_disk_balance_args {
415 __le64 profiles;
416 union {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700417 __le64 usage;
418 struct {
419 __le32 usage_min;
420 __le32 usage_max;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700421 };
422 };
423 __le64 devid;
424 __le64 pstart;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700425 __le64 pend;
426 __le64 vstart;
427 __le64 vend;
428 __le64 target;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700429 __le64 flags;
430 union {
431 __le64 limit;
432 struct {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700433 __le32 limit_min;
434 __le32 limit_max;
435 };
436 };
Christopher Ferris106b3a82016-08-24 12:15:38 -0700437 __le32 stripes_min;
438 __le32 stripes_max;
439 __le64 unused[6];
440} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700441struct btrfs_balance_item {
442 __le64 flags;
443 struct btrfs_disk_balance_args data;
444 struct btrfs_disk_balance_args meta;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700445 struct btrfs_disk_balance_args sys;
446 __le64 unused[4];
447} __attribute__((__packed__));
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800448enum {
449 BTRFS_FILE_EXTENT_INLINE = 0,
450 BTRFS_FILE_EXTENT_REG = 1,
451 BTRFS_FILE_EXTENT_PREALLOC = 2,
452 BTRFS_NR_FILE_EXTENT_TYPES = 3,
453};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700454struct btrfs_file_extent_item {
455 __le64 generation;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700456 __le64 ram_bytes;
457 __u8 compression;
458 __u8 encryption;
459 __le16 other_encoding;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700460 __u8 type;
461 __le64 disk_bytenr;
462 __le64 disk_num_bytes;
463 __le64 offset;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700464 __le64 num_bytes;
465} __attribute__((__packed__));
466struct btrfs_csum_item {
467 __u8 csum;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700468} __attribute__((__packed__));
469struct btrfs_dev_stats_item {
470 __le64 values[BTRFS_DEV_STAT_VALUES_MAX];
471} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700472#define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_ALWAYS 0
473#define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_AVOID 1
Christopher Ferris106b3a82016-08-24 12:15:38 -0700474struct btrfs_dev_replace_item {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700475 __le64 src_devid;
476 __le64 cursor_left;
477 __le64 cursor_right;
478 __le64 cont_reading_from_srcdev_mode;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700479 __le64 replace_state;
480 __le64 time_started;
481 __le64 time_stopped;
482 __le64 num_write_errors;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700483 __le64 num_uncorrectable_read_errors;
484} __attribute__((__packed__));
485#define BTRFS_BLOCK_GROUP_DATA (1ULL << 0)
486#define BTRFS_BLOCK_GROUP_SYSTEM (1ULL << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700487#define BTRFS_BLOCK_GROUP_METADATA (1ULL << 2)
488#define BTRFS_BLOCK_GROUP_RAID0 (1ULL << 3)
489#define BTRFS_BLOCK_GROUP_RAID1 (1ULL << 4)
490#define BTRFS_BLOCK_GROUP_DUP (1ULL << 5)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700491#define BTRFS_BLOCK_GROUP_RAID10 (1ULL << 6)
492#define BTRFS_BLOCK_GROUP_RAID5 (1ULL << 7)
493#define BTRFS_BLOCK_GROUP_RAID6 (1ULL << 8)
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800494#define BTRFS_BLOCK_GROUP_RAID1C3 (1ULL << 9)
495#define BTRFS_BLOCK_GROUP_RAID1C4 (1ULL << 10)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700496#define BTRFS_BLOCK_GROUP_RESERVED (BTRFS_AVAIL_ALLOC_BIT_SINGLE | BTRFS_SPACE_INFO_GLOBAL_RSV)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700497#define BTRFS_BLOCK_GROUP_TYPE_MASK (BTRFS_BLOCK_GROUP_DATA | BTRFS_BLOCK_GROUP_SYSTEM | BTRFS_BLOCK_GROUP_METADATA)
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800498#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)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700499#define BTRFS_BLOCK_GROUP_RAID56_MASK (BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6)
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800500#define BTRFS_BLOCK_GROUP_RAID1_MASK (BTRFS_BLOCK_GROUP_RAID1 | BTRFS_BLOCK_GROUP_RAID1C3 | BTRFS_BLOCK_GROUP_RAID1C4)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700501#define BTRFS_AVAIL_ALLOC_BIT_SINGLE (1ULL << 48)
502#define BTRFS_SPACE_INFO_GLOBAL_RSV (1ULL << 49)
503#define BTRFS_EXTENDED_PROFILE_MASK (BTRFS_BLOCK_GROUP_PROFILE_MASK | BTRFS_AVAIL_ALLOC_BIT_SINGLE)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700504struct btrfs_block_group_item {
505 __le64 used;
506 __le64 chunk_objectid;
507 __le64 flags;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700508} __attribute__((__packed__));
509struct btrfs_free_space_info {
510 __le32 extent_count;
511 __le32 flags;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700512} __attribute__((__packed__));
513#define BTRFS_FREE_SPACE_USING_BITMAPS (1ULL << 0)
514#define BTRFS_QGROUP_LEVEL_SHIFT 48
515#define BTRFS_QGROUP_STATUS_FLAG_ON (1ULL << 0)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700516#define BTRFS_QGROUP_STATUS_FLAG_RESCAN (1ULL << 1)
517#define BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT (1ULL << 2)
Christopher Ferris6cd53a52022-12-12 23:39:16 +0000518#define BTRFS_QGROUP_STATUS_FLAGS_MASK (BTRFS_QGROUP_STATUS_FLAG_ON | BTRFS_QGROUP_STATUS_FLAG_RESCAN | BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700519#define BTRFS_QGROUP_STATUS_VERSION 1
520struct btrfs_qgroup_status_item {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700521 __le64 version;
522 __le64 generation;
523 __le64 flags;
524 __le64 rescan;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700525} __attribute__((__packed__));
526struct btrfs_qgroup_info_item {
527 __le64 generation;
528 __le64 rfer;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700529 __le64 rfer_cmpr;
530 __le64 excl;
531 __le64 excl_cmpr;
532} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700533struct btrfs_qgroup_limit_item {
534 __le64 flags;
535 __le64 max_rfer;
536 __le64 max_excl;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700537 __le64 rsv_rfer;
538 __le64 rsv_excl;
539} __attribute__((__packed__));
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700540struct btrfs_verity_descriptor_item {
541 __le64 size;
542 __le64 reserved[2];
543 __u8 encryption;
544} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700545#endif