ReactOS 0.4.16-dev-289-g096a551
btrfs.h File Reference
#include <fs/crc32c.h>
#include <pshpack1.h>
#include <poppack.h>
Include dependency graph for btrfs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  btrfs_disk_key
 
struct  btrfs_header
 
struct  btrfs_item
 
struct  btrfs_leaf
 
struct  btrfs_key_ptr
 
struct  btrfs_node
 
struct  btrfs_dev_item
 
struct  btrfs_stripe
 
struct  btrfs_chunk
 
struct  btrfs_inode_ref
 
struct  btrfs_timespec
 
struct  btrfs_inode_item
 
struct  btrfs_dir_item
 
struct  btrfs_root_item
 
struct  btrfs_root_ref
 
struct  btrfs_file_extent_item
 
struct  btrfs_super_block
 
union  tree_buf
 
struct  btrfs_path
 
struct  btrfs_chunk_map_item
 
struct  btrfs_chunk_map
 
struct  btrfs_file_info
 

Macros

#define btrfs_crc32c(name, len)   crc32c_le((u32)~1, name, len)
 
#define BTRFS_SUPER_INFO_OFFSET   (64 * 1024)
 
#define BTRFS_SUPER_INFO_SIZE   4096
 
#define BTRFS_MAX_LEAF_SIZE   4096
 
#define BTRFS_BLOCK_SHIFT   12
 
#define BTRFS_BLOCK_SIZE   (1 << BTRFS_BLOCK_SHIFT)
 
#define BTRFS_SUPER_MIRROR_MAX   3
 
#define BTRFS_SUPER_MIRROR_SHIFT   12
 
#define BTRFS_CSUM_SIZE   32
 
#define BTRFS_FSID_SIZE   16
 
#define BTRFS_LABEL_SIZE   256
 
#define BTRFS_SYSTEM_CHUNK_ARRAY_SIZE   2048
 
#define BTRFS_UUID_SIZE   16
 
#define BTRFS_VOL_NAME_MAX   255
 
#define BTRFS_NAME_MAX   255
 
#define BTRFS_MAGIC   "_BHRfS_M"
 
#define BTRFS_MAGIC_L   8
 
#define BTRFS_MAGIC_N   0x4d5f53665248425fULL
 
#define BTRFS_SUPER_FLAG_METADUMP   (1ULL << 33)
 
#define BTRFS_DEV_ITEM_KEY   216
 
#define BTRFS_CHUNK_ITEM_KEY   228
 
#define BTRFS_ROOT_REF_KEY   156
 
#define BTRFS_ROOT_ITEM_KEY   132
 
#define BTRFS_EXTENT_DATA_KEY   108
 
#define BTRFS_DIR_ITEM_KEY   84
 
#define BTRFS_DIR_INDEX_KEY   96
 
#define BTRFS_INODE_ITEM_KEY   1
 
#define BTRFS_INODE_REF_KEY   12
 
#define BTRFS_EXTENT_TREE_OBJECTID   2ULL
 
#define BTRFS_FS_TREE_OBJECTID   5ULL
 
#define BTRFS_FIRST_FREE_OBJECTID   256ULL
 
#define BTRFS_LAST_FREE_OBJECTID   -256ULL
 
#define BTRFS_FIRST_CHUNK_TREE_OBJECTID   256ULL
 
#define BTRFS_FILE_EXTENT_INLINE   0
 
#define BTRFS_FILE_EXTENT_REG   1
 
#define BTRFS_FILE_EXTENT_PREALLOC   2
 
#define BTRFS_MAX_LEVEL   8
 
#define BTRFS_MAX_CHUNK_ENTRIES   256
 
#define BTRFS_DEV_ITEMS_OBJECTID   1ULL
 
#define BTRFS_FT_REG_FILE   1
 
#define BTRFS_FT_DIR   2
 
#define BTRFS_FT_SYMLINK   7
 
#define BTRFS_FT_XATTR   8
 
#define BTRFS_FT_MAX   9
 
#define BTRFS_COMPRESS_NONE   0
 
#define BTRFS_COMPRESS_ZLIB   1
 
#define BTRFS_COMPRESS_LZO   2
 
#define ROOT_DIR_WORD   0x002f
 

Typedefs

typedef UCHAR u8
 
typedef USHORT u16
 
typedef ULONG32 u32
 
typedef ULONG64 u64
 
typedef u8 __u8
 
typedef u16 __u16
 
typedef u32 __u32
 
typedef u64 __u64
 
typedef struct _BTRFS_INFOPBTRFS_INFO
 
typedef struct btrfs_file_infopbtrfs_file_info
 

Functions

const DEVVTBLBtrFsMount (ULONG DeviceId)
 

Macro Definition Documentation

◆ BTRFS_BLOCK_SHIFT

#define BTRFS_BLOCK_SHIFT   12

Definition at line 28 of file btrfs.h.

◆ BTRFS_BLOCK_SIZE

#define BTRFS_BLOCK_SIZE   (1 << BTRFS_BLOCK_SHIFT)

Definition at line 29 of file btrfs.h.

◆ BTRFS_CHUNK_ITEM_KEY

#define BTRFS_CHUNK_ITEM_KEY   228

Definition at line 49 of file btrfs.h.

◆ BTRFS_COMPRESS_LZO

#define BTRFS_COMPRESS_LZO   2

Definition at line 82 of file btrfs.h.

◆ BTRFS_COMPRESS_NONE

#define BTRFS_COMPRESS_NONE   0

Definition at line 80 of file btrfs.h.

◆ BTRFS_COMPRESS_ZLIB

#define BTRFS_COMPRESS_ZLIB   1

Definition at line 81 of file btrfs.h.

◆ btrfs_crc32c

#define btrfs_crc32c (   name,
  len 
)    crc32c_le((u32)~1, name, len)

Definition at line 23 of file btrfs.h.

◆ BTRFS_CSUM_SIZE

#define BTRFS_CSUM_SIZE   32

Definition at line 33 of file btrfs.h.

◆ BTRFS_DEV_ITEM_KEY

#define BTRFS_DEV_ITEM_KEY   216

Definition at line 48 of file btrfs.h.

◆ BTRFS_DEV_ITEMS_OBJECTID

#define BTRFS_DEV_ITEMS_OBJECTID   1ULL

Definition at line 72 of file btrfs.h.

◆ BTRFS_DIR_INDEX_KEY

#define BTRFS_DIR_INDEX_KEY   96

Definition at line 54 of file btrfs.h.

◆ BTRFS_DIR_ITEM_KEY

#define BTRFS_DIR_ITEM_KEY   84

Definition at line 53 of file btrfs.h.

◆ BTRFS_EXTENT_DATA_KEY

#define BTRFS_EXTENT_DATA_KEY   108

Definition at line 52 of file btrfs.h.

◆ BTRFS_EXTENT_TREE_OBJECTID

#define BTRFS_EXTENT_TREE_OBJECTID   2ULL

Definition at line 58 of file btrfs.h.

◆ BTRFS_FILE_EXTENT_INLINE

#define BTRFS_FILE_EXTENT_INLINE   0

Definition at line 65 of file btrfs.h.

◆ BTRFS_FILE_EXTENT_PREALLOC

#define BTRFS_FILE_EXTENT_PREALLOC   2

Definition at line 67 of file btrfs.h.

◆ BTRFS_FILE_EXTENT_REG

#define BTRFS_FILE_EXTENT_REG   1

Definition at line 66 of file btrfs.h.

◆ BTRFS_FIRST_CHUNK_TREE_OBJECTID

#define BTRFS_FIRST_CHUNK_TREE_OBJECTID   256ULL

Definition at line 63 of file btrfs.h.

◆ BTRFS_FIRST_FREE_OBJECTID

#define BTRFS_FIRST_FREE_OBJECTID   256ULL

Definition at line 61 of file btrfs.h.

◆ BTRFS_FS_TREE_OBJECTID

#define BTRFS_FS_TREE_OBJECTID   5ULL

Definition at line 59 of file btrfs.h.

◆ BTRFS_FSID_SIZE

#define BTRFS_FSID_SIZE   16

Definition at line 34 of file btrfs.h.

◆ BTRFS_FT_DIR

#define BTRFS_FT_DIR   2

Definition at line 75 of file btrfs.h.

◆ BTRFS_FT_MAX

#define BTRFS_FT_MAX   9

Definition at line 78 of file btrfs.h.

◆ BTRFS_FT_REG_FILE

#define BTRFS_FT_REG_FILE   1

Definition at line 74 of file btrfs.h.

◆ BTRFS_FT_SYMLINK

#define BTRFS_FT_SYMLINK   7

Definition at line 76 of file btrfs.h.

◆ BTRFS_FT_XATTR

#define BTRFS_FT_XATTR   8

Definition at line 77 of file btrfs.h.

◆ BTRFS_INODE_ITEM_KEY

#define BTRFS_INODE_ITEM_KEY   1

Definition at line 55 of file btrfs.h.

◆ BTRFS_INODE_REF_KEY

#define BTRFS_INODE_REF_KEY   12

Definition at line 56 of file btrfs.h.

◆ BTRFS_LABEL_SIZE

#define BTRFS_LABEL_SIZE   256

Definition at line 35 of file btrfs.h.

◆ BTRFS_LAST_FREE_OBJECTID

#define BTRFS_LAST_FREE_OBJECTID   -256ULL

Definition at line 62 of file btrfs.h.

◆ BTRFS_MAGIC

#define BTRFS_MAGIC   "_BHRfS_M"

Definition at line 42 of file btrfs.h.

◆ BTRFS_MAGIC_L

#define BTRFS_MAGIC_L   8

Definition at line 43 of file btrfs.h.

◆ BTRFS_MAGIC_N

#define BTRFS_MAGIC_N   0x4d5f53665248425fULL

Definition at line 44 of file btrfs.h.

◆ BTRFS_MAX_CHUNK_ENTRIES

#define BTRFS_MAX_CHUNK_ENTRIES   256

Definition at line 70 of file btrfs.h.

◆ BTRFS_MAX_LEAF_SIZE

#define BTRFS_MAX_LEAF_SIZE   4096

Definition at line 27 of file btrfs.h.

◆ BTRFS_MAX_LEVEL

#define BTRFS_MAX_LEVEL   8

Definition at line 69 of file btrfs.h.

◆ BTRFS_NAME_MAX

#define BTRFS_NAME_MAX   255

Definition at line 40 of file btrfs.h.

◆ BTRFS_ROOT_ITEM_KEY

#define BTRFS_ROOT_ITEM_KEY   132

Definition at line 51 of file btrfs.h.

◆ BTRFS_ROOT_REF_KEY

#define BTRFS_ROOT_REF_KEY   156

Definition at line 50 of file btrfs.h.

◆ BTRFS_SUPER_FLAG_METADUMP

#define BTRFS_SUPER_FLAG_METADUMP   (1ULL << 33)

Definition at line 46 of file btrfs.h.

◆ BTRFS_SUPER_INFO_OFFSET

#define BTRFS_SUPER_INFO_OFFSET   (64 * 1024)

Definition at line 25 of file btrfs.h.

◆ BTRFS_SUPER_INFO_SIZE

#define BTRFS_SUPER_INFO_SIZE   4096

Definition at line 26 of file btrfs.h.

◆ BTRFS_SUPER_MIRROR_MAX

#define BTRFS_SUPER_MIRROR_MAX   3

Definition at line 31 of file btrfs.h.

◆ BTRFS_SUPER_MIRROR_SHIFT

#define BTRFS_SUPER_MIRROR_SHIFT   12

Definition at line 32 of file btrfs.h.

◆ BTRFS_SYSTEM_CHUNK_ARRAY_SIZE

#define BTRFS_SYSTEM_CHUNK_ARRAY_SIZE   2048

Definition at line 36 of file btrfs.h.

◆ BTRFS_UUID_SIZE

#define BTRFS_UUID_SIZE   16

Definition at line 37 of file btrfs.h.

◆ BTRFS_VOL_NAME_MAX

#define BTRFS_VOL_NAME_MAX   255

Definition at line 39 of file btrfs.h.

◆ ROOT_DIR_WORD

#define ROOT_DIR_WORD   0x002f

Definition at line 84 of file btrfs.h.

Typedef Documentation

◆ __u16

typedef u16 __u16

Definition at line 18 of file btrfs.h.

◆ __u32

typedef u32 __u32

Definition at line 19 of file btrfs.h.

◆ __u64

typedef u64 __u64

Definition at line 20 of file btrfs.h.

◆ __u8

typedef u8 __u8

Definition at line 17 of file btrfs.h.

◆ pbtrfs_file_info

◆ PBTRFS_INFO

Definition at line 412 of file btrfs.h.

◆ u16

typedef USHORT u16

Definition at line 13 of file btrfs.h.

◆ u32

typedef ULONG32 u32

Definition at line 14 of file btrfs.h.

◆ u64

typedef ULONG64 u64

Definition at line 15 of file btrfs.h.

◆ u8

typedef UCHAR u8

Definition at line 12 of file btrfs.h.

Function Documentation

◆ BtrFsMount()

const DEVVTBL * BtrFsMount ( ULONG  DeviceId)

Definition at line 1297 of file btrfs.c.

1298{
1299 PBTRFS_INFO BtrFsInfo;
1300 struct btrfs_path path;
1301 struct btrfs_root_item fs_root_item;
1302
1303 TRACE("Enter BtrFsMount(%lu)\n", DeviceId);
1304
1305 BtrFsInfo = FrLdrTempAlloc(sizeof(BTRFS_INFO), TAG_BTRFS_INFO);
1306 if (!BtrFsInfo)
1307 return NULL;
1308 RtlZeroMemory(BtrFsInfo, sizeof(BTRFS_INFO));
1309
1310 /* Read the SuperBlock */
1311 if (!disk_read(DeviceId, BTRFS_SUPER_INFO_OFFSET,
1312 &BtrFsInfo->SuperBlock, sizeof(BtrFsInfo->SuperBlock)))
1313 {
1314 FrLdrTempFree(BtrFsInfo, TAG_BTRFS_INFO);
1315 return NULL;
1316 }
1317
1318 /* Check if SuperBlock is valid. If yes, return BTRFS function table */
1319 if (BtrFsInfo->SuperBlock.magic != BTRFS_MAGIC_N)
1320 {
1321 FrLdrTempFree(BtrFsInfo, TAG_BTRFS_INFO);
1322 return NULL;
1323 }
1324
1325 BtrFsInfo->DeviceId = DeviceId;
1326 TRACE("BtrFsMount(%lu) superblock magic ok\n", DeviceId);
1327
1329
1330 btrfs_read_sys_chunk_array(BtrFsInfo);
1331 btrfs_read_chunk_tree(BtrFsInfo);
1332
1333 /* setup roots */
1334 fs_root_item.bytenr = BtrFsInfo->SuperBlock.root;
1335 fs_root_item.level = BtrFsInfo->SuperBlock.root_level;
1336
1337 init_path(&BtrFsInfo->SuperBlock, &path);
1338 if (!BtrFsSearchTreeType(BtrFsInfo, &fs_root_item, BTRFS_FS_TREE_OBJECTID, BTRFS_ROOT_ITEM_KEY, &path))
1339 {
1340 free_path(&path);
1341 FrLdrTempFree(BtrFsInfo, TAG_BTRFS_INFO);
1342 return NULL;
1343 }
1344
1345 BtrFsInfo->FsRoot = *(struct btrfs_root_item *) path_current_data(&path);
1346
1347 free_path(&path);
1348
1349 /* Remember BTRFS volume information */
1350 BtrFsVolumes[DeviceId] = BtrFsInfo;
1351
1352 TRACE("BtrFsMount(%lu) success\n", DeviceId);
1353 return &BtrFsFuncTable;
1354}
#define BTRFS_FS_TREE_OBJECTID
Definition: btrfs.h:59
#define BTRFS_ROOT_ITEM_KEY
Definition: btrfs.h:51
#define BTRFS_SUPER_INFO_OFFSET
Definition: btrfs.h:25
#define BTRFS_MAGIC_N
Definition: btrfs.h:44
static void btrfs_init_crc32c(void)
Definition: crc32c.h:39
FORCEINLINE PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: mm.h:188
FORCEINLINE VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: mm.h:197
static void free_path(struct btrfs_path *path)
Definition: btrfs.c:173
static void init_path(const struct btrfs_super_block *sb, struct btrfs_path *path)
Definition: btrfs.c:167
static void btrfs_read_chunk_tree(PBTRFS_INFO BtrFsInfo)
Definition: btrfs.c:476
PBTRFS_INFO BtrFsVolumes[MAX_FDS]
Definition: btrfs.c:34
static void btrfs_read_sys_chunk_array(PBTRFS_INFO BtrFsInfo)
Definition: btrfs.c:440
#define TAG_BTRFS_INFO
Definition: btrfs.c:15
static BOOLEAN disk_read(ULONG DeviceId, u64 physical, void *dest, u32 count)
Definition: btrfs.c:253
static UCHAR * path_current_data(struct btrfs_path *path)
Definition: btrfs.c:183
static BOOLEAN BtrFsSearchTreeType(PBTRFS_INFO BtrFsInfo, const struct btrfs_root_item *root, u64 objectid, u8 type, struct btrfs_path *path)
Definition: btrfs.c:365
const DEVVTBL BtrFsFuncTable
Definition: btrfs.c:1287
#define NULL
Definition: types.h:112
#define TRACE(s)
Definition: solgame.cpp:4
struct btrfs_super_block SuperBlock
Definition: btrfs.c:28
struct btrfs_root_item FsRoot
Definition: btrfs.c:30
ULONG DeviceId
Definition: btrfs.c:27
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262