blob: 5a42297fbfc6b50cf26d0e194e2aed79f105e30f [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_SHARED_BLOCK_REF_KEY 182
78#define BTRFS_SHARED_DATA_REF_KEY 184
79#define BTRFS_BLOCK_GROUP_ITEM_KEY 192
Christopher Ferris106b3a82016-08-24 12:15:38 -070080#define BTRFS_FREE_SPACE_INFO_KEY 198
81#define BTRFS_FREE_SPACE_EXTENT_KEY 199
82#define BTRFS_FREE_SPACE_BITMAP_KEY 200
83#define BTRFS_DEV_EXTENT_KEY 204
Christopher Ferris106b3a82016-08-24 12:15:38 -070084#define BTRFS_DEV_ITEM_KEY 216
85#define BTRFS_CHUNK_ITEM_KEY 228
86#define BTRFS_QGROUP_STATUS_KEY 240
87#define BTRFS_QGROUP_INFO_KEY 242
Christopher Ferris106b3a82016-08-24 12:15:38 -070088#define BTRFS_QGROUP_LIMIT_KEY 244
89#define BTRFS_QGROUP_RELATION_KEY 246
90#define BTRFS_BALANCE_ITEM_KEY 248
91#define BTRFS_TEMPORARY_ITEM_KEY 248
Christopher Ferris106b3a82016-08-24 12:15:38 -070092#define BTRFS_DEV_STATS_KEY 249
93#define BTRFS_PERSISTENT_ITEM_KEY 249
94#define BTRFS_DEV_REPLACE_KEY 250
95#if BTRFS_UUID_SIZE != 16
Christopher Ferris106b3a82016-08-24 12:15:38 -070096#error "UUID items require BTRFS_UUID_SIZE == 16!"
97#endif
98#define BTRFS_UUID_KEY_SUBVOL 251
99#define BTRFS_UUID_KEY_RECEIVED_SUBVOL 252
Christopher Ferris106b3a82016-08-24 12:15:38 -0700100#define BTRFS_STRING_ITEM_KEY 253
Christopher Ferris05667cd2021-02-16 16:01:34 -0800101#define BTRFS_MAX_METADATA_BLOCKSIZE 65536
Christopher Ferris106b3a82016-08-24 12:15:38 -0700102#define BTRFS_CSUM_SIZE 32
Christopher Ferris9584fa42019-12-09 15:36:13 -0800103enum btrfs_csum_type {
104 BTRFS_CSUM_TYPE_CRC32 = 0,
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800105 BTRFS_CSUM_TYPE_XXHASH = 1,
106 BTRFS_CSUM_TYPE_SHA256 = 2,
107 BTRFS_CSUM_TYPE_BLAKE2 = 3,
Christopher Ferris9584fa42019-12-09 15:36:13 -0800108};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700109#define BTRFS_FT_UNKNOWN 0
Christopher Ferris106b3a82016-08-24 12:15:38 -0700110#define BTRFS_FT_REG_FILE 1
111#define BTRFS_FT_DIR 2
112#define BTRFS_FT_CHRDEV 3
113#define BTRFS_FT_BLKDEV 4
Christopher Ferris106b3a82016-08-24 12:15:38 -0700114#define BTRFS_FT_FIFO 5
115#define BTRFS_FT_SOCK 6
116#define BTRFS_FT_SYMLINK 7
117#define BTRFS_FT_XATTR 8
Christopher Ferris106b3a82016-08-24 12:15:38 -0700118#define BTRFS_FT_MAX 9
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800119#define BTRFS_FT_ENCRYPTED 0x80
120#define BTRFS_INODE_NODATASUM (1U << 0)
121#define BTRFS_INODE_NODATACOW (1U << 1)
122#define BTRFS_INODE_READONLY (1U << 2)
123#define BTRFS_INODE_NOCOMPRESS (1U << 3)
124#define BTRFS_INODE_PREALLOC (1U << 4)
125#define BTRFS_INODE_SYNC (1U << 5)
126#define BTRFS_INODE_IMMUTABLE (1U << 6)
127#define BTRFS_INODE_APPEND (1U << 7)
128#define BTRFS_INODE_NODUMP (1U << 8)
129#define BTRFS_INODE_NOATIME (1U << 9)
130#define BTRFS_INODE_DIRSYNC (1U << 10)
131#define BTRFS_INODE_COMPRESS (1U << 11)
132#define BTRFS_INODE_ROOT_ITEM_INIT (1U << 31)
133#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)
134#define BTRFS_INODE_RO_VERITY (1U << 0)
135#define BTRFS_INODE_RO_FLAG_MASK (BTRFS_INODE_RO_VERITY)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700136struct btrfs_disk_key {
137 __le64 objectid;
138 __u8 type;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700139 __le64 offset;
140} __attribute__((__packed__));
141struct btrfs_key {
142 __u64 objectid;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700143 __u8 type;
144 __u64 offset;
145} __attribute__((__packed__));
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800146struct btrfs_header {
147 __u8 csum[BTRFS_CSUM_SIZE];
148 __u8 fsid[BTRFS_FSID_SIZE];
149 __le64 bytenr;
150 __le64 flags;
151 __u8 chunk_tree_uuid[BTRFS_UUID_SIZE];
152 __le64 generation;
153 __le64 owner;
154 __le32 nritems;
155 __u8 level;
156} __attribute__((__packed__));
157#define BTRFS_SYSTEM_CHUNK_ARRAY_SIZE 2048
158#define BTRFS_NUM_BACKUP_ROOTS 4
159struct btrfs_root_backup {
160 __le64 tree_root;
161 __le64 tree_root_gen;
162 __le64 chunk_root;
163 __le64 chunk_root_gen;
164 __le64 extent_root;
165 __le64 extent_root_gen;
166 __le64 fs_root;
167 __le64 fs_root_gen;
168 __le64 dev_root;
169 __le64 dev_root_gen;
170 __le64 csum_root;
171 __le64 csum_root_gen;
172 __le64 total_bytes;
173 __le64 bytes_used;
174 __le64 num_devices;
175 __le64 unused_64[4];
176 __u8 tree_root_level;
177 __u8 chunk_root_level;
178 __u8 extent_root_level;
179 __u8 fs_root_level;
180 __u8 dev_root_level;
181 __u8 csum_root_level;
182 __u8 unused_8[10];
183} __attribute__((__packed__));
184struct btrfs_item {
185 struct btrfs_disk_key key;
186 __le32 offset;
187 __le32 size;
188} __attribute__((__packed__));
189struct btrfs_leaf {
190 struct btrfs_header header;
191 struct btrfs_item items[];
192} __attribute__((__packed__));
193struct btrfs_key_ptr {
194 struct btrfs_disk_key key;
195 __le64 blockptr;
196 __le64 generation;
197} __attribute__((__packed__));
198struct btrfs_node {
199 struct btrfs_header header;
200 struct btrfs_key_ptr ptrs[];
201} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700202struct btrfs_dev_item {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700203 __le64 devid;
204 __le64 total_bytes;
205 __le64 bytes_used;
206 __le32 io_align;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700207 __le32 io_width;
208 __le32 sector_size;
209 __le64 type;
210 __le64 generation;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700211 __le64 start_offset;
212 __le32 dev_group;
213 __u8 seek_speed;
214 __u8 bandwidth;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700215 __u8 uuid[BTRFS_UUID_SIZE];
216 __u8 fsid[BTRFS_UUID_SIZE];
217} __attribute__((__packed__));
218struct btrfs_stripe {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700219 __le64 devid;
220 __le64 offset;
221 __u8 dev_uuid[BTRFS_UUID_SIZE];
222} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700223struct btrfs_chunk {
224 __le64 length;
225 __le64 owner;
226 __le64 stripe_len;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700227 __le64 type;
228 __le32 io_align;
229 __le32 io_width;
230 __le32 sector_size;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700231 __le16 num_stripes;
232 __le16 sub_stripes;
233 struct btrfs_stripe stripe;
234} __attribute__((__packed__));
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800235struct btrfs_super_block {
236 __u8 csum[BTRFS_CSUM_SIZE];
237 __u8 fsid[BTRFS_FSID_SIZE];
238 __le64 bytenr;
239 __le64 flags;
240 __le64 magic;
241 __le64 generation;
242 __le64 root;
243 __le64 chunk_root;
244 __le64 log_root;
245 __le64 __unused_log_root_transid;
246 __le64 total_bytes;
247 __le64 bytes_used;
248 __le64 root_dir_objectid;
249 __le64 num_devices;
250 __le32 sectorsize;
251 __le32 nodesize;
252 __le32 __unused_leafsize;
253 __le32 stripesize;
254 __le32 sys_chunk_array_size;
255 __le64 chunk_root_generation;
256 __le64 compat_flags;
257 __le64 compat_ro_flags;
258 __le64 incompat_flags;
259 __le16 csum_type;
260 __u8 root_level;
261 __u8 chunk_root_level;
262 __u8 log_root_level;
263 struct btrfs_dev_item dev_item;
264 char label[BTRFS_LABEL_SIZE];
265 __le64 cache_generation;
266 __le64 uuid_tree_generation;
267 __u8 metadata_uuid[BTRFS_FSID_SIZE];
268 __u64 nr_global_roots;
269 __le64 reserved[27];
270 __u8 sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE];
271 struct btrfs_root_backup super_roots[BTRFS_NUM_BACKUP_ROOTS];
272 __u8 padding[565];
273} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700274#define BTRFS_FREE_SPACE_EXTENT 1
275#define BTRFS_FREE_SPACE_BITMAP 2
276struct btrfs_free_space_entry {
277 __le64 offset;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700278 __le64 bytes;
279 __u8 type;
280} __attribute__((__packed__));
281struct btrfs_free_space_header {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700282 struct btrfs_disk_key location;
283 __le64 generation;
284 __le64 num_entries;
285 __le64 num_bitmaps;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700286} __attribute__((__packed__));
287#define BTRFS_HEADER_FLAG_WRITTEN (1ULL << 0)
288#define BTRFS_HEADER_FLAG_RELOC (1ULL << 1)
289#define BTRFS_SUPER_FLAG_ERROR (1ULL << 2)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700290#define BTRFS_SUPER_FLAG_SEEDING (1ULL << 32)
291#define BTRFS_SUPER_FLAG_METADUMP (1ULL << 33)
Christopher Ferris76a1d452018-06-27 14:12:29 -0700292#define BTRFS_SUPER_FLAG_METADUMP_V2 (1ULL << 34)
293#define BTRFS_SUPER_FLAG_CHANGING_FSID (1ULL << 35)
Christopher Ferrisd842e432019-03-07 10:21:59 -0800294#define BTRFS_SUPER_FLAG_CHANGING_FSID_V2 (1ULL << 36)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700295struct btrfs_extent_item {
296 __le64 refs;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700297 __le64 generation;
298 __le64 flags;
299} __attribute__((__packed__));
300struct btrfs_extent_item_v0 {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700301 __le32 refs;
302} __attribute__((__packed__));
303#define BTRFS_EXTENT_FLAG_DATA (1ULL << 0)
304#define BTRFS_EXTENT_FLAG_TREE_BLOCK (1ULL << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700305#define BTRFS_BLOCK_FLAG_FULL_BACKREF (1ULL << 8)
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800306#define BTRFS_BACKREF_REV_MAX 256
307#define BTRFS_BACKREF_REV_SHIFT 56
308#define BTRFS_BACKREF_REV_MASK (((u64) BTRFS_BACKREF_REV_MAX - 1) << BTRFS_BACKREF_REV_SHIFT)
309#define BTRFS_OLD_BACKREF_REV 0
310#define BTRFS_MIXED_BACKREF_REV 1
Christopher Ferris106b3a82016-08-24 12:15:38 -0700311#define BTRFS_EXTENT_FLAG_SUPER (1ULL << 48)
312struct btrfs_tree_block_info {
313 struct btrfs_disk_key key;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700314 __u8 level;
315} __attribute__((__packed__));
316struct btrfs_extent_data_ref {
317 __le64 root;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700318 __le64 objectid;
319 __le64 offset;
320 __le32 count;
321} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700322struct btrfs_shared_data_ref {
323 __le32 count;
324} __attribute__((__packed__));
325struct btrfs_extent_inline_ref {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700326 __u8 type;
327 __le64 offset;
328} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700329struct btrfs_dev_extent {
330 __le64 chunk_tree;
331 __le64 chunk_objectid;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700332 __le64 chunk_offset;
333 __le64 length;
334 __u8 chunk_tree_uuid[BTRFS_UUID_SIZE];
335} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700336struct btrfs_inode_ref {
337 __le64 index;
338 __le16 name_len;
339} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700340struct btrfs_inode_extref {
341 __le64 parent_objectid;
342 __le64 index;
343 __le16 name_len;
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700344 __u8 name[];
Christopher Ferris106b3a82016-08-24 12:15:38 -0700345} __attribute__((__packed__));
346struct btrfs_timespec {
347 __le64 sec;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700348 __le32 nsec;
349} __attribute__((__packed__));
350struct btrfs_inode_item {
351 __le64 generation;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700352 __le64 transid;
353 __le64 size;
354 __le64 nbytes;
355 __le64 block_group;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700356 __le32 nlink;
357 __le32 uid;
358 __le32 gid;
359 __le32 mode;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700360 __le64 rdev;
361 __le64 flags;
362 __le64 sequence;
363 __le64 reserved[4];
Christopher Ferris106b3a82016-08-24 12:15:38 -0700364 struct btrfs_timespec atime;
365 struct btrfs_timespec ctime;
366 struct btrfs_timespec mtime;
367 struct btrfs_timespec otime;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700368} __attribute__((__packed__));
369struct btrfs_dir_log_item {
370 __le64 end;
371} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700372struct btrfs_dir_item {
373 struct btrfs_disk_key location;
374 __le64 transid;
375 __le16 data_len;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700376 __le16 name_len;
377 __u8 type;
378} __attribute__((__packed__));
379#define BTRFS_ROOT_SUBVOL_RDONLY (1ULL << 0)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700380#define BTRFS_ROOT_SUBVOL_DEAD (1ULL << 48)
381struct btrfs_root_item {
382 struct btrfs_inode_item inode;
383 __le64 generation;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700384 __le64 root_dirid;
385 __le64 bytenr;
386 __le64 byte_limit;
387 __le64 bytes_used;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700388 __le64 last_snapshot;
389 __le64 flags;
390 __le32 refs;
391 struct btrfs_disk_key drop_progress;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700392 __u8 drop_level;
393 __u8 level;
394 __le64 generation_v2;
395 __u8 uuid[BTRFS_UUID_SIZE];
Christopher Ferris106b3a82016-08-24 12:15:38 -0700396 __u8 parent_uuid[BTRFS_UUID_SIZE];
397 __u8 received_uuid[BTRFS_UUID_SIZE];
398 __le64 ctransid;
399 __le64 otransid;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700400 __le64 stransid;
401 __le64 rtransid;
402 struct btrfs_timespec ctime;
403 struct btrfs_timespec otime;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700404 struct btrfs_timespec stime;
405 struct btrfs_timespec rtime;
406 __le64 reserved[8];
407} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700408struct btrfs_root_ref {
409 __le64 dirid;
410 __le64 sequence;
411 __le16 name_len;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700412} __attribute__((__packed__));
413struct btrfs_disk_balance_args {
414 __le64 profiles;
415 union {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700416 __le64 usage;
417 struct {
418 __le32 usage_min;
419 __le32 usage_max;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700420 };
421 };
422 __le64 devid;
423 __le64 pstart;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700424 __le64 pend;
425 __le64 vstart;
426 __le64 vend;
427 __le64 target;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700428 __le64 flags;
429 union {
430 __le64 limit;
431 struct {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700432 __le32 limit_min;
433 __le32 limit_max;
434 };
435 };
Christopher Ferris106b3a82016-08-24 12:15:38 -0700436 __le32 stripes_min;
437 __le32 stripes_max;
438 __le64 unused[6];
439} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700440struct btrfs_balance_item {
441 __le64 flags;
442 struct btrfs_disk_balance_args data;
443 struct btrfs_disk_balance_args meta;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700444 struct btrfs_disk_balance_args sys;
445 __le64 unused[4];
446} __attribute__((__packed__));
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800447enum {
448 BTRFS_FILE_EXTENT_INLINE = 0,
449 BTRFS_FILE_EXTENT_REG = 1,
450 BTRFS_FILE_EXTENT_PREALLOC = 2,
451 BTRFS_NR_FILE_EXTENT_TYPES = 3,
452};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700453struct btrfs_file_extent_item {
454 __le64 generation;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700455 __le64 ram_bytes;
456 __u8 compression;
457 __u8 encryption;
458 __le16 other_encoding;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700459 __u8 type;
460 __le64 disk_bytenr;
461 __le64 disk_num_bytes;
462 __le64 offset;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700463 __le64 num_bytes;
464} __attribute__((__packed__));
465struct btrfs_csum_item {
466 __u8 csum;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700467} __attribute__((__packed__));
468struct btrfs_dev_stats_item {
469 __le64 values[BTRFS_DEV_STAT_VALUES_MAX];
470} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700471#define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_ALWAYS 0
472#define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_AVOID 1
Christopher Ferris106b3a82016-08-24 12:15:38 -0700473struct btrfs_dev_replace_item {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700474 __le64 src_devid;
475 __le64 cursor_left;
476 __le64 cursor_right;
477 __le64 cont_reading_from_srcdev_mode;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700478 __le64 replace_state;
479 __le64 time_started;
480 __le64 time_stopped;
481 __le64 num_write_errors;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700482 __le64 num_uncorrectable_read_errors;
483} __attribute__((__packed__));
484#define BTRFS_BLOCK_GROUP_DATA (1ULL << 0)
485#define BTRFS_BLOCK_GROUP_SYSTEM (1ULL << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700486#define BTRFS_BLOCK_GROUP_METADATA (1ULL << 2)
487#define BTRFS_BLOCK_GROUP_RAID0 (1ULL << 3)
488#define BTRFS_BLOCK_GROUP_RAID1 (1ULL << 4)
489#define BTRFS_BLOCK_GROUP_DUP (1ULL << 5)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700490#define BTRFS_BLOCK_GROUP_RAID10 (1ULL << 6)
491#define BTRFS_BLOCK_GROUP_RAID5 (1ULL << 7)
492#define BTRFS_BLOCK_GROUP_RAID6 (1ULL << 8)
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800493#define BTRFS_BLOCK_GROUP_RAID1C3 (1ULL << 9)
494#define BTRFS_BLOCK_GROUP_RAID1C4 (1ULL << 10)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700495#define BTRFS_BLOCK_GROUP_RESERVED (BTRFS_AVAIL_ALLOC_BIT_SINGLE | BTRFS_SPACE_INFO_GLOBAL_RSV)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700496#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 -0800497#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 -0700498#define BTRFS_BLOCK_GROUP_RAID56_MASK (BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6)
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800499#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 -0700500#define BTRFS_AVAIL_ALLOC_BIT_SINGLE (1ULL << 48)
501#define BTRFS_SPACE_INFO_GLOBAL_RSV (1ULL << 49)
502#define BTRFS_EXTENDED_PROFILE_MASK (BTRFS_BLOCK_GROUP_PROFILE_MASK | BTRFS_AVAIL_ALLOC_BIT_SINGLE)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700503struct btrfs_block_group_item {
504 __le64 used;
505 __le64 chunk_objectid;
506 __le64 flags;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700507} __attribute__((__packed__));
508struct btrfs_free_space_info {
509 __le32 extent_count;
510 __le32 flags;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700511} __attribute__((__packed__));
512#define BTRFS_FREE_SPACE_USING_BITMAPS (1ULL << 0)
513#define BTRFS_QGROUP_LEVEL_SHIFT 48
514#define BTRFS_QGROUP_STATUS_FLAG_ON (1ULL << 0)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700515#define BTRFS_QGROUP_STATUS_FLAG_RESCAN (1ULL << 1)
516#define BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT (1ULL << 2)
Christopher Ferris6cd53a52022-12-12 23:39:16 +0000517#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 -0700518#define BTRFS_QGROUP_STATUS_VERSION 1
519struct btrfs_qgroup_status_item {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700520 __le64 version;
521 __le64 generation;
522 __le64 flags;
523 __le64 rescan;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700524} __attribute__((__packed__));
525struct btrfs_qgroup_info_item {
526 __le64 generation;
527 __le64 rfer;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700528 __le64 rfer_cmpr;
529 __le64 excl;
530 __le64 excl_cmpr;
531} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700532struct btrfs_qgroup_limit_item {
533 __le64 flags;
534 __le64 max_rfer;
535 __le64 max_excl;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700536 __le64 rsv_rfer;
537 __le64 rsv_excl;
538} __attribute__((__packed__));
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700539struct btrfs_verity_descriptor_item {
540 __le64 size;
541 __le64 reserved[2];
542 __u8 encryption;
543} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700544#endif