Struct VidHeader
pub struct VidHeader {
pub kind: VolumeKind,
pub copy: bool,
pub compat: u8,
pub volume_id: u32,
pub lnum: u32,
pub data_size: u32,
pub used_ebs: u32,
pub data_pad: u32,
pub data_crc: u32,
pub sqnum: u64,
}Expand description
Volume identifier header of an erase block that holds data.
It says which logical eraseblock of which volume the block holds.
Fields§
§kind: VolumeKindType of the volume.
copy: boolWhether wear leveling copied the block from another block.
compat: u8How UBI implementations that don’t know the volume treat it.
volume_id: u32ID of the volume.
lnum: u32Number of the logical eraseblock in the volume.
data_size: u32Bytes of data in the block. Only set for static volumes and copies.
used_ebs: u32Number of logical eraseblocks with data. Only set for static volumes.
data_pad: u32Bytes at the end of each block that alignment leaves unused.
data_crc: u32CRC of the data. Only set for static volumes and copies.
sqnum: u64Sequence number. If two blocks contain the same logical eraseblock, UBI uses the one with the higher number.
Implementations§
§impl VidHeader
impl VidHeader
pub fn parse(data: &[u8]) -> Result<Self, FormatError>
pub fn parse(data: &[u8]) -> Result<Self, FormatError>
Parses the header at the start of data.
It applies the checks of the kernel’s validate_vid_hdr that don’t
depend on the size of the logical eraseblock. super::ImageReader
applies the others.
§Errors
Returns an error if data is too short or a field has a value that the
kernel rejects.
pub fn to_bytes(&self) -> [u8; 64]
pub fn to_bytes(&self) -> [u8; 64]
Returns the header as stored on flash, with version 1 and its CRC.
pub(crate) const fn has_data_size(&self) -> bool
pub(crate) const fn has_data_size(&self) -> bool
Returns whether the header stores the size and CRC of the data, as static volumes and copies do.
fn validate(&self) -> Result<(), FormatError>
fn validate(&self) -> Result<(), FormatError>
Applies the rules of validate_vid_hdr that work without the size of
the logical eraseblock.