Skip to main content

Inode

Struct Inode 

Source
#[non_exhaustive]
pub struct Inode {
Show 21 fields pub magic: u16, pub mode: u16, pub version: u8, pub format: InodeFormat, pub aformat: u8, pub size: u64, pub nblocks: u64, pub nextents: u32, pub aextents: u16, pub forkoff: u8, pub atime: XfsTimestamp, pub mtime: XfsTimestamp, pub ctime: XfsTimestamp, pub crtime: Option<XfsTimestamp>, pub flags2: Option<u64>, pub cowextsize: Option<u32>, pub di_ino: Option<u64>, pub uuid: Option<[u8; 16]>, pub crc: Option<u32>, pub crc_valid: Option<bool>, pub data_fork: Vec<u8>,
}
Expand description

A parsed XFS inode core (di_core), v2 or v3.

Carries the subset of struct xfs_dinode a forensic reader needs; the v3 tail fields (crtime/di_ino/uuid/crc/flags2/cowextsize) are Option — None on a v2 inode where they do not exist. #[non_exhaustive] so later phases add fields without a breaking change.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§magic: u16

di_magic (offset 0) — validated to equal XFS_DINODE_MAGIC.

§mode: u16

di_mode (offset 2) — file type (S_IFMT) + permission bits.

§version: u8

di_version (offset 4) — inode format version (1 / 2 / 3).

§format: InodeFormat

di_format (offset 5) — the data-fork format selector P3/P4 use.

§aformat: u8

di_aformat (offset 83) — the attribute-fork format selector.

§size: u64

di_size (offset 56) — logical size in bytes.

§nblocks: u64

di_nblocks (offset 64) — data + btree blocks used.

§nextents: u32

di_nextents (offset 76) — number of data-fork extents.

§aextents: u16

di_anextents (offset 80) — number of attribute-fork extents.

§forkoff: u8

di_forkoff (offset 82) — attr-fork offset (in 8-byte units).

§atime: XfsTimestamp

di_atime (offset 32) — last-access time (decoded).

§mtime: XfsTimestamp

di_mtime (offset 40) — last-modification time (decoded).

§ctime: XfsTimestamp

di_ctime (offset 48) — inode-change time (decoded).

§crtime: Option<XfsTimestamp>

di_crtime (offset 144) — creation time; None on v2.

§flags2: Option<u64>

di_flags2 (offset 120) — extended flags (BIGTIME/…); None on v2.

§cowextsize: Option<u32>

di_cowextsize (offset 128) — copy-on-write extent-size hint; None v2.

§di_ino: Option<u64>

di_ino (offset 152) — the inode’s self-reference; None on v2. A nice integrity check: it must equal the number used to locate the inode.

§uuid: Option<[u8; 16]>

di_uuid (offset 160) — owning filesystem UUID; None on v2.

§crc: Option<u32>

di_crc (offset 100, little-endian) — inode CRC32c; None on v2. The raw stored value; Self::crc_valid carries the verification result.

§crc_valid: Option<bool>

The v5 CRC32c status of this inode: Some(true) if di_crc (offset 100) verifies over the whole inode-sized slice, Some(false) if it does not (corrupt/tampered), or None on a v2 inode (no CRC). Non-fatal — a bad CRC does not fail the parse; the -forensic layer turns it into a Finding. Computed only when Self::parse receives the full inode; a short slice (< inodesize) verifies as Some(false).

§data_fork: Vec<u8>

The raw data-fork (“u” union) bytes — everything from Self::data_fork_offset to the end of the inode-sized slice. For an InodeFormat::Extents inode this holds the inline xfs_bmbt_rec array P3 decodes; for InodeFormat::Local it holds the short-form dir/symlink (P4). Empty when the slice was exactly the core length.

Implementations§

Source§

impl Inode

Source

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

Parse an inode core from data (the inode-sized slice at the byte offset crate::Superblock::inode_to_location yields).

§Errors
  • XfsError::BadMagic if bytes 0..2 are not IN — the offending value is carried (as a be32 with the high half zero, matching the shared error type).
  • XfsError::Truncated if data is shorter than the core for its version (v2: 100 bytes; v3: 176 bytes).
Source

pub fn file_type(&self) -> FileType

The S_IFMT file type from Self::mode.

Source

pub fn is_dir(&self) -> bool

True if this inode is a directory.

Source

pub fn is_reg(&self) -> bool

True if this inode is a regular file.

Source

pub fn is_bigtime(&self) -> bool

True if the timestamps were decoded with the bigtime encoding (a v3 inode carrying XFS_DIFLAG2_BIGTIME).

Source

pub fn data_fork_offset(&self) -> usize

Byte offset of the data-fork (“u” union) within the inode: 176 on a v3 inode, 100 on a v2 inode. P3/P4 read the extent array / short-form directory starting here.

Trait Implementations§

Source§

impl Clone for Inode

Source§

fn clone(&self) -> Self

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

impl Eq for Inode

Source§

impl PartialEq for Inode

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Inode

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.