Skip to main content

Superblock

Struct Superblock 

Source
pub struct Superblock {
Show 35 fields pub inodes_count: u32, pub blocks_count: u64, pub reserved_blocks: u64, pub free_blocks: u64, pub free_inodes: u32, pub first_data_block: u32, pub block_size: u32, pub blocks_per_group: u32, pub inodes_per_group: u32, pub magic: u16, pub state: u16, pub rev_level: u32, pub inode_size: u16, pub desc_size: u16, pub feature_compat: CompatFeatures, pub feature_incompat: IncompatFeatures, pub feature_ro_compat: RoCompatFeatures, pub uuid: [u8; 16], pub volume_name: [u8; 16], pub last_mounted: [u8; 64], pub mkfs_time: u32, pub mount_time: u32, pub write_time: u32, pub lastcheck_time: u32, pub journal_inum: u32, pub hash_seed: [u32; 4], pub def_hash_version: u8, pub checksum_type: u8, pub checksum_seed: u32, pub checksum: u32, pub is_64bit: bool, pub log_groups_per_flex: u32, pub last_orphan: u32, pub first_error_time: u32, pub last_error_time: u32,
}
Expand description

Parsed ext4 superblock. All multi-byte fields are converted from little-endian on disk to native endianness.

Fields§

§inodes_count: u32§blocks_count: u64

Combined lo + hi (64-bit mode).

§reserved_blocks: u64§free_blocks: u64§free_inodes: u32§first_data_block: u32§block_size: u32

Computed: 2^(10 + s_log_block_size).

§blocks_per_group: u32§inodes_per_group: u32§magic: u16§state: u16§rev_level: u32§inode_size: u16§desc_size: u16§feature_compat: CompatFeatures§feature_incompat: IncompatFeatures§feature_ro_compat: RoCompatFeatures§uuid: [u8; 16]§volume_name: [u8; 16]§last_mounted: [u8; 64]§mkfs_time: u32§mount_time: u32§write_time: u32§lastcheck_time: u32§journal_inum: u32§hash_seed: [u32; 4]§def_hash_version: u8§checksum_type: u8§checksum_seed: u32§checksum: u32§is_64bit: bool§log_groups_per_flex: u32§last_orphan: u32§first_error_time: u32§last_error_time: u32

Implementations§

Source§

impl Superblock

Source

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

Parse an ext4 superblock from the given byte slice.

The slice should begin at the start of the superblock (i.e. byte 1024 of the filesystem image has already been skipped by the caller). A minimum of MIN_SUPERBLOCK_LEN bytes is required; a full 1024-byte superblock is needed to access all extended fields.

Source

pub fn label(&self) -> &str

Volume label as a UTF-8 string, trimmed of trailing null bytes.

Source

pub fn uuid_string(&self) -> String

UUID formatted as a standard hyphenated string.

Source

pub fn has_metadata_csum(&self) -> bool

Whether the filesystem has metadata checksumming enabled.

Source

pub fn has_extents(&self) -> bool

Whether the filesystem uses extents (vs. block maps).

Source

pub fn verify_checksum(&self, raw_buf: &[u8]) -> bool

Verify the superblock CRC32C checksum.

The checksum covers bytes 0..0x3FC (everything except the 4-byte checksum field itself at offset 0x3FC).

The superblock checksum is special: unlike other ext4 metadata, it is computed with the default CRC32C initial value (~0 / 0xFFFFFFFF) rather than the UUID-derived or stored seed. This is because the superblock itself contains the UUID used to derive seeds for other structures.

The Linux kernel’s crc32c_le() does NOT apply the final XOR that the standard CRC-32/ISCSI algorithm specifies (xorout=0xFFFFFFFF). We use a custom algorithm definition with xorout=0 to match kernel behavior.

Source

pub fn has_inline_data(&self) -> bool

Whether inline data is supported.

Source

pub fn has_journal(&self) -> bool

Whether the filesystem has a journal.

Source

pub fn group_count(&self) -> u32

Number of block groups (rounded up).

Trait Implementations§

Source§

impl Clone for Superblock

Source§

fn clone(&self) -> Superblock

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 Superblock

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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