pub struct Parser { /* private fields */ }
Implementations§
Source§impl Parser
impl Parser
EXT4 Parser
Takes in a Reader
that is able to read arbitrary chunks of data from the filesystem image.
Basic use: let mut parser = Parser::new(VecReader::new(vec_of_u8)); let tree = parser.build_fuchsia_tree()
pub fn new(reader: Box<dyn Reader>) -> Self
Sourcepub fn block_size(&self) -> Result<u64, ParsingError>
pub fn block_size(&self) -> Result<u64, ParsingError>
Reads block size from the Super Block.
Sourcepub fn inode(&self, inode_number: u32) -> Result<INode, ParsingError>
pub fn inode(&self, inode_number: u32) -> Result<INode, ParsingError>
Reads the INode at the given inode number.
Sourcepub fn root_inode(&self) -> Result<INode, ParsingError>
pub fn root_inode(&self) -> Result<INode, ParsingError>
Helper function to get the root directory INode.
Sourcepub fn read_extents(
&self,
inode_num: u32,
) -> Result<(u64, Vec<Extent>), ParsingError>
pub fn read_extents( &self, inode_num: u32, ) -> Result<(u64, Vec<Extent>), ParsingError>
Reads the inode size and raw extent data for a regular file. Fails if the provided inode is not a regular file.
Sourcepub fn entries_from_inode(
&self,
inode: &INode,
) -> Result<Vec<DirEntry2>, ParsingError>
pub fn entries_from_inode( &self, inode: &INode, ) -> Result<Vec<DirEntry2>, ParsingError>
Lists directory entries from the directory that is the given Inode.
Errors if the Inode does not map to a Directory.
Sourcepub fn entry_at_path(&self, path: &Path) -> Result<DirEntry2, ParsingError>
pub fn entry_at_path(&self, path: &Path) -> Result<DirEntry2, ParsingError>
Gets any DirEntry2 that isn’t root.
Root doesn’t have a DirEntry2.
When dynamic loading of files is supported, this is the required mechanism.
Sourcepub fn read_data(&self, inode_num: u32) -> Result<Vec<u8>, ParsingError>
pub fn read_data(&self, inode_num: u32) -> Result<Vec<u8>, ParsingError>
Reads all raw data for a given inode.
For a file, this will be the file data. For a symlink, this will be the symlink target.
Sourcepub fn index<R>(
&self,
inode: INode,
prefix: Vec<&str>,
receiver: &mut R,
) -> Result<bool, ParsingError>
pub fn index<R>( &self, inode: INode, prefix: Vec<&str>, receiver: &mut R, ) -> Result<bool, ParsingError>
Progress through the entire directory tree starting from the given INode.
If given the root directory INode, this will process through every directory entry in the filesystem in a DFS manner.
Takes in a closure that will be called for each entry found.
Closure should return Ok(true)
in order to continue the process, otherwise the process
will stop.
Returns Ok(true) if it has indexed its subtree successfully. Otherwise, if the receiver chooses to cancel indexing early, an Ok(false) is returned and propagated up.
Sourcepub fn inode_xattrs(&self, inode_number: u32) -> Result<XattrMap, ParsingError>
pub fn inode_xattrs(&self, inode_number: u32) -> Result<XattrMap, ParsingError>
Returns the xattrs associated with inode_number
.
Sourcepub fn build_fuchsia_tree(&self) -> Result<Arc<Simple>, ParsingError>
pub fn build_fuchsia_tree(&self) -> Result<Arc<Simple>, ParsingError>
Returns a Simple
filesystem as built by TreeBuilder.build()
.