#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.version: UfsVersionOn-disk version (UFS1 vs UFS2), from the magic.
endian: EndianOn-disk byte order, from the magic.
sblkno: i32fs_sblkno — superblock offset within a cylinder group (frags).
cblkno: i32fs_cblkno — cylinder-group-block offset within a cg (frags).
iblkno: i32fs_iblkno — inode-blocks offset within a cg (frags).
dblkno: i32fs_dblkno — first data-block offset within a cg (frags).
ncg: u32fs_ncg — number of cylinder groups.
bsize: i32fs_bsize — basic block size in bytes.
fsize: i32fs_fsize — fragment size in bytes.
frag: i32fs_frag — number of fragments in a block (bsize / fsize).
bshift: i32fs_bshift — log2(bsize).
fshift: i32fs_fshift — log2(fsize).
fragshift: i32fs_fragshift — log2(frag).
fsbtodb: i32fs_fsbtodb — fsblock→disk-block shift constant.
sbsize: i32fs_sbsize — actual on-disk superblock size in bytes.
nindir: i32fs_nindir — pointers per indirect block.
inopb: u32fs_inopb — inodes per block.
ipg: i32fs_ipg — inodes per cylinder group.
fpg: i32fs_fpg — fragments per cylinder group.
size: i64Total size of the filesystem in fragments (fs_size on UFS2, the 32-bit
fs_old_size on UFS1).
dsize: i64Data-region size in fragments (fs_dsize / fs_old_dsize).
csaddr: i64fs_csaddr — fragment address of the cylinder-summary area (UFS2).
sblockloc: i64fs_sblockloc — the byte offset at which this superblock records itself
(self-locating; SBLOCK_UFS2 on UFS2). 0 on UFS1 (field absent).
maxsymlinklen: i32fs_maxsymlinklen — inline (fast) symlink length threshold.
Implementations§
Source§impl Superblock
impl Superblock
Sourcepub fn parse(data: &[u8]) -> Result<Superblock, UfsError>
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
UfsError::BadMagicif the value at offset 1372 is neither UFS magic in either byte order — the offending bytes are carried.UfsError::Truncatedifdatais shorter than the fields read.UfsError::ImpossibleGeometryif a geometry field is out of range.
Sourcepub fn inode_size(&self) -> u32
pub fn inode_size(&self) -> u32
The inode size in bytes for this version: 128 (UFS1) or 256 (UFS2).
Sourcepub fn primary_offset(&self) -> usize
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
impl Clone for Superblock
Source§fn clone(&self) -> Superblock
fn clone(&self) -> Superblock
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more