C API¶
Defines
-
BCACHEFS_ITERATOR_CLEAN(Bcachefs_iterator){.type = BTREE_ID_NR}¶
-
BCACHEFS_CLEAN(Bcachefs){ \
._extents_iter_begin = BCACHEFS_ITERATOR_CLEAN, \
._inodes_iter_begin = BCACHEFS_ITERATOR_CLEAN, \
._dirents_iter_begin = BCACHEFS_ITERATOR_CLEAN, \
._root_stats = (
Bcachefs_inode){0}, \
._root_dirent = (
Bcachefs_dirent){0} \
}
¶
Typedefs
-
typedef struct Bcachefs_iterator
Bcachefs_iterator¶
Functions
-
int
Bcachefs_open(Bcachefs *this, const char *path)¶ Open a Bcachefs disk image for reading.
- Return
- 1 on success, 0 on failure
- Parameters
this: Bcachefs struct to initializepath: path to the image
-
int
Bcachefs_close(Bcachefs *this)¶ Close a Bcachefs disk image.
- Return
- 1 on success, 0 on failure
- Parameters
this: disk image to close
-
Bcachefs_iterator *
Bcachefs_iter(const Bcachefs *this, enum btree_id type)¶ Create a Bcachefs iterator to go through a Bcachefs btree.
- Return
- initialized iterator struct or
NULLon failure - Parameters
this: disk imagetype: type of the btree to iterate over
-
Bcachefs_extent
Bcachefs_find_extent(Bcachefs *this, uint64_t inode, uint64_t file_offset)¶ Find and parse an extent descriptor of a file at a particular offset.
The file offset needs to exist in the extents list
- Return
- parsed
Bcachefs_extentor a zeroed struct on failure - Parameters
this: disk imageinode: inode of a filefile_offset: offset of a file extent
-
Bcachefs_inode
Bcachefs_find_inode(Bcachefs *this, uint64_t inode)¶ Find and parse the inode informations of a file.
- Return
- parsed
Bcachefs_inodeor a zeroed struct on failure - Parameters
this: disk imageinode: inode of a file
-
Bcachefs_dirent
Bcachefs_find_dirent(Bcachefs *this, uint64_t parent_inode, uint64_t hash_seed, const uint8_t *name, const uint8_t len)¶ Find and parse the dirent informations of a file.
- Return
- parsed
Bcachefs_inodeor a zeroed struct on failure - Parameters
this: disk imageparent_inode: inode of the parent directoryhash_seed: hash seed of the parent directory or 0name: name of the dirent to findlen: length of the name string
-
const struct bch_val *
Bcachefs_iter_next(const Bcachefs *this, Bcachefs_iterator *iter)¶ Fetch next value from an iterator.
- Return
- next
bch_valorNULLif the end is reached - Parameters
this: disk imageiter: a disk image’s iterator struct
-
int
Bcachefs_iter_fini(const Bcachefs *this, Bcachefs_iterator *iter)¶ Free the resources allocated by the iterator.
- Return
- 1 on success, 0 on failure
- Parameters
this: disk imageiter: a disk image’s iterator struct
-
Bcachefs_extent
Bcachefs_iter_make_extent(const Bcachefs *this, Bcachefs_iterator *iter)¶ Extract extent descriptor from the current
bch_valof an iterator.- Return
- parsed
Bcachefs_extentor a zeroed struct on failure - Parameters
this: disk imageiter: a disk image’s iterator struct
-
Bcachefs_inode
Bcachefs_iter_make_inode(const Bcachefs *this, Bcachefs_iterator *iter)¶ Extract inode information from the current
bch_valof an iterator.- Return
- parsed
Bcachefs_inodeor a zeroed struct on failure - Parameters
this: disk imageiter: a disk image’s iterator struct
-
Bcachefs_dirent
Bcachefs_iter_make_dirent(const Bcachefs *this, Bcachefs_iterator *iter)¶ Extract dirent information from the current
bch_valof an iterator.- Return
- parsed
Bcachefs_direntor a zeroed struct on failure - Parameters
this: the disk image we are reading fromiter: the iterator pointing to the value we want to extract
-
int
Bcachefs_next_iter(const Bcachefs *this, Bcachefs_iterator *iter, const struct bch_btree_ptr_v2 *btree_ptr)¶
-
int
Bcachefs_iter_reinit(const Bcachefs *this, Bcachefs_iterator *iter, enum btree_id type)¶
-
int
Bcachefs_iter_minimal_copy(const Bcachefs *this, Bcachefs_iterator *iter, const Bcachefs_iterator *other)¶
-
const struct jset_entry *
Bcachefs_iter_next_jset_entry(const Bcachefs *this, Bcachefs_iterator *iter)¶
-
const struct bch_btree_ptr_v2 *
Bcachefs_iter_next_btree_ptr(const Bcachefs *this, Bcachefs_iterator *iter)¶
-
const struct bset *
Bcachefs_iter_next_bset(const Bcachefs *this, Bcachefs_iterator *iter)¶
-
struct
Bcachefs_extent¶ - #include <bcachefs_iterator.h>
Decoded value from the extend btree.
Includes
Public Members
-
uint64_t Bcachefs_extent
inode¶
-
uint64_t Bcachefs_extent
file_offset¶
-
uint64_t Bcachefs_extent
offset¶
-
uint64_t Bcachefs_extent
size¶
-
uint64_t Bcachefs_extent
-
struct
Bcachefs_inode¶ - #include <bcachefs_iterator.h>
Decoded value from the inode btree.
Public Members
-
uint64_t Bcachefs_inode
inode¶
-
uint64_t Bcachefs_inode
size¶
-
uint64_t Bcachefs_inode
hash_seed¶
-
uint64_t Bcachefs_inode
-
struct
Bcachefs_dirent¶ - #include <bcachefs_iterator.h>
Decoded value from the dirent btree.
Public Members
-
uint64_t Bcachefs_dirent
parent_inode¶
-
uint64_t Bcachefs_dirent
inode¶
-
uint8_t Bcachefs_dirent
type¶
-
const uint8_t *Bcachefs_dirent
name¶
-
uint8_t Bcachefs_dirent
name_len¶
-
uint64_t Bcachefs_dirent
-
struct
Bcachefs_iterator Public Members
-
btree_id Bcachefs_iterator
type¶
-
const struct jset_entry *Bcachefs_iterator
jset_entry¶ which btree are we iterating over
-
const struct bch_btree_ptr_v2 *Bcachefs_iterator
btree_ptr¶ journal entry specifying the location of the btree root
-
const struct bch_val *Bcachefs_iterator
bch_val¶ current btree node location
-
const struct bkey *Bcachefs_iterator
bkey¶ current value stored inside along side the key
-
struct btree_node *Bcachefs_iterator
btree_node¶
-
struct Bcachefs_iterator *Bcachefs_iterator
next_it¶ current btree node
-
const struct bkey **Bcachefs_iterator
keys¶ pointer to the children btree node if iterating over nested Btrees
-
uint32_t Bcachefs_iterator
num_keys¶
-
uint32_t Bcachefs_iterator
pos¶
-
btree_id Bcachefs_iterator
-
struct
Bcachefs¶ Public Members
-
Bcachefs_iterator *Bcachefs
_iter¶
-
Bcachefs_iterator Bcachefs
_extents_iter_begin¶
-
Bcachefs_iterator Bcachefs
_inodes_iter_begin¶
-
Bcachefs_iterator Bcachefs
_dirents_iter_begin¶
-
Bcachefs_inode Bcachefs
_root_stats¶
-
Bcachefs_dirent Bcachefs
_root_dirent¶
-
Bcachefs_iterator *Bcachefs