#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.magic: u16di_magic (offset 0) — validated to equal XFS_DINODE_MAGIC.
mode: u16di_mode (offset 2) — file type (S_IFMT) + permission bits.
version: u8di_version (offset 4) — inode format version (1 / 2 / 3).
format: InodeFormatdi_format (offset 5) — the data-fork format selector P3/P4 use.
aformat: u8di_aformat (offset 83) — the attribute-fork format selector.
size: u64di_size (offset 56) — logical size in bytes.
nblocks: u64di_nblocks (offset 64) — data + btree blocks used.
nextents: u32di_nextents (offset 76) — number of data-fork extents.
aextents: u16di_anextents (offset 80) — number of attribute-fork extents.
forkoff: u8di_forkoff (offset 82) — attr-fork offset (in 8-byte units).
atime: XfsTimestampdi_atime (offset 32) — last-access time (decoded).
mtime: XfsTimestampdi_mtime (offset 40) — last-modification time (decoded).
ctime: XfsTimestampdi_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
impl Inode
Sourcepub fn parse(data: &[u8]) -> Result<Self, XfsError>
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::BadMagicif bytes 0..2 are notIN— the offending value is carried (as abe32with the high half zero, matching the shared error type).XfsError::Truncatedifdatais shorter than the core for its version (v2: 100 bytes; v3: 176 bytes).
Sourcepub fn file_type(&self) -> FileType
pub fn file_type(&self) -> FileType
The S_IFMT file type from Self::mode.
Sourcepub fn is_bigtime(&self) -> bool
pub fn is_bigtime(&self) -> bool
True if the timestamps were decoded with the bigtime encoding (a v3
inode carrying XFS_DIFLAG2_BIGTIME).
Sourcepub fn data_fork_offset(&self) -> usize
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.