Skip to main content

VolumeRecord

Struct VolumeRecord 

pub struct VolumeRecord<'a> {
    pub reserved_blocks: u32,
    pub alignment: u32,
    pub data_pad: u32,
    pub kind: VolumeKind,
    pub update_marker: bool,
    pub name: &'a [u8],
    pub autoresize: bool,
    pub skip_crc_check: bool,
}
Expand description

Record of a volume in the volume table.

The volume table is stored in each of the two logical eraseblocks of the layout volume, LAYOUT_VOLUME_ID. The record borrows its name from the parsed data.

Fields§

§reserved_blocks: u32

Erase blocks reserved for the volume.

§alignment: u32

Alignment of the volume.

§data_pad: u32

Bytes at the end of each block that alignment leaves unused.

§kind: VolumeKind

Type of the volume.

§update_marker: bool

Whether an update of the volume didn’t finish.

§name: &'a [u8]

Name of the volume. The kernel allows any bytes except NUL, so it may not be UTF-8.

§autoresize: bool

Whether UBI grows the volume to fill the device on the first attach.

§skip_crc_check: bool

Whether UBI skips the CRC check when it reads a static volume. Older kernels, such as 3.18, ignore it.

Implementations§

§

impl<'a> VolumeRecord<'a>

pub const SIZE: usize = 172

Size of a record in bytes.

pub fn parse(data: &'a [u8]) -> Result<Option<Self>, FormatError>

Parses the record at the start of data.

Returns None for an unused record. It applies the checks of the kernel’s vtbl_check that only look at this record. VolumeRecord::read_table also checks the record against the table and the size of the logical eraseblock.

§Errors

Returns an error if data is too short, the CRC is wrong, an unused record isn’t all zeros, or a field has a value that the kernel rejects.

pub fn read_table( data: &'a [u8], leb_size: u32, ) -> impl Iterator<Item = Result<(u32, Self), FormatError>> + 'a

Returns the used records of a volume table with the ID of their volume.

data is the data of a logical eraseblock of the layout volume, and leb_size is the size of a logical eraseblock, see super::ImageBlock::leb_size. Besides VolumeRecord::parse, it checks the alignment against leb_size, that no two volumes share a name and that only one volume has the autoresize flag. The kernel also checks the alignment against the minimum I/O size and the reserved blocks against the device, which a table alone can’t know.

fn check_geometry(&self, leb_size: u32) -> Result<(), FormatError>

Checks the alignment against the size of a logical eraseblock.

Trait Implementations§

§

impl<'a> Clone for VolumeRecord<'a>

§

fn clone(&self) -> VolumeRecord<'a>

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
§

impl<'a> Copy for VolumeRecord<'a>

§

impl<'a> Debug for VolumeRecord<'a>

§

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

Formats the value using the given formatter. Read more
§

impl<'a> Eq for VolumeRecord<'a>

§

impl<'a> PartialEq for VolumeRecord<'a>

§

fn eq(&self, other: &VolumeRecord<'a>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
§

impl<'a> StructuralPartialEq for VolumeRecord<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for VolumeRecord<'a>

§

impl<'a> RefUnwindSafe for VolumeRecord<'a>

§

impl<'a> Send for VolumeRecord<'a>

§

impl<'a> Sync for VolumeRecord<'a>

§

impl<'a> Unpin for VolumeRecord<'a>

§

impl<'a> UnsafeUnpin for VolumeRecord<'a>

§

impl<'a> UnwindSafe for VolumeRecord<'a>

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