Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 1 | /**************************************************************************** |
| 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 Ferris | 525ce91 | 2017-07-26 13:12:53 -0700 | [diff] [blame] | 21 | #include <linux/btrfs.h> |
| 22 | #include <linux/types.h> |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 23 | #include <stddef.h> |
Christopher Ferris | 8b7fdc9 | 2023-02-21 13:36:32 -0800 | [diff] [blame^] | 24 | #define BTRFS_MAGIC 0x4D5F53665248425FULL |
| 25 | #define BTRFS_MAX_LEVEL 8 |
| 26 | #define BTRFS_NAME_LEN 255 |
| 27 | #define BTRFS_LINK_MAX 65535U |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 28 | #define BTRFS_ROOT_TREE_OBJECTID 1ULL |
| 29 | #define BTRFS_EXTENT_TREE_OBJECTID 2ULL |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 30 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 34 | #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 Ferris | 10a76e6 | 2022-06-08 13:31:52 -0700 | [diff] [blame] | 38 | #define BTRFS_BLOCK_GROUP_TREE_OBJECTID 11ULL |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 39 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 43 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 47 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 51 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 55 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 59 | #define BTRFS_INODE_EXTREF_KEY 13 |
| 60 | #define BTRFS_XATTR_ITEM_KEY 24 |
Christopher Ferris | 2abfa9e | 2021-11-01 16:26:06 -0700 | [diff] [blame] | 61 | #define BTRFS_VERITY_DESC_ITEM_KEY 36 |
| 62 | #define BTRFS_VERITY_MERKLE_ITEM_KEY 37 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 63 | #define BTRFS_ORPHAN_ITEM_KEY 48 |
| 64 | #define BTRFS_DIR_LOG_ITEM_KEY 60 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 65 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 69 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 73 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 77 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 81 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 85 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 89 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 93 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 97 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 101 | #define BTRFS_STRING_ITEM_KEY 253 |
Christopher Ferris | 05667cd | 2021-02-16 16:01:34 -0800 | [diff] [blame] | 102 | #define BTRFS_MAX_METADATA_BLOCKSIZE 65536 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 103 | #define BTRFS_CSUM_SIZE 32 |
Christopher Ferris | 9584fa4 | 2019-12-09 15:36:13 -0800 | [diff] [blame] | 104 | enum btrfs_csum_type { |
| 105 | BTRFS_CSUM_TYPE_CRC32 = 0, |
Christopher Ferris | d32ca14 | 2020-02-04 16:16:51 -0800 | [diff] [blame] | 106 | BTRFS_CSUM_TYPE_XXHASH = 1, |
| 107 | BTRFS_CSUM_TYPE_SHA256 = 2, |
| 108 | BTRFS_CSUM_TYPE_BLAKE2 = 3, |
Christopher Ferris | 9584fa4 | 2019-12-09 15:36:13 -0800 | [diff] [blame] | 109 | }; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 110 | #define BTRFS_FT_UNKNOWN 0 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 111 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 115 | #define BTRFS_FT_FIFO 5 |
| 116 | #define BTRFS_FT_SOCK 6 |
| 117 | #define BTRFS_FT_SYMLINK 7 |
| 118 | #define BTRFS_FT_XATTR 8 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 119 | #define BTRFS_FT_MAX 9 |
Christopher Ferris | 8b7fdc9 | 2023-02-21 13:36:32 -0800 | [diff] [blame^] | 120 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 137 | struct btrfs_disk_key { |
| 138 | __le64 objectid; |
| 139 | __u8 type; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 140 | __le64 offset; |
| 141 | } __attribute__((__packed__)); |
| 142 | struct btrfs_key { |
| 143 | __u64 objectid; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 144 | __u8 type; |
| 145 | __u64 offset; |
| 146 | } __attribute__((__packed__)); |
Christopher Ferris | 8b7fdc9 | 2023-02-21 13:36:32 -0800 | [diff] [blame^] | 147 | struct 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 |
| 160 | struct 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__)); |
| 185 | struct btrfs_item { |
| 186 | struct btrfs_disk_key key; |
| 187 | __le32 offset; |
| 188 | __le32 size; |
| 189 | } __attribute__((__packed__)); |
| 190 | struct btrfs_leaf { |
| 191 | struct btrfs_header header; |
| 192 | struct btrfs_item items[]; |
| 193 | } __attribute__((__packed__)); |
| 194 | struct btrfs_key_ptr { |
| 195 | struct btrfs_disk_key key; |
| 196 | __le64 blockptr; |
| 197 | __le64 generation; |
| 198 | } __attribute__((__packed__)); |
| 199 | struct btrfs_node { |
| 200 | struct btrfs_header header; |
| 201 | struct btrfs_key_ptr ptrs[]; |
| 202 | } __attribute__((__packed__)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 203 | struct btrfs_dev_item { |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 204 | __le64 devid; |
| 205 | __le64 total_bytes; |
| 206 | __le64 bytes_used; |
| 207 | __le32 io_align; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 208 | __le32 io_width; |
| 209 | __le32 sector_size; |
| 210 | __le64 type; |
| 211 | __le64 generation; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 212 | __le64 start_offset; |
| 213 | __le32 dev_group; |
| 214 | __u8 seek_speed; |
| 215 | __u8 bandwidth; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 216 | __u8 uuid[BTRFS_UUID_SIZE]; |
| 217 | __u8 fsid[BTRFS_UUID_SIZE]; |
| 218 | } __attribute__((__packed__)); |
| 219 | struct btrfs_stripe { |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 220 | __le64 devid; |
| 221 | __le64 offset; |
| 222 | __u8 dev_uuid[BTRFS_UUID_SIZE]; |
| 223 | } __attribute__((__packed__)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 224 | struct btrfs_chunk { |
| 225 | __le64 length; |
| 226 | __le64 owner; |
| 227 | __le64 stripe_len; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 228 | __le64 type; |
| 229 | __le32 io_align; |
| 230 | __le32 io_width; |
| 231 | __le32 sector_size; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 232 | __le16 num_stripes; |
| 233 | __le16 sub_stripes; |
| 234 | struct btrfs_stripe stripe; |
| 235 | } __attribute__((__packed__)); |
Christopher Ferris | 8b7fdc9 | 2023-02-21 13:36:32 -0800 | [diff] [blame^] | 236 | struct 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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 275 | #define BTRFS_FREE_SPACE_EXTENT 1 |
| 276 | #define BTRFS_FREE_SPACE_BITMAP 2 |
| 277 | struct btrfs_free_space_entry { |
| 278 | __le64 offset; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 279 | __le64 bytes; |
| 280 | __u8 type; |
| 281 | } __attribute__((__packed__)); |
| 282 | struct btrfs_free_space_header { |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 283 | struct btrfs_disk_key location; |
| 284 | __le64 generation; |
| 285 | __le64 num_entries; |
| 286 | __le64 num_bitmaps; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 287 | } __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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 291 | #define BTRFS_SUPER_FLAG_SEEDING (1ULL << 32) |
| 292 | #define BTRFS_SUPER_FLAG_METADUMP (1ULL << 33) |
Christopher Ferris | 76a1d45 | 2018-06-27 14:12:29 -0700 | [diff] [blame] | 293 | #define BTRFS_SUPER_FLAG_METADUMP_V2 (1ULL << 34) |
| 294 | #define BTRFS_SUPER_FLAG_CHANGING_FSID (1ULL << 35) |
Christopher Ferris | d842e43 | 2019-03-07 10:21:59 -0800 | [diff] [blame] | 295 | #define BTRFS_SUPER_FLAG_CHANGING_FSID_V2 (1ULL << 36) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 296 | struct btrfs_extent_item { |
| 297 | __le64 refs; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 298 | __le64 generation; |
| 299 | __le64 flags; |
| 300 | } __attribute__((__packed__)); |
| 301 | struct btrfs_extent_item_v0 { |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 302 | __le32 refs; |
| 303 | } __attribute__((__packed__)); |
| 304 | #define BTRFS_EXTENT_FLAG_DATA (1ULL << 0) |
| 305 | #define BTRFS_EXTENT_FLAG_TREE_BLOCK (1ULL << 1) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 306 | #define BTRFS_BLOCK_FLAG_FULL_BACKREF (1ULL << 8) |
Christopher Ferris | 8b7fdc9 | 2023-02-21 13:36:32 -0800 | [diff] [blame^] | 307 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 312 | #define BTRFS_EXTENT_FLAG_SUPER (1ULL << 48) |
| 313 | struct btrfs_tree_block_info { |
| 314 | struct btrfs_disk_key key; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 315 | __u8 level; |
| 316 | } __attribute__((__packed__)); |
| 317 | struct btrfs_extent_data_ref { |
| 318 | __le64 root; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 319 | __le64 objectid; |
| 320 | __le64 offset; |
| 321 | __le32 count; |
| 322 | } __attribute__((__packed__)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 323 | struct btrfs_shared_data_ref { |
| 324 | __le32 count; |
| 325 | } __attribute__((__packed__)); |
| 326 | struct btrfs_extent_inline_ref { |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 327 | __u8 type; |
| 328 | __le64 offset; |
| 329 | } __attribute__((__packed__)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 330 | struct btrfs_dev_extent { |
| 331 | __le64 chunk_tree; |
| 332 | __le64 chunk_objectid; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 333 | __le64 chunk_offset; |
| 334 | __le64 length; |
| 335 | __u8 chunk_tree_uuid[BTRFS_UUID_SIZE]; |
| 336 | } __attribute__((__packed__)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 337 | struct btrfs_inode_ref { |
| 338 | __le64 index; |
| 339 | __le16 name_len; |
| 340 | } __attribute__((__packed__)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 341 | struct btrfs_inode_extref { |
| 342 | __le64 parent_objectid; |
| 343 | __le64 index; |
| 344 | __le16 name_len; |
Christopher Ferris | 7447a1c | 2022-10-04 18:24:44 -0700 | [diff] [blame] | 345 | __u8 name[]; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 346 | } __attribute__((__packed__)); |
| 347 | struct btrfs_timespec { |
| 348 | __le64 sec; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 349 | __le32 nsec; |
| 350 | } __attribute__((__packed__)); |
| 351 | struct btrfs_inode_item { |
| 352 | __le64 generation; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 353 | __le64 transid; |
| 354 | __le64 size; |
| 355 | __le64 nbytes; |
| 356 | __le64 block_group; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 357 | __le32 nlink; |
| 358 | __le32 uid; |
| 359 | __le32 gid; |
| 360 | __le32 mode; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 361 | __le64 rdev; |
| 362 | __le64 flags; |
| 363 | __le64 sequence; |
| 364 | __le64 reserved[4]; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 365 | struct btrfs_timespec atime; |
| 366 | struct btrfs_timespec ctime; |
| 367 | struct btrfs_timespec mtime; |
| 368 | struct btrfs_timespec otime; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 369 | } __attribute__((__packed__)); |
| 370 | struct btrfs_dir_log_item { |
| 371 | __le64 end; |
| 372 | } __attribute__((__packed__)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 373 | struct btrfs_dir_item { |
| 374 | struct btrfs_disk_key location; |
| 375 | __le64 transid; |
| 376 | __le16 data_len; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 377 | __le16 name_len; |
| 378 | __u8 type; |
| 379 | } __attribute__((__packed__)); |
| 380 | #define BTRFS_ROOT_SUBVOL_RDONLY (1ULL << 0) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 381 | #define BTRFS_ROOT_SUBVOL_DEAD (1ULL << 48) |
| 382 | struct btrfs_root_item { |
| 383 | struct btrfs_inode_item inode; |
| 384 | __le64 generation; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 385 | __le64 root_dirid; |
| 386 | __le64 bytenr; |
| 387 | __le64 byte_limit; |
| 388 | __le64 bytes_used; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 389 | __le64 last_snapshot; |
| 390 | __le64 flags; |
| 391 | __le32 refs; |
| 392 | struct btrfs_disk_key drop_progress; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 393 | __u8 drop_level; |
| 394 | __u8 level; |
| 395 | __le64 generation_v2; |
| 396 | __u8 uuid[BTRFS_UUID_SIZE]; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 397 | __u8 parent_uuid[BTRFS_UUID_SIZE]; |
| 398 | __u8 received_uuid[BTRFS_UUID_SIZE]; |
| 399 | __le64 ctransid; |
| 400 | __le64 otransid; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 401 | __le64 stransid; |
| 402 | __le64 rtransid; |
| 403 | struct btrfs_timespec ctime; |
| 404 | struct btrfs_timespec otime; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 405 | struct btrfs_timespec stime; |
| 406 | struct btrfs_timespec rtime; |
| 407 | __le64 reserved[8]; |
| 408 | } __attribute__((__packed__)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 409 | struct btrfs_root_ref { |
| 410 | __le64 dirid; |
| 411 | __le64 sequence; |
| 412 | __le16 name_len; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 413 | } __attribute__((__packed__)); |
| 414 | struct btrfs_disk_balance_args { |
| 415 | __le64 profiles; |
| 416 | union { |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 417 | __le64 usage; |
| 418 | struct { |
| 419 | __le32 usage_min; |
| 420 | __le32 usage_max; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 421 | }; |
| 422 | }; |
| 423 | __le64 devid; |
| 424 | __le64 pstart; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 425 | __le64 pend; |
| 426 | __le64 vstart; |
| 427 | __le64 vend; |
| 428 | __le64 target; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 429 | __le64 flags; |
| 430 | union { |
| 431 | __le64 limit; |
| 432 | struct { |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 433 | __le32 limit_min; |
| 434 | __le32 limit_max; |
| 435 | }; |
| 436 | }; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 437 | __le32 stripes_min; |
| 438 | __le32 stripes_max; |
| 439 | __le64 unused[6]; |
| 440 | } __attribute__((__packed__)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 441 | struct btrfs_balance_item { |
| 442 | __le64 flags; |
| 443 | struct btrfs_disk_balance_args data; |
| 444 | struct btrfs_disk_balance_args meta; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 445 | struct btrfs_disk_balance_args sys; |
| 446 | __le64 unused[4]; |
| 447 | } __attribute__((__packed__)); |
Christopher Ferris | d32ca14 | 2020-02-04 16:16:51 -0800 | [diff] [blame] | 448 | enum { |
| 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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 454 | struct btrfs_file_extent_item { |
| 455 | __le64 generation; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 456 | __le64 ram_bytes; |
| 457 | __u8 compression; |
| 458 | __u8 encryption; |
| 459 | __le16 other_encoding; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 460 | __u8 type; |
| 461 | __le64 disk_bytenr; |
| 462 | __le64 disk_num_bytes; |
| 463 | __le64 offset; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 464 | __le64 num_bytes; |
| 465 | } __attribute__((__packed__)); |
| 466 | struct btrfs_csum_item { |
| 467 | __u8 csum; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 468 | } __attribute__((__packed__)); |
| 469 | struct btrfs_dev_stats_item { |
| 470 | __le64 values[BTRFS_DEV_STAT_VALUES_MAX]; |
| 471 | } __attribute__((__packed__)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 472 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 474 | struct btrfs_dev_replace_item { |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 475 | __le64 src_devid; |
| 476 | __le64 cursor_left; |
| 477 | __le64 cursor_right; |
| 478 | __le64 cont_reading_from_srcdev_mode; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 479 | __le64 replace_state; |
| 480 | __le64 time_started; |
| 481 | __le64 time_stopped; |
| 482 | __le64 num_write_errors; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 483 | __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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 487 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 491 | #define BTRFS_BLOCK_GROUP_RAID10 (1ULL << 6) |
| 492 | #define BTRFS_BLOCK_GROUP_RAID5 (1ULL << 7) |
| 493 | #define BTRFS_BLOCK_GROUP_RAID6 (1ULL << 8) |
Christopher Ferris | d32ca14 | 2020-02-04 16:16:51 -0800 | [diff] [blame] | 494 | #define BTRFS_BLOCK_GROUP_RAID1C3 (1ULL << 9) |
| 495 | #define BTRFS_BLOCK_GROUP_RAID1C4 (1ULL << 10) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 496 | #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] | 497 | #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] | 498 | #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] | 499 | #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] | 500 | #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] | 501 | #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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 504 | struct btrfs_block_group_item { |
| 505 | __le64 used; |
| 506 | __le64 chunk_objectid; |
| 507 | __le64 flags; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 508 | } __attribute__((__packed__)); |
| 509 | struct btrfs_free_space_info { |
| 510 | __le32 extent_count; |
| 511 | __le32 flags; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 512 | } __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 Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 516 | #define BTRFS_QGROUP_STATUS_FLAG_RESCAN (1ULL << 1) |
| 517 | #define BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT (1ULL << 2) |
Christopher Ferris | 6cd53a5 | 2022-12-12 23:39:16 +0000 | [diff] [blame] | 518 | #define BTRFS_QGROUP_STATUS_FLAGS_MASK (BTRFS_QGROUP_STATUS_FLAG_ON | BTRFS_QGROUP_STATUS_FLAG_RESCAN | BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 519 | #define BTRFS_QGROUP_STATUS_VERSION 1 |
| 520 | struct btrfs_qgroup_status_item { |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 521 | __le64 version; |
| 522 | __le64 generation; |
| 523 | __le64 flags; |
| 524 | __le64 rescan; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 525 | } __attribute__((__packed__)); |
| 526 | struct btrfs_qgroup_info_item { |
| 527 | __le64 generation; |
| 528 | __le64 rfer; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 529 | __le64 rfer_cmpr; |
| 530 | __le64 excl; |
| 531 | __le64 excl_cmpr; |
| 532 | } __attribute__((__packed__)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 533 | struct btrfs_qgroup_limit_item { |
| 534 | __le64 flags; |
| 535 | __le64 max_rfer; |
| 536 | __le64 max_excl; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 537 | __le64 rsv_rfer; |
| 538 | __le64 rsv_excl; |
| 539 | } __attribute__((__packed__)); |
Christopher Ferris | 2abfa9e | 2021-11-01 16:26:06 -0700 | [diff] [blame] | 540 | struct btrfs_verity_descriptor_item { |
| 541 | __le64 size; |
| 542 | __le64 reserved[2]; |
| 543 | __u8 encryption; |
| 544 | } __attribute__((__packed__)); |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 545 | #endif |