Skip to main content

Inode

Struct Inode 

Source
pub struct Inode {
Show 20 fields pub mode: u16, pub uid: u32, pub gid: u32, pub size: u64, pub atime: i64, pub mtime: i64, pub ctime: i64, pub dtime: i64, pub crtime: i64, pub atime_nsec: u32, pub mtime_nsec: u32, pub ctime_nsec: u32, pub crtime_nsec: u32, pub links_count: u16, pub blocks: u64, pub flags: u32, pub block: [u8; 60], pub generation: u32, pub file_acl: u64, pub checksum: u32,
}
Expand description

Parsed ext4 inode.

Combines hi+lo halves for uid, gid, size, file_acl, blocks, and checksum so callers don’t have to reassemble them. Nanosecond timestamps come from the *_extra fields when present (top 30 bits = nsec, low 2 bits = epoch).

Fields§

§mode: u16§uid: u32§gid: u32§size: u64§atime: i64

Seconds since the Unix epoch, signed and 64-bit.

The on-disk base field is a signed 32-bit value, so dates before 1970 are representable and must not be read as far-future ones. When i_extra_isize is large enough, the low two bits of the matching *_extra field extend the seconds by << 32, widening the range from 1901..2038 to roughly 1901..2446. Both are applied here; see decode_extra_time.

§mtime: i64§ctime: i64§dtime: i64§crtime: i64§atime_nsec: u32§mtime_nsec: u32§ctime_nsec: u32§crtime_nsec: u32§links_count: u16§blocks: u64§flags: u32§block: [u8; 60]

Raw 60-byte i_block area — extent header / direct pointers / inline data. Parsed by the extent module.

§generation: u32§file_acl: u64§checksum: u32

Implementations§

Source§

impl Inode

Source

pub fn parse(raw: &[u8]) -> Result<Self>

Parse an inode from its on-disk bytes. Accepts any length >= 128; if >= 160 and i_extra_isize >= 28, parses the extra (nsec + crtime + checksum_hi) section as well.

Source

pub fn file_type(&self) -> u16

File type from i_mode.

Source

pub fn is_dir(&self) -> bool

Source

pub fn is_file(&self) -> bool

Source

pub fn has_extents(&self) -> bool

True when EXT4_EXTENTS_FL is set in i_flags — i_block holds an extent tree rather than legacy direct/indirect block pointers.

Source

pub fn has_inline_data(&self) -> bool

True when INLINE_DATA flag is set — file contents live inside i_block.

Source

pub fn flag_set(&self) -> InodeFlags

Decode i_flags into a typed bitflags value (silently drops unknown bits).

Trait Implementations§

Source§

impl Clone for Inode

Source§

fn clone(&self) -> Inode

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Inode

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Inode

§

impl RefUnwindSafe for Inode

§

impl Send for Inode

§

impl Sync for Inode

§

impl Unpin for Inode

§

impl UnsafeUnpin for Inode

§

impl UnwindSafe for Inode

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> CloneToUninit for T
where T: Clone,

Source§

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
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

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

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

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.