15#define TAG_BTRFS_INFO 'IftB'
16#define TAG_BTRFS_CHUNK_MAP 'CftB'
17#define TAG_BTRFS_NODE 'NftB'
18#define TAG_BTRFS_FILE 'FftB'
19#define TAG_BTRFS_LINK 'LftB'
21#define INVALID_INODE _UI64_MAX
22#define INVALID_ADDRESS _UI64_MAX
23#define READ_ERROR _UI64_MAX
52 mid = (low + high) / 2;
111 TRACE(
"too many chunk items\n");
116 chunk_map->
map[
i] = chunk_map->
map[
i - 1];
137 TRACE(
"inserting chunk log: %llx len: %llx devid: %llx phys: %llx\n",
146 TRACE(
"insert finished. Printing chunk map:\n------------------------------\n");
150 itm = &chunk_map->
map[
i];
151 TRACE(
"%llx..%llx -> %llx..%llx, devid: %llu\n",
180 return &
path->tree_buf->leaf.items[
path->slots[0]];
247 TRACE(
"Address translation: 0x%llx -> 0x%llx\n",
logical,
266 ERR(
"ArcSeek returned status %lu\n",
Status);
273 ERR(
"ArcRead returned status %lu\n",
Status);
286 u64 physical, logical = loffset;
288 TRACE(
"BtrFsSearchTree called: offset: 0x%llx, level: %u (%llu %u %llu)\n",
293 ERR(
"Path struct is not allocated\n");
297 for (lvl =
level; lvl >= 0; lvl--)
304 ERR(
"Error when reading tree node, loffset: 0x%llx, poffset: 0x%llx, level: %u\n",
305 logical, physical, lvl);
311 ERR(
"Error when searching in tree: expected lvl=%u but got %u\n",
316 TRACE(
"BtrFsSearchTree loop, level %u, loffset: 0x%llx\n", lvl, logical);
342 path->offsets[lvl] = logical;
350 TRACE(
"BtrFsSearchTree found item (%llu %u %llu) offset: %lu, size: %lu, returning %lu\n",
389 if (!
path->itemsnr[0])
448 TRACE(
"reading chunk array\n-----------------------------\n");
450 while (cur < sb->sys_chunk_array_size)
453 TRACE(
"chunk key objectid: %llx, offset: %llx, type: %u\n",
459 TRACE(
"chunk stripe_len: %llx\n",
chunk->stripe_len);
461 TRACE(
"chunk io_align: %u\n",
chunk->io_align);
462 TRACE(
"chunk io_width: %u\n",
chunk->io_width);
463 TRACE(
"chunk sector_size: %u\n",
chunk->sector_size);
464 TRACE(
"chunk num_stripes: %u\n",
chunk->num_stripes);
465 TRACE(
"chunk sub_stripes: %u\n",
chunk->sub_stripes);
468 TRACE(
"read_sys_chunk_array() cur=%d\n",
cur);
487 TRACE(
"warning: only support single device btrfs\n");
526 ERR(
"Invalid dir item type: %i\n",
item->type);
536 ERR(
"Invalid dir item name len: %u\n",
item->name_len);
549 const char *name_ptr;
553 this_len =
sizeof(*item) +
item->name_len +
item->data_len;
554 name_ptr = (
const char *)
item +
sizeof(*
item);
609 key.objectid = dir_haystack;
631 name_buf = (
char *)
item +
sizeof(*
item);
661 cbuf = (
const char *)
extent + data_off;
668 ERR(
"Tried to read offset (%llu) beyond extent length (%lu)\n",
offset, dlen);
677 TRACE(
"read_extent_inline %lu, \n", data_off);
682 ERR(
"No compression supported right now\n");
697 ERR(
"Tried to read offset (%llu) beyond extent length (%lu)\n",
offset, dlen);
705 if (
extent->disk_bytenr == 0 &&
extent->disk_num_bytes == 0)
714 ERR(
"Unable to convert logical address to physical: %llu\n",
extent->disk_bytenr);
765 ERR(
"No compression supported right now\n");
780 TRACE(
"btrfs_file_read inr=%llu offset=%llu size=%llu\n", inr,
offset,
size);
804 TRACE(
"Current extent: (%llu %u %llu) \n",
811 offset_in_extent = seek_pointer;
827 ERR(
"Error while reading extent\n");
835 TRACE(
"file_read size=%llu rd=%llu seek_pointer=%llu\n",
size,
rd, seek_pointer);
907 *new_root = tmp_root;
933 ERR(
"Extent for symlink %llu not of INLINE type\n", inr);
939 ERR(
"Symlink %llu extent data compressed!\n", inr);
942 else if (
extent->encryption != 0)
944 ERR(
"Symlink %llu extent data encrypted!\n", inr);
949 ERR(
"Symlink %llu extent data too long (%llu)!\n", inr,
extent->ram_bytes);
959 ERR(
"Cannot allocate %llu bytes\n",
extent->ram_bytes + 1);
964 (*target)[
extent->ram_bytes] =
'\0';
1041 if (
cur[0] ==
'/' ||
cur[0] ==
'\\')
1043 else if (
cur[0] ==
'.' && (
cur[1] ==
'/' ||
cur[1] ==
'\\'))
1059 int len, have_inode = 0;
1062 char *link_target =
NULL;
1064 if (*
cur ==
'/' || *
cur ==
'\\')
1067 inr =
root->root_dirid;
1081 if (
len == 1 &&
cur[0] ==
'.')
1084 if (
len == 2 &&
cur[0] ==
'.' &&
cur[1] ==
'.')
1100 TRACE(
"Try to find case-insensitive, path=%s inr=%llu s=%.*s\n",
path, inr,
len,
cur);
1114 TRACE(
"%s: Too much symlinks!\n");
1134 inr =
item.location.objectid;
1155 *inode_item_p = inode_item;
1165 TRACE(
"BtrFsClose %lu\n", FileId);
1179 TRACE(
"BtrFsGetFileInformation(%lu) -> FileSize = %llu, FilePointer = 0x%llx\n",
1206 BtrFsInfo->
FsRoot.root_dirid,
1217 TRACE(
"Not a regular file: %s\n",
Path);
1221 TRACE(
"found inode inr=%llu size=%llu\n", inr, temp_file_info.
inode.size);
1223 temp_file_info.
inr = inr;
1231 phandle->
Volume = BtrFsInfo;
1242 TRACE(
"BtrFsRead %lu, size=%lu \n", FileId,
Size);
1254 TRACE(
"An error occured while reading file %lu\n", FileId);
1303 TRACE(
"Enter BtrFsMount(%lu)\n", DeviceId);
1326 TRACE(
"BtrFsMount(%lu) superblock magic ok\n", DeviceId);
1352 TRACE(
"BtrFsMount(%lu) success\n", DeviceId);
#define ALIGN_DOWN_BY(size, align)
PRTL_UNICODE_STRING_BUFFER Path
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
#define DBG_DEFAULT_CHANNEL(ch)
#define BTRFS_SUPER_FLAG_METADUMP
#define btrfs_crc32c(name, len)
#define BTRFS_FIRST_CHUNK_TREE_OBJECTID
#define BTRFS_DEV_ITEMS_OBJECTID
#define BTRFS_FIRST_FREE_OBJECTID
#define BTRFS_DIR_INDEX_KEY
#define BTRFS_INODE_REF_KEY
#define BTRFS_DEV_ITEM_KEY
#define BTRFS_DIR_ITEM_KEY
#define BTRFS_COMPRESS_NONE
#define BTRFS_MAX_CHUNK_ENTRIES
#define BTRFS_FS_TREE_OBJECTID
#define BTRFS_ROOT_ITEM_KEY
#define BTRFS_SUPER_INFO_OFFSET
#define BTRFS_INODE_ITEM_KEY
#define BTRFS_FT_REG_FILE
#define BTRFS_CHUNK_ITEM_KEY
#define BTRFS_EXTENT_DATA_KEY
#define BTRFS_FILE_EXTENT_INLINE
static void btrfs_init_crc32c(void)
ARC_STATUS ArcSeek(ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
PVOID FsGetDeviceSpecific(ULONG FileId)
VOID FsSetDeviceSpecific(ULONG FileId, PVOID Specific)
ULONG FsGetDeviceId(ULONG FileId)
ARC_STATUS ArcRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
FORCEINLINE PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
FORCEINLINE VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
static u64 btrfs_file_read(PBTRFS_INFO BtrFsInfo, const struct btrfs_root_item *root, u64 inr, u64 offset, u64 size, char *buf)
ARC_STATUS BtrFsClose(ULONG FileId)
static u64 get_parent_inode(PBTRFS_INFO BtrFsInfo, const struct btrfs_root_item *root, u64 inr, struct btrfs_inode_item *inode_item)
static u64 btrfs_lookup_inode_ref(PBTRFS_INFO BtrFsInfo, const struct btrfs_root_item *root, u64 inr, struct btrfs_inode_ref *refp, char *name)
ARC_STATUS BtrFsOpen(CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
ARC_STATUS BtrFsSeek(ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
struct _BTRFS_INFO BTRFS_INFO
static const struct btrfs_disk_key * path_current_disk_key(struct btrfs_path *path)
const DEVVTBL * BtrFsMount(ULONG DeviceId)
static struct btrfs_item * path_current_item(struct btrfs_path *path)
static u64 logical_physical(struct btrfs_chunk_map *chunk_map, u64 logical)
static u64 btrfs_read_extent_reg(PBTRFS_INFO BtrFsInfo, struct btrfs_path *path, struct btrfs_file_extent_item *extent, u64 offset, u64 size, char *out)
ARC_STATUS BtrFsRead(ULONG FileId, VOID *Buffer, ULONG Size, ULONG *BytesRead)
static void free_path(struct btrfs_path *path)
#define TAG_BTRFS_CHUNK_MAP
static BOOLEAN BtrFsSearchTree(PBTRFS_INFO BtrFsInfo, const struct btrfs_root_item *root, struct btrfs_disk_key *key, struct btrfs_path *path)
static BOOLEAN _BtrFsSearchTree(PBTRFS_INFO BtrFsInfo, u64 loffset, u8 level, struct btrfs_disk_key *key, struct btrfs_path *path)
static BOOLEAN BtrFsLookupDirItemI(PBTRFS_INFO BtrFsInfo, const struct btrfs_root_item *root, u64 dir_haystack, const char *name, int name_len, struct btrfs_dir_item *ret_item)
static int next_slot(PBTRFS_INFO BtrFsInfo, struct btrfs_disk_key *key, struct btrfs_path *path)
static void insert_map(struct btrfs_chunk_map *chunk_map, const struct btrfs_disk_key *key, struct btrfs_chunk *chunk)
static int btrfs_lookup_inode(PBTRFS_INFO BtrFsInfo, const struct btrfs_root_item *root, struct btrfs_disk_key *location, struct btrfs_inode_item *item, struct btrfs_root_item *new_root)
static int next_length(const char *path)
static BOOLEAN BtrFsLookupDirItem(PBTRFS_INFO BtrFsInfo, const struct btrfs_root_item *root, u64 dir, const char *name, int name_len, struct btrfs_dir_item *item)
ARC_STATUS BtrFsGetFileInformation(ULONG FileId, FILEINFORMATION *Information)
static int btrfs_comp_keys(const struct btrfs_disk_key *k1, const struct btrfs_disk_key *k2)
static BOOLEAN btrfs_readlink(PBTRFS_INFO BtrFsInfo, const struct btrfs_root_item *root, u64 inr, char **target)
static int btrfs_comp_chunk_map(struct btrfs_chunk_map_item *m1, struct btrfs_chunk_map_item *m2)
static void init_path(const struct btrfs_super_block *sb, struct btrfs_path *path)
static void btrfs_read_chunk_tree(PBTRFS_INFO BtrFsInfo)
static int bin_search(void *ptr, int item_size, void *cmp_item, cmp_func func, int min, int max, int *slot)
static void insert_chunk_item(struct btrfs_chunk_map *chunk_map, struct btrfs_chunk_map_item *item)
PBTRFS_INFO BtrFsVolumes[MAX_FDS]
static void btrfs_read_sys_chunk_array(PBTRFS_INFO BtrFsInfo)
static u64 btrfs_read_extent_inline(struct btrfs_path *path, struct btrfs_file_extent_item *extent, u64 offset, u64 size, char *out)
static BOOLEAN disk_read(ULONG DeviceId, u64 physical, void *dest, u32 count)
static UCHAR * path_current_data(struct btrfs_path *path)
static int btrfs_comp_keys_type(const struct btrfs_disk_key *k1, const struct btrfs_disk_key *k2)
static struct btrfs_dir_item * BtrFsMatchDirItemName(struct btrfs_path *path, const char *name, int name_len)
static int prev_slot(struct btrfs_disk_key *key, struct btrfs_path *path)
static u64 btrfs_lookup_path(PBTRFS_INFO BtrFsInfo, const struct btrfs_root_item *root, u64 inr, const char *path, u8 *type_p, struct btrfs_inode_item *inode_item_p, int symlink_limit)
static const char * skip_current_directories(const char *cur)
static BOOLEAN BtrFsSearchTreeType(PBTRFS_INFO BtrFsInfo, const struct btrfs_root_item *root, u64 objectid, u8 type, struct btrfs_path *path)
const DEVVTBL BtrFsFuncTable
static unsigned long btrfs_chunk_item_size(int num_stripes)
static BOOLEAN verify_dir_item(struct btrfs_dir_item *item, u32 start, u32 total)
int(* cmp_func)(const void *ptr1, const void *ptr2)
#define _strnicmp(_String1, _String2, _MaxCount)
static void cleanup(void)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
GLuint GLuint GLsizei GLenum type
GLuint GLuint GLsizei count
GLenum GLuint GLenum GLsizei const GLchar * buf
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define memcpy(s1, s2, n)
#define offsetof(TYPE, MEMBER)
struct btrfs_super_block SuperBlock
struct btrfs_root_item FsRoot
struct btrfs_root_item ExtentRoot
struct btrfs_chunk_map ChunkMap
struct btrfs_chunk_map_item * map
struct btrfs_inode_item inode
uint8_t sys_chunk_array[SYS_CHUNK_ARRAY_SIZE]
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
struct btrfs_header header
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList