Ext2Superblock

Struct Ext2Superblock 

Source
#[repr(C, packed(1))]
pub struct Ext2Superblock {
Show 38 fields pub inodes_count: u32, pub blocks_count: u32, pub r_blocks_count: u32, pub free_blocks_count: u32, pub free_inodes_count: u32, pub first_data_block: u32, pub log_block_size: u32, pub log_frag_size: u32, pub blocks_per_group: u32, pub frags_per_group: u32, pub inodes_per_group: u32, pub mtime: u32, pub wtime: u32, pub mnt_count: u16, pub max_mnt_count: u16, pub magic: u16, pub state: u16, pub errors: u16, pub minor_rev_level: u16, pub lastcheck: u32, pub checkinterval: u32, pub creator_os: u32, pub rev_level: u32, pub def_resuid: u16, pub def_resgid: u16, pub first_ino: u32, pub inode_size: u16, pub block_group_nr: u16, pub feature_compat: u32, pub feature_incompat: u32, pub feature_ro_compat: u32, pub uuid: [u8; 16], pub volume_name: [u8; 16], pub last_mounted: [u8; 64], pub algorithm_usage_bitmap: u32, pub prealloc_blocks: u8, pub prealloc_dir_blocks: u8, pub padding: [u8; 820],
}
Expand description

ext2 Superblock structure

This structure represents the superblock of an ext2 filesystem. It contains essential information about the filesystem layout and parameters.

Fields§

§inodes_count: u32

Total number of inodes

§blocks_count: u32

Total number of blocks

§r_blocks_count: u32

Number of blocks reserved for superuser

§free_blocks_count: u32

Number of free blocks

§free_inodes_count: u32

Number of free inodes

§first_data_block: u32

First data block (0 for 1K blocks, 1 for larger blocks)

§log_block_size: u32

Block size (log2(block_size) - 10)

§log_frag_size: u32

Fragment size (log2(fragment_size) - 10)

§blocks_per_group: u32

Number of blocks per group

§frags_per_group: u32

Number of fragments per group

§inodes_per_group: u32

Number of inodes per group

§mtime: u32

Mount time

§wtime: u32

Write time

§mnt_count: u16

Mount count

§max_mnt_count: u16

Maximum mount count

§magic: u16

Magic signature

§state: u16

File system state

§errors: u16

Behavior when detecting errors

§minor_rev_level: u16

Minor revision level

§lastcheck: u32

Time of last check

§checkinterval: u32

Maximum time between checks

§creator_os: u32

Creator OS

§rev_level: u32

Revision level

§def_resuid: u16

Default uid for reserved blocks

§def_resgid: u16

Default gid for reserved blocks

§first_ino: u32

First non-reserved inode

§inode_size: u16

Size of inode structure

§block_group_nr: u16

Block group this superblock is part of

§feature_compat: u32

Compatible feature set

§feature_incompat: u32

Incompatible feature set

§feature_ro_compat: u32

Read-only feature set

§uuid: [u8; 16]

128-bit UUID for volume

§volume_name: [u8; 16]

Volume name

§last_mounted: [u8; 64]

Directory where last mounted

§algorithm_usage_bitmap: u32

Algorithm usage bitmap

§prealloc_blocks: u8

Number of blocks to try to preallocate for files

§prealloc_dir_blocks: u8

Number of blocks to preallocate for directories

§padding: [u8; 820]

Padding to 1024 bytes

Implementations§

Source§

impl Ext2Superblock

Source

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

Parse superblock from raw bytes using unsafe type conversion for efficiency

Source

pub fn from_bytes_boxed(data: &[u8]) -> Result<Box<Self>, FileSystemError>

Parse superblock from raw bytes and return as Box to avoid stack overflow

Source

pub fn get_block_size(&self) -> u32

Get block size in bytes

Source

pub fn get_blocks_count(&self) -> u32

Get total blocks count

Source

pub fn get_inodes_count(&self) -> u32

Get total inodes count

Source

pub fn get_blocks_per_group(&self) -> u32

Get blocks per group

Source

pub fn get_inodes_per_group(&self) -> u32

Get inodes per group

Source

pub fn get_inode_size(&self) -> u16

Get inode size

Source

pub fn get_first_data_block(&self) -> u32

Get first data block

Trait Implementations§

Source§

impl Clone for Ext2Superblock

Source§

fn clone(&self) -> Ext2Superblock

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Ext2Superblock

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Copy for Ext2Superblock

Auto Trait Implementations§

§

impl Freeze for Ext2Superblock

§

impl RefUnwindSafe for Ext2Superblock

§

impl Send for Ext2Superblock

§

impl Sync for Ext2Superblock

§

impl Unpin for Ext2Superblock

§

impl UnwindSafe for Ext2Superblock

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.