blob: ea33eee480f8474e344a1123b78f027dd567e854 [file] [log] [blame]
Elliott Hughes180edef2023-11-02 00:08:05 +00001/*
2 * This file is auto-generated. Modifications will be lost.
3 *
4 * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
5 * for more information.
6 */
Christopher Ferris106b3a82016-08-24 12:15:38 -07007#ifndef _BTRFS_CTREE_H_
8#define _BTRFS_CTREE_H_
Christopher Ferris525ce912017-07-26 13:12:53 -07009#include <linux/btrfs.h>
10#include <linux/types.h>
Christopher Ferris32ff3f82020-12-14 13:10:04 -080011#include <stddef.h>
Christopher Ferris8b7fdc92023-02-21 13:36:32 -080012#define BTRFS_MAGIC 0x4D5F53665248425FULL
13#define BTRFS_MAX_LEVEL 8
14#define BTRFS_NAME_LEN 255
15#define BTRFS_LINK_MAX 65535U
Christopher Ferris106b3a82016-08-24 12:15:38 -070016#define BTRFS_ROOT_TREE_OBJECTID 1ULL
17#define BTRFS_EXTENT_TREE_OBJECTID 2ULL
Christopher Ferris106b3a82016-08-24 12:15:38 -070018#define BTRFS_CHUNK_TREE_OBJECTID 3ULL
19#define BTRFS_DEV_TREE_OBJECTID 4ULL
20#define BTRFS_FS_TREE_OBJECTID 5ULL
21#define BTRFS_ROOT_TREE_DIR_OBJECTID 6ULL
Christopher Ferris106b3a82016-08-24 12:15:38 -070022#define BTRFS_CSUM_TREE_OBJECTID 7ULL
23#define BTRFS_QUOTA_TREE_OBJECTID 8ULL
24#define BTRFS_UUID_TREE_OBJECTID 9ULL
25#define BTRFS_FREE_SPACE_TREE_OBJECTID 10ULL
Christopher Ferris10a76e62022-06-08 13:31:52 -070026#define BTRFS_BLOCK_GROUP_TREE_OBJECTID 11ULL
Christopher Ferris0f795212024-01-17 14:17:28 -080027#define BTRFS_RAID_STRIPE_TREE_OBJECTID 12ULL
Christopher Ferris106b3a82016-08-24 12:15:38 -070028#define BTRFS_DEV_STATS_OBJECTID 0ULL
29#define BTRFS_BALANCE_OBJECTID - 4ULL
30#define BTRFS_ORPHAN_OBJECTID - 5ULL
31#define BTRFS_TREE_LOG_OBJECTID - 6ULL
Christopher Ferris106b3a82016-08-24 12:15:38 -070032#define BTRFS_TREE_LOG_FIXUP_OBJECTID - 7ULL
33#define BTRFS_TREE_RELOC_OBJECTID - 8ULL
34#define BTRFS_DATA_RELOC_TREE_OBJECTID - 9ULL
35#define BTRFS_EXTENT_CSUM_OBJECTID - 10ULL
Christopher Ferris106b3a82016-08-24 12:15:38 -070036#define BTRFS_FREE_SPACE_OBJECTID - 11ULL
37#define BTRFS_FREE_INO_OBJECTID - 12ULL
38#define BTRFS_MULTIPLE_OBJECTIDS - 255ULL
39#define BTRFS_FIRST_FREE_OBJECTID 256ULL
Christopher Ferris106b3a82016-08-24 12:15:38 -070040#define BTRFS_LAST_FREE_OBJECTID - 256ULL
41#define BTRFS_FIRST_CHUNK_TREE_OBJECTID 256ULL
42#define BTRFS_DEV_ITEMS_OBJECTID 1ULL
43#define BTRFS_BTREE_INODE_OBJECTID 1
Christopher Ferris106b3a82016-08-24 12:15:38 -070044#define BTRFS_EMPTY_SUBVOL_DIR_OBJECTID 2
45#define BTRFS_DEV_REPLACE_DEVID 0ULL
46#define BTRFS_INODE_ITEM_KEY 1
47#define BTRFS_INODE_REF_KEY 12
Christopher Ferris106b3a82016-08-24 12:15:38 -070048#define BTRFS_INODE_EXTREF_KEY 13
49#define BTRFS_XATTR_ITEM_KEY 24
Christopher Ferris2abfa9e2021-11-01 16:26:06 -070050#define BTRFS_VERITY_DESC_ITEM_KEY 36
51#define BTRFS_VERITY_MERKLE_ITEM_KEY 37
Christopher Ferris106b3a82016-08-24 12:15:38 -070052#define BTRFS_ORPHAN_ITEM_KEY 48
53#define BTRFS_DIR_LOG_ITEM_KEY 60
Christopher Ferris106b3a82016-08-24 12:15:38 -070054#define BTRFS_DIR_LOG_INDEX_KEY 72
55#define BTRFS_DIR_ITEM_KEY 84
56#define BTRFS_DIR_INDEX_KEY 96
57#define BTRFS_EXTENT_DATA_KEY 108
Christopher Ferris106b3a82016-08-24 12:15:38 -070058#define BTRFS_EXTENT_CSUM_KEY 128
59#define BTRFS_ROOT_ITEM_KEY 132
60#define BTRFS_ROOT_BACKREF_KEY 144
61#define BTRFS_ROOT_REF_KEY 156
Christopher Ferris106b3a82016-08-24 12:15:38 -070062#define BTRFS_EXTENT_ITEM_KEY 168
63#define BTRFS_METADATA_ITEM_KEY 169
Christopher Ferris0f795212024-01-17 14:17:28 -080064#define BTRFS_EXTENT_OWNER_REF_KEY 172
Christopher Ferris106b3a82016-08-24 12:15:38 -070065#define BTRFS_TREE_BLOCK_REF_KEY 176
66#define BTRFS_EXTENT_DATA_REF_KEY 178
Christopher Ferris106b3a82016-08-24 12:15:38 -070067#define BTRFS_SHARED_BLOCK_REF_KEY 182
68#define BTRFS_SHARED_DATA_REF_KEY 184
69#define BTRFS_BLOCK_GROUP_ITEM_KEY 192
Christopher Ferris106b3a82016-08-24 12:15:38 -070070#define BTRFS_FREE_SPACE_INFO_KEY 198
71#define BTRFS_FREE_SPACE_EXTENT_KEY 199
72#define BTRFS_FREE_SPACE_BITMAP_KEY 200
73#define BTRFS_DEV_EXTENT_KEY 204
Christopher Ferris106b3a82016-08-24 12:15:38 -070074#define BTRFS_DEV_ITEM_KEY 216
75#define BTRFS_CHUNK_ITEM_KEY 228
Christopher Ferris0f795212024-01-17 14:17:28 -080076#define BTRFS_RAID_STRIPE_KEY 230
Christopher Ferris106b3a82016-08-24 12:15:38 -070077#define BTRFS_QGROUP_STATUS_KEY 240
78#define BTRFS_QGROUP_INFO_KEY 242
Christopher Ferris106b3a82016-08-24 12:15:38 -070079#define BTRFS_QGROUP_LIMIT_KEY 244
80#define BTRFS_QGROUP_RELATION_KEY 246
81#define BTRFS_BALANCE_ITEM_KEY 248
82#define BTRFS_TEMPORARY_ITEM_KEY 248
Christopher Ferris106b3a82016-08-24 12:15:38 -070083#define BTRFS_DEV_STATS_KEY 249
84#define BTRFS_PERSISTENT_ITEM_KEY 249
85#define BTRFS_DEV_REPLACE_KEY 250
86#if BTRFS_UUID_SIZE != 16
Christopher Ferris106b3a82016-08-24 12:15:38 -070087#error "UUID items require BTRFS_UUID_SIZE == 16!"
88#endif
89#define BTRFS_UUID_KEY_SUBVOL 251
90#define BTRFS_UUID_KEY_RECEIVED_SUBVOL 252
Christopher Ferris106b3a82016-08-24 12:15:38 -070091#define BTRFS_STRING_ITEM_KEY 253
Christopher Ferris05667cd2021-02-16 16:01:34 -080092#define BTRFS_MAX_METADATA_BLOCKSIZE 65536
Christopher Ferris106b3a82016-08-24 12:15:38 -070093#define BTRFS_CSUM_SIZE 32
Christopher Ferris9584fa42019-12-09 15:36:13 -080094enum btrfs_csum_type {
95 BTRFS_CSUM_TYPE_CRC32 = 0,
Christopher Ferrisd32ca142020-02-04 16:16:51 -080096 BTRFS_CSUM_TYPE_XXHASH = 1,
97 BTRFS_CSUM_TYPE_SHA256 = 2,
98 BTRFS_CSUM_TYPE_BLAKE2 = 3,
Christopher Ferris9584fa42019-12-09 15:36:13 -080099};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700100#define BTRFS_FT_UNKNOWN 0
Christopher Ferris106b3a82016-08-24 12:15:38 -0700101#define BTRFS_FT_REG_FILE 1
102#define BTRFS_FT_DIR 2
103#define BTRFS_FT_CHRDEV 3
104#define BTRFS_FT_BLKDEV 4
Christopher Ferris106b3a82016-08-24 12:15:38 -0700105#define BTRFS_FT_FIFO 5
106#define BTRFS_FT_SOCK 6
107#define BTRFS_FT_SYMLINK 7
108#define BTRFS_FT_XATTR 8
Christopher Ferris106b3a82016-08-24 12:15:38 -0700109#define BTRFS_FT_MAX 9
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800110#define BTRFS_FT_ENCRYPTED 0x80
111#define BTRFS_INODE_NODATASUM (1U << 0)
112#define BTRFS_INODE_NODATACOW (1U << 1)
113#define BTRFS_INODE_READONLY (1U << 2)
114#define BTRFS_INODE_NOCOMPRESS (1U << 3)
115#define BTRFS_INODE_PREALLOC (1U << 4)
116#define BTRFS_INODE_SYNC (1U << 5)
117#define BTRFS_INODE_IMMUTABLE (1U << 6)
118#define BTRFS_INODE_APPEND (1U << 7)
119#define BTRFS_INODE_NODUMP (1U << 8)
120#define BTRFS_INODE_NOATIME (1U << 9)
121#define BTRFS_INODE_DIRSYNC (1U << 10)
122#define BTRFS_INODE_COMPRESS (1U << 11)
123#define BTRFS_INODE_ROOT_ITEM_INIT (1U << 31)
124#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)
125#define BTRFS_INODE_RO_VERITY (1U << 0)
126#define BTRFS_INODE_RO_FLAG_MASK (BTRFS_INODE_RO_VERITY)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700127struct btrfs_disk_key {
128 __le64 objectid;
129 __u8 type;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700130 __le64 offset;
131} __attribute__((__packed__));
132struct btrfs_key {
133 __u64 objectid;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700134 __u8 type;
135 __u64 offset;
136} __attribute__((__packed__));
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800137struct btrfs_header {
138 __u8 csum[BTRFS_CSUM_SIZE];
139 __u8 fsid[BTRFS_FSID_SIZE];
140 __le64 bytenr;
141 __le64 flags;
142 __u8 chunk_tree_uuid[BTRFS_UUID_SIZE];
143 __le64 generation;
144 __le64 owner;
145 __le32 nritems;
146 __u8 level;
147} __attribute__((__packed__));
148#define BTRFS_SYSTEM_CHUNK_ARRAY_SIZE 2048
149#define BTRFS_NUM_BACKUP_ROOTS 4
150struct btrfs_root_backup {
151 __le64 tree_root;
152 __le64 tree_root_gen;
153 __le64 chunk_root;
154 __le64 chunk_root_gen;
155 __le64 extent_root;
156 __le64 extent_root_gen;
157 __le64 fs_root;
158 __le64 fs_root_gen;
159 __le64 dev_root;
160 __le64 dev_root_gen;
161 __le64 csum_root;
162 __le64 csum_root_gen;
163 __le64 total_bytes;
164 __le64 bytes_used;
165 __le64 num_devices;
166 __le64 unused_64[4];
167 __u8 tree_root_level;
168 __u8 chunk_root_level;
169 __u8 extent_root_level;
170 __u8 fs_root_level;
171 __u8 dev_root_level;
172 __u8 csum_root_level;
173 __u8 unused_8[10];
174} __attribute__((__packed__));
175struct btrfs_item {
176 struct btrfs_disk_key key;
177 __le32 offset;
178 __le32 size;
179} __attribute__((__packed__));
180struct btrfs_leaf {
181 struct btrfs_header header;
182 struct btrfs_item items[];
183} __attribute__((__packed__));
184struct btrfs_key_ptr {
185 struct btrfs_disk_key key;
186 __le64 blockptr;
187 __le64 generation;
188} __attribute__((__packed__));
189struct btrfs_node {
190 struct btrfs_header header;
191 struct btrfs_key_ptr ptrs[];
192} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700193struct btrfs_dev_item {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700194 __le64 devid;
195 __le64 total_bytes;
196 __le64 bytes_used;
197 __le32 io_align;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700198 __le32 io_width;
199 __le32 sector_size;
200 __le64 type;
201 __le64 generation;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700202 __le64 start_offset;
203 __le32 dev_group;
204 __u8 seek_speed;
205 __u8 bandwidth;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700206 __u8 uuid[BTRFS_UUID_SIZE];
207 __u8 fsid[BTRFS_UUID_SIZE];
208} __attribute__((__packed__));
209struct btrfs_stripe {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700210 __le64 devid;
211 __le64 offset;
212 __u8 dev_uuid[BTRFS_UUID_SIZE];
213} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700214struct btrfs_chunk {
215 __le64 length;
216 __le64 owner;
217 __le64 stripe_len;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700218 __le64 type;
219 __le32 io_align;
220 __le32 io_width;
221 __le32 sector_size;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700222 __le16 num_stripes;
223 __le16 sub_stripes;
224 struct btrfs_stripe stripe;
225} __attribute__((__packed__));
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800226struct btrfs_super_block {
227 __u8 csum[BTRFS_CSUM_SIZE];
228 __u8 fsid[BTRFS_FSID_SIZE];
229 __le64 bytenr;
230 __le64 flags;
231 __le64 magic;
232 __le64 generation;
233 __le64 root;
234 __le64 chunk_root;
235 __le64 log_root;
236 __le64 __unused_log_root_transid;
237 __le64 total_bytes;
238 __le64 bytes_used;
239 __le64 root_dir_objectid;
240 __le64 num_devices;
241 __le32 sectorsize;
242 __le32 nodesize;
243 __le32 __unused_leafsize;
244 __le32 stripesize;
245 __le32 sys_chunk_array_size;
246 __le64 chunk_root_generation;
247 __le64 compat_flags;
248 __le64 compat_ro_flags;
249 __le64 incompat_flags;
250 __le16 csum_type;
251 __u8 root_level;
252 __u8 chunk_root_level;
253 __u8 log_root_level;
254 struct btrfs_dev_item dev_item;
255 char label[BTRFS_LABEL_SIZE];
256 __le64 cache_generation;
257 __le64 uuid_tree_generation;
258 __u8 metadata_uuid[BTRFS_FSID_SIZE];
259 __u64 nr_global_roots;
260 __le64 reserved[27];
261 __u8 sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE];
262 struct btrfs_root_backup super_roots[BTRFS_NUM_BACKUP_ROOTS];
263 __u8 padding[565];
264} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700265#define BTRFS_FREE_SPACE_EXTENT 1
266#define BTRFS_FREE_SPACE_BITMAP 2
267struct btrfs_free_space_entry {
268 __le64 offset;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700269 __le64 bytes;
270 __u8 type;
271} __attribute__((__packed__));
272struct btrfs_free_space_header {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700273 struct btrfs_disk_key location;
274 __le64 generation;
275 __le64 num_entries;
276 __le64 num_bitmaps;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700277} __attribute__((__packed__));
Christopher Ferris0f795212024-01-17 14:17:28 -0800278struct btrfs_raid_stride {
279 __le64 devid;
280 __le64 physical;
281} __attribute__((__packed__));
Priyanka Advani (xWF)a8050342024-09-25 19:07:32 +0000282#define BTRFS_STRIPE_RAID0 1
283#define BTRFS_STRIPE_RAID1 2
284#define BTRFS_STRIPE_DUP 3
285#define BTRFS_STRIPE_RAID10 4
286#define BTRFS_STRIPE_RAID5 5
287#define BTRFS_STRIPE_RAID6 6
288#define BTRFS_STRIPE_RAID1C3 7
289#define BTRFS_STRIPE_RAID1C4 8
Christopher Ferris0f795212024-01-17 14:17:28 -0800290struct btrfs_stripe_extent {
Priyanka Advani (xWF)a8050342024-09-25 19:07:32 +0000291 __u8 encoding;
292 __u8 reserved[7];
293 struct btrfs_raid_stride strides[];
Christopher Ferris0f795212024-01-17 14:17:28 -0800294} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700295#define BTRFS_HEADER_FLAG_WRITTEN (1ULL << 0)
296#define BTRFS_HEADER_FLAG_RELOC (1ULL << 1)
297#define BTRFS_SUPER_FLAG_ERROR (1ULL << 2)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700298#define BTRFS_SUPER_FLAG_SEEDING (1ULL << 32)
299#define BTRFS_SUPER_FLAG_METADUMP (1ULL << 33)
Christopher Ferris76a1d452018-06-27 14:12:29 -0700300#define BTRFS_SUPER_FLAG_METADUMP_V2 (1ULL << 34)
301#define BTRFS_SUPER_FLAG_CHANGING_FSID (1ULL << 35)
Christopher Ferrisd842e432019-03-07 10:21:59 -0800302#define BTRFS_SUPER_FLAG_CHANGING_FSID_V2 (1ULL << 36)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700303struct btrfs_extent_item {
304 __le64 refs;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700305 __le64 generation;
306 __le64 flags;
307} __attribute__((__packed__));
308struct btrfs_extent_item_v0 {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700309 __le32 refs;
310} __attribute__((__packed__));
311#define BTRFS_EXTENT_FLAG_DATA (1ULL << 0)
312#define BTRFS_EXTENT_FLAG_TREE_BLOCK (1ULL << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700313#define BTRFS_BLOCK_FLAG_FULL_BACKREF (1ULL << 8)
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800314#define BTRFS_BACKREF_REV_MAX 256
315#define BTRFS_BACKREF_REV_SHIFT 56
316#define BTRFS_BACKREF_REV_MASK (((u64) BTRFS_BACKREF_REV_MAX - 1) << BTRFS_BACKREF_REV_SHIFT)
317#define BTRFS_OLD_BACKREF_REV 0
318#define BTRFS_MIXED_BACKREF_REV 1
Christopher Ferris106b3a82016-08-24 12:15:38 -0700319#define BTRFS_EXTENT_FLAG_SUPER (1ULL << 48)
320struct btrfs_tree_block_info {
321 struct btrfs_disk_key key;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700322 __u8 level;
323} __attribute__((__packed__));
324struct btrfs_extent_data_ref {
325 __le64 root;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700326 __le64 objectid;
327 __le64 offset;
328 __le32 count;
329} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700330struct btrfs_shared_data_ref {
331 __le32 count;
332} __attribute__((__packed__));
Christopher Ferris0f795212024-01-17 14:17:28 -0800333struct btrfs_extent_owner_ref {
334 __le64 root_id;
335} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700336struct btrfs_extent_inline_ref {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700337 __u8 type;
338 __le64 offset;
339} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700340struct btrfs_dev_extent {
341 __le64 chunk_tree;
342 __le64 chunk_objectid;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700343 __le64 chunk_offset;
344 __le64 length;
345 __u8 chunk_tree_uuid[BTRFS_UUID_SIZE];
346} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700347struct btrfs_inode_ref {
348 __le64 index;
349 __le16 name_len;
350} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700351struct btrfs_inode_extref {
352 __le64 parent_objectid;
353 __le64 index;
354 __le16 name_len;
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700355 __u8 name[];
Christopher Ferris106b3a82016-08-24 12:15:38 -0700356} __attribute__((__packed__));
357struct btrfs_timespec {
358 __le64 sec;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700359 __le32 nsec;
360} __attribute__((__packed__));
361struct btrfs_inode_item {
362 __le64 generation;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700363 __le64 transid;
364 __le64 size;
365 __le64 nbytes;
366 __le64 block_group;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700367 __le32 nlink;
368 __le32 uid;
369 __le32 gid;
370 __le32 mode;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700371 __le64 rdev;
372 __le64 flags;
373 __le64 sequence;
374 __le64 reserved[4];
Christopher Ferris106b3a82016-08-24 12:15:38 -0700375 struct btrfs_timespec atime;
376 struct btrfs_timespec ctime;
377 struct btrfs_timespec mtime;
378 struct btrfs_timespec otime;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700379} __attribute__((__packed__));
380struct btrfs_dir_log_item {
381 __le64 end;
382} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700383struct btrfs_dir_item {
384 struct btrfs_disk_key location;
385 __le64 transid;
386 __le16 data_len;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700387 __le16 name_len;
388 __u8 type;
389} __attribute__((__packed__));
390#define BTRFS_ROOT_SUBVOL_RDONLY (1ULL << 0)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700391#define BTRFS_ROOT_SUBVOL_DEAD (1ULL << 48)
392struct btrfs_root_item {
393 struct btrfs_inode_item inode;
394 __le64 generation;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700395 __le64 root_dirid;
396 __le64 bytenr;
397 __le64 byte_limit;
398 __le64 bytes_used;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700399 __le64 last_snapshot;
400 __le64 flags;
401 __le32 refs;
402 struct btrfs_disk_key drop_progress;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700403 __u8 drop_level;
404 __u8 level;
405 __le64 generation_v2;
406 __u8 uuid[BTRFS_UUID_SIZE];
Christopher Ferris106b3a82016-08-24 12:15:38 -0700407 __u8 parent_uuid[BTRFS_UUID_SIZE];
408 __u8 received_uuid[BTRFS_UUID_SIZE];
409 __le64 ctransid;
410 __le64 otransid;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700411 __le64 stransid;
412 __le64 rtransid;
413 struct btrfs_timespec ctime;
414 struct btrfs_timespec otime;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700415 struct btrfs_timespec stime;
416 struct btrfs_timespec rtime;
417 __le64 reserved[8];
418} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700419struct btrfs_root_ref {
420 __le64 dirid;
421 __le64 sequence;
422 __le16 name_len;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700423} __attribute__((__packed__));
424struct btrfs_disk_balance_args {
425 __le64 profiles;
426 union {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700427 __le64 usage;
428 struct {
429 __le32 usage_min;
430 __le32 usage_max;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700431 };
432 };
433 __le64 devid;
434 __le64 pstart;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700435 __le64 pend;
436 __le64 vstart;
437 __le64 vend;
438 __le64 target;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700439 __le64 flags;
440 union {
441 __le64 limit;
442 struct {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700443 __le32 limit_min;
444 __le32 limit_max;
445 };
446 };
Christopher Ferris106b3a82016-08-24 12:15:38 -0700447 __le32 stripes_min;
448 __le32 stripes_max;
449 __le64 unused[6];
450} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700451struct btrfs_balance_item {
452 __le64 flags;
453 struct btrfs_disk_balance_args data;
454 struct btrfs_disk_balance_args meta;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700455 struct btrfs_disk_balance_args sys;
456 __le64 unused[4];
457} __attribute__((__packed__));
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800458enum {
459 BTRFS_FILE_EXTENT_INLINE = 0,
460 BTRFS_FILE_EXTENT_REG = 1,
461 BTRFS_FILE_EXTENT_PREALLOC = 2,
462 BTRFS_NR_FILE_EXTENT_TYPES = 3,
463};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700464struct btrfs_file_extent_item {
465 __le64 generation;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700466 __le64 ram_bytes;
467 __u8 compression;
468 __u8 encryption;
469 __le16 other_encoding;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700470 __u8 type;
471 __le64 disk_bytenr;
472 __le64 disk_num_bytes;
473 __le64 offset;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700474 __le64 num_bytes;
475} __attribute__((__packed__));
476struct btrfs_csum_item {
477 __u8 csum;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700478} __attribute__((__packed__));
479struct btrfs_dev_stats_item {
480 __le64 values[BTRFS_DEV_STAT_VALUES_MAX];
481} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700482#define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_ALWAYS 0
483#define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_AVOID 1
Christopher Ferris106b3a82016-08-24 12:15:38 -0700484struct btrfs_dev_replace_item {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700485 __le64 src_devid;
486 __le64 cursor_left;
487 __le64 cursor_right;
488 __le64 cont_reading_from_srcdev_mode;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700489 __le64 replace_state;
490 __le64 time_started;
491 __le64 time_stopped;
492 __le64 num_write_errors;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700493 __le64 num_uncorrectable_read_errors;
494} __attribute__((__packed__));
495#define BTRFS_BLOCK_GROUP_DATA (1ULL << 0)
496#define BTRFS_BLOCK_GROUP_SYSTEM (1ULL << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700497#define BTRFS_BLOCK_GROUP_METADATA (1ULL << 2)
498#define BTRFS_BLOCK_GROUP_RAID0 (1ULL << 3)
499#define BTRFS_BLOCK_GROUP_RAID1 (1ULL << 4)
500#define BTRFS_BLOCK_GROUP_DUP (1ULL << 5)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700501#define BTRFS_BLOCK_GROUP_RAID10 (1ULL << 6)
502#define BTRFS_BLOCK_GROUP_RAID5 (1ULL << 7)
503#define BTRFS_BLOCK_GROUP_RAID6 (1ULL << 8)
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800504#define BTRFS_BLOCK_GROUP_RAID1C3 (1ULL << 9)
505#define BTRFS_BLOCK_GROUP_RAID1C4 (1ULL << 10)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700506#define BTRFS_BLOCK_GROUP_RESERVED (BTRFS_AVAIL_ALLOC_BIT_SINGLE | BTRFS_SPACE_INFO_GLOBAL_RSV)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700507#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 -0800508#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 -0700509#define BTRFS_BLOCK_GROUP_RAID56_MASK (BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6)
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800510#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 -0700511#define BTRFS_AVAIL_ALLOC_BIT_SINGLE (1ULL << 48)
512#define BTRFS_SPACE_INFO_GLOBAL_RSV (1ULL << 49)
513#define BTRFS_EXTENDED_PROFILE_MASK (BTRFS_BLOCK_GROUP_PROFILE_MASK | BTRFS_AVAIL_ALLOC_BIT_SINGLE)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700514struct btrfs_block_group_item {
515 __le64 used;
516 __le64 chunk_objectid;
517 __le64 flags;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700518} __attribute__((__packed__));
519struct btrfs_free_space_info {
520 __le32 extent_count;
521 __le32 flags;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700522} __attribute__((__packed__));
523#define BTRFS_FREE_SPACE_USING_BITMAPS (1ULL << 0)
524#define BTRFS_QGROUP_LEVEL_SHIFT 48
525#define BTRFS_QGROUP_STATUS_FLAG_ON (1ULL << 0)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700526#define BTRFS_QGROUP_STATUS_FLAG_RESCAN (1ULL << 1)
527#define BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT (1ULL << 2)
Christopher Ferris0f795212024-01-17 14:17:28 -0800528#define BTRFS_QGROUP_STATUS_FLAG_SIMPLE_MODE (1ULL << 3)
529#define BTRFS_QGROUP_STATUS_FLAGS_MASK (BTRFS_QGROUP_STATUS_FLAG_ON | BTRFS_QGROUP_STATUS_FLAG_RESCAN | BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT | BTRFS_QGROUP_STATUS_FLAG_SIMPLE_MODE)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700530#define BTRFS_QGROUP_STATUS_VERSION 1
531struct btrfs_qgroup_status_item {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700532 __le64 version;
533 __le64 generation;
534 __le64 flags;
535 __le64 rescan;
Christopher Ferris0f795212024-01-17 14:17:28 -0800536 __le64 enable_gen;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700537} __attribute__((__packed__));
538struct btrfs_qgroup_info_item {
539 __le64 generation;
540 __le64 rfer;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700541 __le64 rfer_cmpr;
542 __le64 excl;
543 __le64 excl_cmpr;
544} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700545struct btrfs_qgroup_limit_item {
546 __le64 flags;
547 __le64 max_rfer;
548 __le64 max_excl;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700549 __le64 rsv_rfer;
550 __le64 rsv_excl;
551} __attribute__((__packed__));
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700552struct btrfs_verity_descriptor_item {
553 __le64 size;
554 __le64 reserved[2];
555 __u8 encryption;
556} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700557#endif