Skip to main content

BootSector

Struct BootSector 

Source
#[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
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.
§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: u64

Number of sectors (offset 24).

§bytes_per_sector: u32

Bytes per sector (offset 32).

§sectors_per_cluster: u32

Sectors per cluster block / allocation unit (offset 36).

§major_version: u8

Major format version (offset 40) — 3 for the v3.x line this reader targets, 1 for the legacy Server 2012 / 8.1 layout.

§minor_version: u8

Minor format version (offset 41).

§volume_serial: u64

Volume serial number (offset 56).

§container_size: u64

Container / band size (offset 64).

Implementations§

Source§

impl BootSector

Source

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

Parse the boot VBR from the start of data.

§Errors

The version is not checked here (a v1 volume still has a valid signature); call Self::require_v3 to gate on version.

Source

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

Source

pub fn is_v3(&self) -> bool

True for a ReFS v3.x volume (major_version == 3) — the format this reader targets.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for BootSector

Source§

fn clone(&self) -> Self

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 BootSector

Source§

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

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

impl Eq for BootSector

Source§

impl PartialEq for BootSector

Source§

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

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.