Ext2Inode

Struct Ext2Inode 

Source
#[repr(C, packed(1))]
pub struct Ext2Inode {
Show 18 fields pub mode: u16, pub uid: u16, pub size: u32, pub atime: u32, pub ctime: u32, pub mtime: u32, pub dtime: u32, pub gid: u16, pub links_count: u16, pub blocks: u32, pub flags: u32, pub osd1: u32, pub block: [u32; 15], pub generation: u32, pub file_acl: u32, pub dir_acl: u32, pub faddr: u32, pub osd2: [u8; 12],
}
Expand description

ext2 Inode structure

Each file and directory is represented by an inode that contains metadata about the file and pointers to its data blocks.

Fields§

§mode: u16

File mode (permissions and file type)

§uid: u16

Owner UID

§size: u32

Size in bytes

§atime: u32

Access time

§ctime: u32

Creation time

§mtime: u32

Modification time

§dtime: u32

Deletion time

§gid: u16

Group ID

§links_count: u16

Link count

§blocks: u32

Blocks count (512-byte blocks)

§flags: u32

File flags

§osd1: u32

OS dependent 1

§block: [u32; 15]

Pointers to blocks (0-11 direct, 12 indirect, 13 double indirect, 14 triple indirect)

§generation: u32

File version (for NFS)

§file_acl: u32

File ACL

§dir_acl: u32

Directory ACL / high 32 bits of file size

§faddr: u32

Fragment address

§osd2: [u8; 12]

OS dependent 2

Implementations§

Source§

impl Ext2Inode

Source

pub fn empty() -> Self

Source

pub fn from_bytes(data: &[u8]) -> Result<Self, FileSystemError>

Parse inode from raw bytes using unsafe type conversion for efficiency

Source

pub fn get_mode(&self) -> u16

Get file mode (permissions and type)

Source

pub fn get_size(&self) -> u32

Get file size in bytes

Source

pub fn get_mtime(&self) -> u32

Get modification time

Source

pub fn get_atime(&self) -> u32

Get access time

Source

pub fn get_ctime(&self) -> u32

Get creation time

Get link count

Source

pub fn get_blocks(&self) -> u32

Get blocks count (512-byte blocks)

Source

pub fn get_block(&self, index: usize) -> Option<u32>

Get block pointer at index

Source

pub fn is_dir(&self) -> bool

Check if this is a directory

Source

pub fn is_file(&self) -> bool

Check if this is a regular file

Source

pub fn is_char_device(&self) -> bool

Check if this is a character device

Source

pub fn is_block_device(&self) -> bool

Check if this is a block device

Check if this is a symbolic link

Source

pub fn is_fifo(&self) -> bool

Check if this is a FIFO (pipe)

Source

pub fn is_socket(&self) -> bool

Check if this is a socket

Source

pub fn get_device_info(&self) -> Option<(u32, u32)>

Get device information for device files Returns (major, minor) device numbers

Read symbolic link target from inode

This method handles both fast symlinks (target stored in block array) and slow symlinks (target stored in data blocks).

§Arguments
  • filesystem - Reference to the ext2 filesystem for block reading
§Returns

The target path of the symbolic link, or an error if this is not a symlink or if the target cannot be read.

Trait Implementations§

Source§

impl Clone for Ext2Inode

Source§

fn clone(&self) -> Ext2Inode

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Ext2Inode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for Ext2Inode

Auto Trait Implementations§

§

impl Freeze for Ext2Inode

§

impl RefUnwindSafe for Ext2Inode

§

impl Send for Ext2Inode

§

impl Sync for Ext2Inode

§

impl Unpin for Ext2Inode

§

impl UnwindSafe for Ext2Inode

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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.
§

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

Performs the conversion.