Struct ext2::fs::Ext2

source ·
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>

source

pub(crate) fn new(builder: &Builder, arena: &'a Arena<'a>) -> Result<Self>

source

fn allocate_inode(&mut self) -> Result<InodeNum>

source

fn allocate_block(&mut self) -> Result<BlockId>

source

fn allocate_contiguous_blocks(&mut self, n: u16) -> Result<Vec<Vec<BlockId>>>

source

fn group_num_for_inode(&self, inode: InodeNum) -> usize

source

fn get_inode_mut(&mut self, num: InodeNum) -> Result<&mut &'a mut Inode>

source

fn allocate_dir_entry( &mut self, arena: &'a Arena<'a>, parent: InodeNum, inode: InodeNum, typ: InodeType, name: &OsStr ) -> Result<()>

source

fn add_inode(&mut self, num: InodeNum, inode: &'a mut Inode) -> Result<()>

source

fn add_reserved_dir( &mut self, arena: &'a Arena<'a>, inode_num: InodeNum, parent_inode: InodeNum, name: &OsStr, xattr: Option<InlineXattrs> ) -> Result<()>

source

fn add_dir( &mut self, arena: &'a Arena<'a>, inode_num: InodeNum, parent_inode: InodeNum, path: &Path ) -> Result<()>

source

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.

source

fn fill_indirect_block( &mut self, arena: &'a Arena<'a>, indirect_table: BlockId, file: &File, file_size: usize, file_offset: usize ) -> Result<usize>

source

fn add_file( &mut self, arena: &'a Arena<'a>, parent_inode: InodeNum, path: &Path ) -> Result<()>

source

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.

source

fn copy_dirtree_rec<P: AsRef<Path>>( &mut self, arena: &'a Arena<'a>, parent_inode: InodeNum, src_dir: P ) -> Result<()>

source

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.