pub(crate) struct Ext2<'a> {
sb: &'a mut SuperBlock,
cur_block_group: usize,
cur_inode_table: usize,
group_metadata: Vec<GroupMetaData<'a>>,
dir_entries: BTreeMap<InodeNum, Vec<DirEntryBlock<'a>>>,
}
Expand description
A struct to represent an ext2 filesystem.
Fields§
§sb: &'a mut SuperBlock
§cur_block_group: usize
§cur_inode_table: usize
§group_metadata: Vec<GroupMetaData<'a>>
§dir_entries: BTreeMap<InodeNum, Vec<DirEntryBlock<'a>>>
Implementations§
source§impl<'a> Ext2<'a>
impl<'a> Ext2<'a>
pub(crate) fn new(builder: &Builder, arena: &'a Arena<'a>) -> Result<Self>
fn allocate_inode(&mut self) -> Result<InodeNum>
fn allocate_block(&mut self) -> Result<BlockId>
fn allocate_contiguous_blocks(&mut self, n: u16) -> Result<Vec<Vec<BlockId>>>
fn group_num_for_inode(&self, inode: InodeNum) -> usize
fn get_inode_mut(&mut self, num: InodeNum) -> Result<&mut &'a mut Inode>
fn allocate_dir_entry( &mut self, arena: &'a Arena<'a>, parent: InodeNum, inode: InodeNum, typ: InodeType, name: &OsStr ) -> Result<()>
fn add_inode(&mut self, num: InodeNum, inode: &'a mut Inode) -> Result<()>
fn add_reserved_dir( &mut self, arena: &'a Arena<'a>, inode_num: InodeNum, parent_inode: InodeNum, name: &OsStr, xattr: Option<InlineXattrs> ) -> Result<()>
fn add_dir( &mut self, arena: &'a Arena<'a>, inode_num: InodeNum, parent_inode: InodeNum, path: &Path ) -> Result<()>
sourcefn register_mmap_file(
&mut self,
arena: &'a Arena<'a>,
block_num: usize,
file: &File,
file_size: usize,
file_offset: usize
) -> Result<(Vec<BlockId>, usize)>
fn register_mmap_file( &mut self, arena: &'a Arena<'a>, block_num: usize, file: &File, file_size: usize, file_offset: usize ) -> Result<(Vec<BlockId>, usize)>
Registers a file to be mmaped to the memory region.
This function just reserves a region for mmap() on arena
and doesn’t call mmap().
It’s arena
’s owner’s responsibility to call mmap() for the registered files at the end.
fn fill_indirect_block( &mut self, arena: &'a Arena<'a>, indirect_table: BlockId, file: &File, file_size: usize, file_offset: usize ) -> Result<usize>
fn add_file( &mut self, arena: &'a Arena<'a>, parent_inode: InodeNum, path: &Path ) -> Result<()>
fn add_symlink( &mut self, arena: &'a Arena<'a>, parent: InodeNum, entry: &DirEntry ) -> Result<()>
fn add_long_symlink( &mut self, arena: &'a Arena<'a>, parent: InodeNum, link: &Path, dst: &str ) -> Result<()>
sourcepub(crate) fn copy_dirtree<P: AsRef<Path>>(
&mut self,
arena: &'a Arena<'a>,
src_dir: P
) -> Result<()>
pub(crate) fn copy_dirtree<P: AsRef<Path>>( &mut self, arena: &'a Arena<'a>, src_dir: P ) -> Result<()>
Walks through src_dir
and copies directories and files to the new file system.
fn copy_dirtree_rec<P: AsRef<Path>>( &mut self, arena: &'a Arena<'a>, parent_inode: InodeNum, src_dir: P ) -> Result<()>
pub(crate) fn copy_backup_metadata(self, arena: &'a Arena<'a>) -> Result<()>
Auto Trait Implementations§
impl<'a> RefUnwindSafe for Ext2<'a>
impl<'a> Send for Ext2<'a>
impl<'a> Sync for Ext2<'a>
impl<'a> Unpin for Ext2<'a>
impl<'a> !UnwindSafe for Ext2<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more