#[non_exhaustive]pub struct BootSector {
pub signature: [u8; 8],
pub fsrs: [u8; 4],
pub num_sectors: u64,
pub bytes_per_sector: u32,
pub sectors_per_cluster: u32,
pub major_version: u8,
pub minor_version: u8,
pub volume_serial: u64,
pub container_size: u64,
}Expand description
Parsed ReFS boot VBR / FS-recognition structure.
#[non_exhaustive] so later phases add fields (flags, the FSRS checksum)
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.signature: [u8; 8]FS signature at offset 3 — validated to equal REFS_SIGNATURE.
fsrs: [u8; 4]FS-recognition-structure identifier at offset 16 — validated to equal
REFS_FSRS.
num_sectors: u64Number of sectors (offset 24).
bytes_per_sector: u32Bytes per sector (offset 32).
sectors_per_cluster: u32Sectors per cluster block / allocation unit (offset 36).
major_version: u8Major format version (offset 40) — 3 for the v3.x line this reader
targets, 1 for the legacy Server 2012 / 8.1 layout.
minor_version: u8Minor format version (offset 41).
volume_serial: u64Volume serial number (offset 56).
container_size: u64Container / band size (offset 64).
Implementations§
Source§impl BootSector
impl BootSector
Sourcepub fn parse(data: &[u8]) -> Result<Self, RefsError>
pub fn parse(data: &[u8]) -> Result<Self, RefsError>
Parse the boot VBR from the start of data.
§Errors
RefsError::BadSignatureif bytes 3..11 are not"ReFS\0\0\0\0"— the eight offending bytes are carried in the error.RefsError::BadFsrsif bytes 16..20 are not"FSRS".RefsError::Truncatedifdatais shorter than the fields read.
The version is not checked here (a v1 volume still has a valid
signature); call Self::require_v3 to gate on version.
Sourcepub fn cluster_size(&self) -> u64
pub fn cluster_size(&self) -> u64
Cluster (allocation-unit) size in bytes: bytes_per_sector * sectors_per_cluster.
Saturating so absurd geometry from a hostile image yields a clamped value rather than an overflow panic (the Paranoid Gatekeeper standard).
Sourcepub fn is_v3(&self) -> bool
pub fn is_v3(&self) -> bool
True for a ReFS v3.x volume (major_version == 3) — the format this
reader targets.
Sourcepub fn superblock_offset(&self) -> u64
pub fn superblock_offset(&self) -> u64
Byte offset of the primary superblock: REFS_SUPERBLOCK_CLUSTER × the
cluster size.
Saturating so a hostile cluster size cannot overflow.
Sourcepub fn require_v3(&self) -> Result<(), RefsError>
pub fn require_v3(&self) -> Result<(), RefsError>
Reject any non-v3.x volume, naming the actual version bytes.
This is the fail-loud version gate RESEARCH.md mandates: a v1 volume (Server 2012 / 8.1) has a materially different on-disk layout, so parsing it as v3 would silently misparse. Callers gate on this before trusting any structure beyond the boot VBR.
§Errors
RefsError::UnsupportedVersion if major_version != 3.