pub struct ErofsFilesystem { /* private fields */ }Expand description
The filesystem implementation for an EROFS image.
Implementations§
Source§impl ErofsFilesystem
impl ErofsFilesystem
Sourcepub fn new(reader: Arc<dyn Reader>) -> Result<Self, ErofsError>
pub fn new(reader: Arc<dyn Reader>) -> Result<Self, ErofsError>
Creates a new filesystem instance for an EROFS image from a reader.
Sourcepub fn block_size(&self) -> u64
pub fn block_size(&self) -> u64
Returns the block size of the EROFS image.
Sourcepub fn root_node(&self) -> DirectoryNode
pub fn root_node(&self) -> DirectoryNode
Returns the root node of the EROFS image.
Sourcepub fn read_file_range(
&self,
node: &FileNode,
offset: u64,
buf: &mut [u8],
) -> Result<usize, ErofsError>
pub fn read_file_range( &self, node: &FileNode, offset: u64, buf: &mut [u8], ) -> Result<usize, ErofsError>
Reads the data of the given file node into a buffer.
Sourcepub fn read_directory(
&self,
node: &DirectoryNode,
entry_offset: usize,
entries: &mut [DirectoryEntry],
) -> Result<usize, ErofsError>
pub fn read_directory( &self, node: &DirectoryNode, entry_offset: usize, entries: &mut [DirectoryEntry], ) -> Result<usize, ErofsError>
Read a number of entries from a directory, starting at entry_offset. Will retrieve up to the number of entries in the directory or the size of the provided buffer, returning the number of entries filled in the buffer. If there are less filled entries then the number of entry slots provided in the buffer, there are no more entries in this directory. Entries are sorted lexicographically. Reads past the end of the number of entries will return zero entries filled.
TODO(https://fxbug.dev/479841115): It is possible for directories to omit their “.” entries in erofs, and in that case there is a flag marking it and we are expected to synthesize it. Parse that flag and implement it. TODO(https://fxbug.dev/479841115): This API is slightly awkward to hold. We should consider making it an iterator interface.
Sourcepub fn lookup(
&self,
dir: &DirectoryNode,
name: &str,
) -> Result<Option<Node>, ErofsError>
pub fn lookup( &self, dir: &DirectoryNode, name: &str, ) -> Result<Option<Node>, ErofsError>
Looks up a node by name in a directory.