C API

int Bcachefs_open(Bcachefs *this, const char *path)

Open a Bcachefs disk image for reading.

Return
1 on success and 0 on failure
Parameters
  • this: the bcachefs struct to use for the initialization
  • path: the path to the image

int Bcachefs_close(Bcachefs *this)

close the Bcachefs disk image

Return
1 on success and 0 on failure
Parameters
  • this: the disk image to close

int Bcachefs_iter(const Bcachefs *this, Bcachefs_iterator *iter, enum btree_id type)

prepare a bcachefs iterator to go through a bcachefs btree

Return
1 on success and 0 on failure
Parameters
  • this: the disk image we want to iterate through
  • iter: the iterator struct to initialize
  • type: the btree type we want to iterate over

const struct bch_val *Bcachefs_iter_next(const Bcachefs *this, Bcachefs_iterator *iter)

fetch next value from the iterator

Return
the next value or NULL if we reached the end
Parameters
  • this: the disk image we are iterating through
  • iter: the iterator struct

int Bcachefs_iter_fini(const Bcachefs *this, Bcachefs_iterator *iter)

free all the resources allocated by the iterator

Return
1 on success and 0 on failure
Parameters
  • this: the disk image we are iterating through
  • iter: the iterator struct

Bcachefs_extent Bcachefs_iter_make_extent(const Bcachefs *this, Bcachefs_iterator *iter)

extract extent information from a bch_val

Return
the extracted value
Parameters
  • this: the disk image we are reading from
  • iter: the iterator pointing to the value we want to extract

Bcachefs_inode Bcachefs_iter_make_inode(const Bcachefs *this, Bcachefs_iterator *iter)

extract inode information from a bch_val

Return
the extracted value
Parameters
  • this: the disk image we are reading from
  • iter: the iterator pointing to the value we want to extract

Bcachefs_dirent Bcachefs_iter_make_dirent(const Bcachefs *this, Bcachefs_iterator *iter)

extract dirent information from a bch_val

Return
the extracted value
Parameters
  • this: the disk image we are reading from
  • iter: the iterator pointing to the value we want to extract