pub struct Ext4Processor { /* private fields */ }Expand description
A processor that wraps an ext4 parser and adds write functionality if not in read-only mode.
Implementations§
Source§impl Ext4Processor
impl Ext4Processor
pub fn new(reader_writer: Arc<dyn ReaderWriter>, read_only: bool) -> Self
pub fn read_only(&self) -> bool
Sourcepub fn overwrite_extents(
&self,
inode_num: u32,
data: impl AsRef<[u8]>,
offset: u64,
) -> Result<(), ParsingError>
pub fn overwrite_extents( &self, inode_num: u32, data: impl AsRef<[u8]>, offset: u64, ) -> Result<(), ParsingError>
Overwrites existing extents of a file with new data. Partial writes of data are not supported - if write requires allocating new extent, a NOT_SUPPORTED error is returned.
pub fn sync(&self) -> Result<(), ParsingError>
Methods from Deref<Target = Parser>§
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, E>(
&self,
inode: INode,
prefix: Vec<&str>,
receiver: &mut R,
) -> Result<bool, E>
pub fn index<R, E>( &self, inode: INode, prefix: Vec<&str>, receiver: &mut R, ) -> Result<bool, E>
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.