Skip to main content

Inode

Struct Inode 

Source
pub struct Inode {
Show 18 fields pub mode: u16, pub uid: u32, pub gid: u32, pub size: u64, pub atime: Timestamp, pub ctime: Timestamp, pub mtime: Timestamp, pub dtime: u32, pub crtime: Timestamp, pub links_count: u16, pub blocks_count: u64, pub flags: InodeFlags, pub i_block: [u8; 60], pub generation: u32, pub file_acl: u64, pub extra_isize: u16, pub checksum: u32, pub projid: u32,
}
Expand description

Parsed on-disk ext4 inode (128-byte base + optional extended fields).

Fields§

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

Full 64-bit file size (i_size_lo | i_size_hi << 32).

§atime: Timestamp§ctime: Timestamp§mtime: Timestamp§dtime: u32

Deletion time (raw 32-bit seconds; 0 = not deleted).

§crtime: Timestamp

Creation time — only valid when extra_isize >= 28.

§links_count: u16§blocks_count: u64

Full 48-bit block count in 512-byte units (i_blocks_lo | i_blocks_hi << 32).

§flags: InodeFlags§i_block: [u8; 60]§generation: u32§file_acl: u64§extra_isize: u16§checksum: u32

Combined 32-bit checksum (lo 16 at 0x7C, hi 16 at 0x82).

§projid: u32

Implementations§

Source§

impl Inode

Source

pub fn parse(buf: &[u8], inode_size: u16) -> Result<Self>

Parse an inode from buf.

inode_size is the value from the superblock (s_inode_size); it determines how many bytes are available for extended fields.

Source

pub fn file_type(&self) -> FileType

Extract the file type from the high nibble of i_mode.

Source

pub fn mode_permissions(&self) -> u16

Extract the permission bits (low 12 bits of i_mode).

Source

pub fn uses_extents(&self) -> bool

True if this inode uses the extent tree (EXTENTS flag set).

Source

pub fn has_inline_data(&self) -> bool

True if this inode stores data inline in i_block.

Source

pub fn has_htree(&self) -> bool

True if this directory uses an HTree (htree/INDEX flag set).

Source

pub fn is_deleted(&self) -> bool

True if the inode has been deleted (dtime != 0).

This is the authoritative deletion marker in ext4. When the kernel deletes a file, it sets dtime to the current time. An inode with links_count == 0 but dtime == 0 is an orphan (unlinked while still open, or system crashed mid-deletion) — a forensically distinct state. Use [is_orphan] to detect those.

Source

pub fn verify_checksum( &self, raw_buf: &[u8], uuid: &[u8; 16], ino: u32, generation: u32, csum_seed: u32, ) -> bool

Verify the inode’s CRC32C checksum (METADATA_CSUM feature).

The algorithm:

  1. Seed from csum_seed (or crc32c(0xFFFFFFFF, uuid) if zero)
  2. Feed le32(ino) then le32(generation)
  3. Feed the full raw inode bytes with both checksum fields zeroed
  4. Compare the 32-bit result against self.checksum
Source

pub fn is_orphan(&self) -> bool

True if the inode is an orphan: unlinked (links_count == 0) but never fully deleted (dtime == 0) and still has content (mode != 0).

Orphans typically result from:

  • A file unlinked while still held open by a process (common temp file pattern)
  • A system crash during file deletion before dtime was written
  • An unclean shutdown leaving inodes in the orphan list

Forensically distinct from deleted inodes — orphans were not intentionally removed by the user/process at the time of imaging.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = 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>,

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V