Skip to main content

Inode

Struct Inode 

Source
#[non_exhaustive]
pub struct Inode {
Show 14 fields pub version: UfsVersion, pub mode: u16, pub file_type: FileType, pub nlink: u16, pub uid: u32, pub gid: u32, pub size: u64, pub blocks: u64, pub atime: Timespec, pub mtime: Timespec, pub ctime: Timespec, pub birthtime: Option<Timespec>, pub direct: [u64; 12], pub indirect: [u64; 3], /* private fields */
}
Expand description

A decoded UFS inode — the metadata and block-pointer arrays a forensic tool needs. Carries the union (superset) of the UFS1 and UFS2 dinode fields; UFS1-absent fields (birthtime) are None. #[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.
§version: UfsVersion

The on-disk version this inode was decoded as.

§mode: u16

di_mode — file type (IFMT) plus permission bits.

§file_type: FileType

The file type decoded from di_mode & IFMT.

§nlink: u16

di_nlink — hard-link count.

§uid: u32

di_uid — owning user id.

§gid: u32

di_gid — owning group id.

§size: u64

di_size — file length in bytes.

§blocks: u64

di_blocks — count of 512-byte sectors actually held.

§atime: Timespec

di_atime — last access time.

§mtime: Timespec

di_mtime — last data-modification time.

§ctime: Timespec

di_ctime — last inode-change time.

§birthtime: Option<Timespec>

di_birthtime — inode creation time (UFS2 only; None on UFS1).

§direct: [u64; 12]

di_db[UFS_NDADDR] — direct block pointers (fragment addresses). For a fast (inline) symlink these bytes hold the target instead — see Self::symlink_target.

§indirect: [u64; 3]

di_ib[UFS_NIADDR] — single/double/triple indirect block pointers (fragment addresses).

Implementations§

Source§

impl Inode

Source

pub fn parse( data: &[u8], version: UfsVersion, endian: Endian, ) -> Result<Self, UfsError>

Decode a single dinode from data, which must begin at the dinode (a 256-byte UFS2 or 128-byte UFS1 record). version and endian come from the superblock. maxsymlinklen is fs_maxsymlinklen, the inline-symlink threshold; pass it so a symlink whose target fits inline is decoded from the block-pointer bytes. Use read_inode to locate and decode by inode number; this is the lower-level decode over already-located bytes.

Reads through bounds-checked helpers, so a short data never panics — missing tail bytes read as 0. It still fails loud when data is too short to hold the whole dinode, so a truncated buffer is reported rather than silently zero-filled.

§Errors

UfsError::Truncated if data is shorter than the dinode for this version.

Decode a dinode using an explicit fs_maxsymlinklen (the inline-symlink threshold from the superblock). Self::parse calls this with the format default (120); read_inode passes the superblock’s value.

§Errors

UfsError::Truncated if data is shorter than the dinode.

Source

pub fn is_dir(&self) -> bool

true when this inode is a directory.

Source

pub fn is_regular(&self) -> bool

true when this inode is a regular file.

true when this inode is a symbolic link.

The inline fast-symlink target bytes, when this inode is a symlink whose target is stored inline (di_size <= fs_maxsymlinklen). None for non-symlinks and for slow symlinks whose target lives in a data block (those are resolved by reading the block in a later phase). The bytes are the raw path, not NUL-terminated.

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

impl Eq for Inode

Source§

impl PartialEq for Inode

Source§

fn eq(&self, other: &Inode) -> 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 = 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.