Elliott Hughes | 180edef | 2023-11-02 00:08:05 +0000 | [diff] [blame] | 1 | /* |
| 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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 7 | #ifndef _BTRFS_CTREE_H_ |
| 8 | #define _BTRFS_CTREE_H_ |
Christopher Ferris | 525ce91 | 2017-07-26 13:12:53 -0700 | [diff] [blame] | 9 | #include <linux/btrfs.h> |
| 10 | #include <linux/types.h> |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 11 | #include <stddef.h> |
Christopher Ferris | 8b7fdc9 | 2023-02-21 13:36:32 -0800 | [diff] [blame] | 12 | #define BTRFS_MAGIC 0x4D5F53665248425FULL |
| 13 | #define BTRFS_MAX_LEVEL 8 |
| 14 | #define BTRFS_NAME_LEN 255 |
| 15 | #define BTRFS_LINK_MAX 65535U |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 16 | #define BTRFS_ROOT_TREE_OBJECTID 1ULL |
| 17 | #define BTRFS_EXTENT_TREE_OBJECTID 2ULL |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 18 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 22 | #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 Ferris | 10a76e6 | 2022-06-08 13:31:52 -0700 | [diff] [blame] | 26 | #define BTRFS_BLOCK_GROUP_TREE_OBJECTID 11ULL |
Christopher Ferris | 0f79521 | 2024-01-17 14:17:28 -0800 | [diff] [blame] | 27 | #define BTRFS_RAID_STRIPE_TREE_OBJECTID 12ULL |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 28 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 32 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 36 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 40 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 44 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 48 | #define BTRFS_INODE_EXTREF_KEY 13 |
| 49 | #define BTRFS_XATTR_ITEM_KEY 24 |
Christopher Ferris | 2abfa9e | 2021-11-01 16:26:06 -0700 | [diff] [blame] | 50 | #define BTRFS_VERITY_DESC_ITEM_KEY 36 |
| 51 | #define BTRFS_VERITY_MERKLE_ITEM_KEY 37 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 52 | #define BTRFS_ORPHAN_ITEM_KEY 48 |
| 53 | #define BTRFS_DIR_LOG_ITEM_KEY 60 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 54 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 58 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 62 | #define BTRFS_EXTENT_ITEM_KEY 168 |
| 63 | #define BTRFS_METADATA_ITEM_KEY 169 |
Christopher Ferris | 0f79521 | 2024-01-17 14:17:28 -0800 | [diff] [blame] | 64 | #define BTRFS_EXTENT_OWNER_REF_KEY 172 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 65 | #define BTRFS_TREE_BLOCK_REF_KEY 176 |
| 66 | #define BTRFS_EXTENT_DATA_REF_KEY 178 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 67 | #define BTRFS_SHARED_BLOCK_REF_KEY 182 |
| 68 | #define BTRFS_SHARED_DATA_REF_KEY 184 |
| 69 | #define BTRFS_BLOCK_GROUP_ITEM_KEY 192 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 70 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 74 | #define BTRFS_DEV_ITEM_KEY 216 |
| 75 | #define BTRFS_CHUNK_ITEM_KEY 228 |
Christopher Ferris | 0f79521 | 2024-01-17 14:17:28 -0800 | [diff] [blame] | 76 | #define BTRFS_RAID_STRIPE_KEY 230 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 77 | #define BTRFS_QGROUP_STATUS_KEY 240 |
| 78 | #define BTRFS_QGROUP_INFO_KEY 242 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 79 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 83 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 87 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 91 | #define BTRFS_STRING_ITEM_KEY 253 |
Christopher Ferris | 05667cd | 2021-02-16 16:01:34 -0800 | [diff] [blame] | 92 | #define BTRFS_MAX_METADATA_BLOCKSIZE 65536 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 93 | #define BTRFS_CSUM_SIZE 32 |
Christopher Ferris | 9584fa4 | 2019-12-09 15:36:13 -0800 | [diff] [blame] | 94 | enum btrfs_csum_type { |
| 95 | BTRFS_CSUM_TYPE_CRC32 = 0, |
Christopher Ferris | d32ca14 | 2020-02-04 16:16:51 -0800 | [diff] [blame] | 96 | BTRFS_CSUM_TYPE_XXHASH = 1, |
| 97 | BTRFS_CSUM_TYPE_SHA256 = 2, |
| 98 | BTRFS_CSUM_TYPE_BLAKE2 = 3, |
Christopher Ferris | 9584fa4 | 2019-12-09 15:36:13 -0800 | [diff] [blame] | 99 | }; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 100 | #define BTRFS_FT_UNKNOWN 0 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 101 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 105 | #define BTRFS_FT_FIFO 5 |
| 106 | #define BTRFS_FT_SOCK 6 |
| 107 | #define BTRFS_FT_SYMLINK 7 |
| 108 | #define BTRFS_FT_XATTR 8 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 109 | #define BTRFS_FT_MAX 9 |
Christopher Ferris | 8b7fdc9 | 2023-02-21 13:36:32 -0800 | [diff] [blame] | 110 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 127 | struct btrfs_disk_key { |
| 128 | __le64 objectid; |
| 129 | __u8 type; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 130 | __le64 offset; |
| 131 | } __attribute__((__packed__)); |
| 132 | struct btrfs_key { |
| 133 | __u64 objectid; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 134 | __u8 type; |
| 135 | __u64 offset; |
| 136 | } __attribute__((__packed__)); |
Christopher Ferris | 8b7fdc9 | 2023-02-21 13:36:32 -0800 | [diff] [blame] | 137 | struct 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 |
| 150 | struct 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__)); |
| 175 | struct btrfs_item { |
| 176 | struct btrfs_disk_key key; |
| 177 | __le32 offset; |
| 178 | __le32 size; |
| 179 | } __attribute__((__packed__)); |
| 180 | struct btrfs_leaf { |
| 181 | struct btrfs_header header; |
| 182 | struct btrfs_item items[]; |
| 183 | } __attribute__((__packed__)); |
| 184 | struct btrfs_key_ptr { |
| 185 | struct btrfs_disk_key key; |
| 186 | __le64 blockptr; |
| 187 | __le64 generation; |
| 188 | } __attribute__((__packed__)); |
| 189 | struct btrfs_node { |
| 190 | struct btrfs_header header; |
| 191 | struct btrfs_key_ptr ptrs[]; |
| 192 | } __attribute__((__packed__)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 193 | struct btrfs_dev_item { |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 194 | __le64 devid; |
| 195 | __le64 total_bytes; |
| 196 | __le64 bytes_used; |
| 197 | __le32 io_align; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 198 | __le32 io_width; |
| 199 | __le32 sector_size; |
| 200 | __le64 type; |
| 201 | __le64 generation; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 202 | __le64 start_offset; |
| 203 | __le32 dev_group; |
| 204 | __u8 seek_speed; |
| 205 | __u8 bandwidth; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 206 | __u8 uuid[BTRFS_UUID_SIZE]; |
| 207 | __u8 fsid[BTRFS_UUID_SIZE]; |
| 208 | } __attribute__((__packed__)); |
| 209 | struct btrfs_stripe { |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 210 | __le64 devid; |
| 211 | __le64 offset; |
| 212 | __u8 dev_uuid[BTRFS_UUID_SIZE]; |
| 213 | } __attribute__((__packed__)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 214 | struct btrfs_chunk { |
| 215 | __le64 length; |
| 216 | __le64 owner; |
| 217 | __le64 stripe_len; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 218 | __le64 type; |
| 219 | __le32 io_align; |
| 220 | __le32 io_width; |
| 221 | __le32 sector_size; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 222 | __le16 num_stripes; |
| 223 | __le16 sub_stripes; |
| 224 | struct btrfs_stripe stripe; |
| 225 | } __attribute__((__packed__)); |
Christopher Ferris | 8b7fdc9 | 2023-02-21 13:36:32 -0800 | [diff] [blame] | 226 | struct 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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 265 | #define BTRFS_FREE_SPACE_EXTENT 1 |
| 266 | #define BTRFS_FREE_SPACE_BITMAP 2 |
| 267 | struct btrfs_free_space_entry { |
| 268 | __le64 offset; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 269 | __le64 bytes; |
| 270 | __u8 type; |
| 271 | } __attribute__((__packed__)); |
| 272 | struct btrfs_free_space_header { |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 273 | struct btrfs_disk_key location; |
| 274 | __le64 generation; |
| 275 | __le64 num_entries; |
| 276 | __le64 num_bitmaps; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 277 | } __attribute__((__packed__)); |
Christopher Ferris | 0f79521 | 2024-01-17 14:17:28 -0800 | [diff] [blame] | 278 | struct btrfs_raid_stride { |
| 279 | __le64 devid; |
| 280 | __le64 physical; |
| 281 | } __attribute__((__packed__)); |
Priyanka Advani (xWF) | a805034 | 2024-09-25 19:07:32 +0000 | [diff] [blame] | 282 | #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 Ferris | 0f79521 | 2024-01-17 14:17:28 -0800 | [diff] [blame] | 290 | struct btrfs_stripe_extent { |
Priyanka Advani (xWF) | a805034 | 2024-09-25 19:07:32 +0000 | [diff] [blame] | 291 | __u8 encoding; |
| 292 | __u8 reserved[7]; |
| 293 | struct btrfs_raid_stride strides[]; |
Christopher Ferris | 0f79521 | 2024-01-17 14:17:28 -0800 | [diff] [blame] | 294 | } __attribute__((__packed__)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 295 | #define BTRFS_HEADER_FLAG_WRITTEN (1ULL << 0) |
| 296 | #define BTRFS_HEADER_FLAG_RELOC (1ULL << 1) |
| 297 | #define BTRFS_SUPER_FLAG_ERROR (1ULL << 2) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 298 | #define BTRFS_SUPER_FLAG_SEEDING (1ULL << 32) |
| 299 | #define BTRFS_SUPER_FLAG_METADUMP (1ULL << 33) |
Christopher Ferris | 76a1d45 | 2018-06-27 14:12:29 -0700 | [diff] [blame] | 300 | #define BTRFS_SUPER_FLAG_METADUMP_V2 (1ULL << 34) |
| 301 | #define BTRFS_SUPER_FLAG_CHANGING_FSID (1ULL << 35) |
Christopher Ferris | d842e43 | 2019-03-07 10:21:59 -0800 | [diff] [blame] | 302 | #define BTRFS_SUPER_FLAG_CHANGING_FSID_V2 (1ULL << 36) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 303 | struct btrfs_extent_item { |
| 304 | __le64 refs; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 305 | __le64 generation; |
| 306 | __le64 flags; |
| 307 | } __attribute__((__packed__)); |
| 308 | struct btrfs_extent_item_v0 { |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 309 | __le32 refs; |
| 310 | } __attribute__((__packed__)); |
| 311 | #define BTRFS_EXTENT_FLAG_DATA (1ULL << 0) |
| 312 | #define BTRFS_EXTENT_FLAG_TREE_BLOCK (1ULL << 1) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 313 | #define BTRFS_BLOCK_FLAG_FULL_BACKREF (1ULL << 8) |
Christopher Ferris | 8b7fdc9 | 2023-02-21 13:36:32 -0800 | [diff] [blame] | 314 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 319 | #define BTRFS_EXTENT_FLAG_SUPER (1ULL << 48) |
| 320 | struct btrfs_tree_block_info { |
| 321 | struct btrfs_disk_key key; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 322 | __u8 level; |
| 323 | } __attribute__((__packed__)); |
| 324 | struct btrfs_extent_data_ref { |
| 325 | __le64 root; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 326 | __le64 objectid; |
| 327 | __le64 offset; |
| 328 | __le32 count; |
| 329 | } __attribute__((__packed__)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 330 | struct btrfs_shared_data_ref { |
| 331 | __le32 count; |
| 332 | } __attribute__((__packed__)); |
Christopher Ferris | 0f79521 | 2024-01-17 14:17:28 -0800 | [diff] [blame] | 333 | struct btrfs_extent_owner_ref { |
| 334 | __le64 root_id; |
| 335 | } __attribute__((__packed__)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 336 | struct btrfs_extent_inline_ref { |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 337 | __u8 type; |
| 338 | __le64 offset; |
| 339 | } __attribute__((__packed__)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 340 | struct btrfs_dev_extent { |
| 341 | __le64 chunk_tree; |
| 342 | __le64 chunk_objectid; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 343 | __le64 chunk_offset; |
| 344 | __le64 length; |
| 345 | __u8 chunk_tree_uuid[BTRFS_UUID_SIZE]; |
| 346 | } __attribute__((__packed__)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 347 | struct btrfs_inode_ref { |
| 348 | __le64 index; |
| 349 | __le16 name_len; |
| 350 | } __attribute__((__packed__)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 351 | struct btrfs_inode_extref { |
| 352 | __le64 parent_objectid; |
| 353 | __le64 index; |
| 354 | __le16 name_len; |
Christopher Ferris | 7447a1c | 2022-10-04 18:24:44 -0700 | [diff] [blame] | 355 | __u8 name[]; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 356 | } __attribute__((__packed__)); |
| 357 | struct btrfs_timespec { |
| 358 | __le64 sec; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 359 | __le32 nsec; |
| 360 | } __attribute__((__packed__)); |
| 361 | struct btrfs_inode_item { |
| 362 | __le64 generation; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 363 | __le64 transid; |
| 364 | __le64 size; |
| 365 | __le64 nbytes; |
| 366 | __le64 block_group; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 367 | __le32 nlink; |
| 368 | __le32 uid; |
| 369 | __le32 gid; |
| 370 | __le32 mode; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 371 | __le64 rdev; |
| 372 | __le64 flags; |
| 373 | __le64 sequence; |
| 374 | __le64 reserved[4]; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 375 | struct btrfs_timespec atime; |
| 376 | struct btrfs_timespec ctime; |
| 377 | struct btrfs_timespec mtime; |
| 378 | struct btrfs_timespec otime; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 379 | } __attribute__((__packed__)); |
| 380 | struct btrfs_dir_log_item { |
| 381 | __le64 end; |
| 382 | } __attribute__((__packed__)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 383 | struct btrfs_dir_item { |
| 384 | struct btrfs_disk_key location; |
| 385 | __le64 transid; |
| 386 | __le16 data_len; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 387 | __le16 name_len; |
| 388 | __u8 type; |
| 389 | } __attribute__((__packed__)); |
| 390 | #define BTRFS_ROOT_SUBVOL_RDONLY (1ULL << 0) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 391 | #define BTRFS_ROOT_SUBVOL_DEAD (1ULL << 48) |
| 392 | struct btrfs_root_item { |
| 393 | struct btrfs_inode_item inode; |
| 394 | __le64 generation; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 395 | __le64 root_dirid; |
| 396 | __le64 bytenr; |
| 397 | __le64 byte_limit; |
| 398 | __le64 bytes_used; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 399 | __le64 last_snapshot; |
| 400 | __le64 flags; |
| 401 | __le32 refs; |
| 402 | struct btrfs_disk_key drop_progress; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 403 | __u8 drop_level; |
| 404 | __u8 level; |
| 405 | __le64 generation_v2; |
| 406 | __u8 uuid[BTRFS_UUID_SIZE]; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 407 | __u8 parent_uuid[BTRFS_UUID_SIZE]; |
| 408 | __u8 received_uuid[BTRFS_UUID_SIZE]; |
| 409 | __le64 ctransid; |
| 410 | __le64 otransid; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 411 | __le64 stransid; |
| 412 | __le64 rtransid; |
| 413 | struct btrfs_timespec ctime; |
| 414 | struct btrfs_timespec otime; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 415 | struct btrfs_timespec stime; |
| 416 | struct btrfs_timespec rtime; |
| 417 | __le64 reserved[8]; |
| 418 | } __attribute__((__packed__)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 419 | struct btrfs_root_ref { |
| 420 | __le64 dirid; |
| 421 | __le64 sequence; |
| 422 | __le16 name_len; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 423 | } __attribute__((__packed__)); |
| 424 | struct btrfs_disk_balance_args { |
| 425 | __le64 profiles; |
| 426 | union { |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 427 | __le64 usage; |
| 428 | struct { |
| 429 | __le32 usage_min; |
| 430 | __le32 usage_max; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 431 | }; |
| 432 | }; |
| 433 | __le64 devid; |
| 434 | __le64 pstart; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 435 | __le64 pend; |
| 436 | __le64 vstart; |
| 437 | __le64 vend; |
| 438 | __le64 target; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 439 | __le64 flags; |
| 440 | union { |
| 441 | __le64 limit; |
| 442 | struct { |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 443 | __le32 limit_min; |
| 444 | __le32 limit_max; |
| 445 | }; |
| 446 | }; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 447 | __le32 stripes_min; |
| 448 | __le32 stripes_max; |
| 449 | __le64 unused[6]; |
| 450 | } __attribute__((__packed__)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 451 | struct btrfs_balance_item { |
| 452 | __le64 flags; |
| 453 | struct btrfs_disk_balance_args data; |
| 454 | struct btrfs_disk_balance_args meta; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 455 | struct btrfs_disk_balance_args sys; |
| 456 | __le64 unused[4]; |
| 457 | } __attribute__((__packed__)); |
Christopher Ferris | d32ca14 | 2020-02-04 16:16:51 -0800 | [diff] [blame] | 458 | enum { |
| 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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 464 | struct btrfs_file_extent_item { |
| 465 | __le64 generation; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 466 | __le64 ram_bytes; |
| 467 | __u8 compression; |
| 468 | __u8 encryption; |
| 469 | __le16 other_encoding; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 470 | __u8 type; |
| 471 | __le64 disk_bytenr; |
| 472 | __le64 disk_num_bytes; |
| 473 | __le64 offset; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 474 | __le64 num_bytes; |
| 475 | } __attribute__((__packed__)); |
| 476 | struct btrfs_csum_item { |
| 477 | __u8 csum; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 478 | } __attribute__((__packed__)); |
| 479 | struct btrfs_dev_stats_item { |
| 480 | __le64 values[BTRFS_DEV_STAT_VALUES_MAX]; |
| 481 | } __attribute__((__packed__)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 482 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 484 | struct btrfs_dev_replace_item { |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 485 | __le64 src_devid; |
| 486 | __le64 cursor_left; |
| 487 | __le64 cursor_right; |
| 488 | __le64 cont_reading_from_srcdev_mode; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 489 | __le64 replace_state; |
| 490 | __le64 time_started; |
| 491 | __le64 time_stopped; |
| 492 | __le64 num_write_errors; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 493 | __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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 497 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 501 | #define BTRFS_BLOCK_GROUP_RAID10 (1ULL << 6) |
| 502 | #define BTRFS_BLOCK_GROUP_RAID5 (1ULL << 7) |
| 503 | #define BTRFS_BLOCK_GROUP_RAID6 (1ULL << 8) |
Christopher Ferris | d32ca14 | 2020-02-04 16:16:51 -0800 | [diff] [blame] | 504 | #define BTRFS_BLOCK_GROUP_RAID1C3 (1ULL << 9) |
| 505 | #define BTRFS_BLOCK_GROUP_RAID1C4 (1ULL << 10) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 506 | #define BTRFS_BLOCK_GROUP_RESERVED (BTRFS_AVAIL_ALLOC_BIT_SINGLE | BTRFS_SPACE_INFO_GLOBAL_RSV) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 507 | #define BTRFS_BLOCK_GROUP_TYPE_MASK (BTRFS_BLOCK_GROUP_DATA | BTRFS_BLOCK_GROUP_SYSTEM | BTRFS_BLOCK_GROUP_METADATA) |
Christopher Ferris | d32ca14 | 2020-02-04 16:16:51 -0800 | [diff] [blame] | 508 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 509 | #define BTRFS_BLOCK_GROUP_RAID56_MASK (BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6) |
Christopher Ferris | d32ca14 | 2020-02-04 16:16:51 -0800 | [diff] [blame] | 510 | #define BTRFS_BLOCK_GROUP_RAID1_MASK (BTRFS_BLOCK_GROUP_RAID1 | BTRFS_BLOCK_GROUP_RAID1C3 | BTRFS_BLOCK_GROUP_RAID1C4) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 511 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 514 | struct btrfs_block_group_item { |
| 515 | __le64 used; |
| 516 | __le64 chunk_objectid; |
| 517 | __le64 flags; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 518 | } __attribute__((__packed__)); |
| 519 | struct btrfs_free_space_info { |
| 520 | __le32 extent_count; |
| 521 | __le32 flags; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 522 | } __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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 526 | #define BTRFS_QGROUP_STATUS_FLAG_RESCAN (1ULL << 1) |
| 527 | #define BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT (1ULL << 2) |
Christopher Ferris | 0f79521 | 2024-01-17 14:17:28 -0800 | [diff] [blame] | 528 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 530 | #define BTRFS_QGROUP_STATUS_VERSION 1 |
| 531 | struct btrfs_qgroup_status_item { |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 532 | __le64 version; |
| 533 | __le64 generation; |
| 534 | __le64 flags; |
| 535 | __le64 rescan; |
Christopher Ferris | 0f79521 | 2024-01-17 14:17:28 -0800 | [diff] [blame] | 536 | __le64 enable_gen; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 537 | } __attribute__((__packed__)); |
| 538 | struct btrfs_qgroup_info_item { |
| 539 | __le64 generation; |
| 540 | __le64 rfer; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 541 | __le64 rfer_cmpr; |
| 542 | __le64 excl; |
| 543 | __le64 excl_cmpr; |
| 544 | } __attribute__((__packed__)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 545 | struct btrfs_qgroup_limit_item { |
| 546 | __le64 flags; |
| 547 | __le64 max_rfer; |
| 548 | __le64 max_excl; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 549 | __le64 rsv_rfer; |
| 550 | __le64 rsv_excl; |
| 551 | } __attribute__((__packed__)); |
Christopher Ferris | 2abfa9e | 2021-11-01 16:26:06 -0700 | [diff] [blame] | 552 | struct btrfs_verity_descriptor_item { |
| 553 | __le64 size; |
| 554 | __le64 reserved[2]; |
| 555 | __u8 encryption; |
| 556 | } __attribute__((__packed__)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 557 | #endif |