Skip to main content

ReaderSuperblock

Struct ReaderSuperblock 

Source
#[non_exhaustive]
pub struct ReaderSuperblock {
Show 24 fields pub version: UfsVersion, pub endian: Endian, pub sblkno: i32, pub cblkno: i32, pub iblkno: i32, pub dblkno: i32, pub ncg: u32, pub bsize: i32, pub fsize: i32, pub frag: i32, pub bshift: i32, pub fshift: i32, pub fragshift: i32, pub fsbtodb: i32, pub sbsize: i32, pub nindir: i32, pub inopb: u32, pub ipg: i32, pub fpg: i32, pub size: i64, pub dsize: i64, pub csaddr: i64, pub sblockloc: i64, pub maxsymlinklen: i32,
}
Expand description

Parsed UFS superblock — geometry and addressing fields the cylinder-group and inode decode (P1) need.

This carries the subset of struct fs the reader currently uses; it is #[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

On-disk version (UFS1 vs UFS2), from the magic.

§endian: Endian

On-disk byte order, from the magic.

§sblkno: i32

fs_sblkno — superblock offset within a cylinder group (frags).

§cblkno: i32

fs_cblkno — cylinder-group-block offset within a cg (frags).

§iblkno: i32

fs_iblkno — inode-blocks offset within a cg (frags).

§dblkno: i32

fs_dblkno — first data-block offset within a cg (frags).

§ncg: u32

fs_ncg — number of cylinder groups.

§bsize: i32

fs_bsize — basic block size in bytes.

§fsize: i32

fs_fsize — fragment size in bytes.

§frag: i32

fs_frag — number of fragments in a block (bsize / fsize).

§bshift: i32

fs_bshiftlog2(bsize).

§fshift: i32

fs_fshiftlog2(fsize).

§fragshift: i32

fs_fragshiftlog2(frag).

§fsbtodb: i32

fs_fsbtodb — fsblock→disk-block shift constant.

§sbsize: i32

fs_sbsize — actual on-disk superblock size in bytes.

§nindir: i32

fs_nindir — pointers per indirect block.

§inopb: u32

fs_inopb — inodes per block.

§ipg: i32

fs_ipg — inodes per cylinder group.

§fpg: i32

fs_fpg — fragments per cylinder group.

§size: i64

Total size of the filesystem in fragments (fs_size on UFS2, the 32-bit fs_old_size on UFS1).

§dsize: i64

Data-region size in fragments (fs_dsize / fs_old_dsize).

§csaddr: i64

fs_csaddr — fragment address of the cylinder-summary area (UFS2).

§sblockloc: i64

fs_sblockloc — the byte offset at which this superblock records itself (self-locating; SBLOCK_UFS2 on UFS2). 0 on UFS1 (field absent).

§maxsymlinklen: i32

fs_maxsymlinklen — inline (fast) symlink length threshold.

Implementations§

Source§

impl Superblock

Source

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

Parse a superblock from the start of data (i.e. data begins at the superblock, not at the filesystem start — callers slice from SBLOCK_UFS1/SBLOCK_UFS2).

Detects the UFS version and byte order from fs_magic (offset 1372) by trying both interpretations against both known magics, then decodes the geometry in the resolved byte order.

§Errors
Source

pub fn inode_size(&self) -> u32

The inode size in bytes for this version: 128 (UFS1) or 256 (UFS2).

Source

pub fn primary_offset(&self) -> usize

The primary-superblock byte offset for this version from the filesystem start (SBLOCK_UFS1 / SBLOCK_UFS2).

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<(), Error>

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

impl Eq for Superblock

Source§

impl PartialEq for Superblock

Source§

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

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.