Struct VolumeInfo
pub struct VolumeInfo {
device_number: u32,
id: u32,
path: PathBuf,
char_device: (u32, u32),
name: VolumeName,
kind: VolumeKind,
alignment: u32,
usable_leb_size: u32,
reserved_lebs: u32,
data_bytes: u64,
corrupted: bool,
update_marker: bool,
}Expand description
Volume of a UBI device, with its attributes from sysfs.
super::DeviceInfo::volume and super::DeviceInfo::volumes return
it. The values are a snapshot from the time the volume was read. Read it
again for current values.
The methods that open the volume use its device file,
/dev/ubi<device>_<id>. Some systems create device files a moment after
the kernel attached the device. Wait for VolumeInfo::path to appear if
needed.
Fields§
§device_number: u32§id: u32§path: PathBuf§char_device: (u32, u32)§name: VolumeName§kind: VolumeKind§alignment: u32§usable_leb_size: u32§reserved_lebs: u32§data_bytes: u64§corrupted: bool§update_marker: boolImplementations§
§impl VolumeInfo
impl VolumeInfo
pub const fn device_number(&self) -> u32
pub const fn device_number(&self) -> u32
Returns the number of the UBI device of the volume.
pub const fn char_device(&self) -> (u32, u32)
pub const fn char_device(&self) -> (u32, u32)
Returns the major and minor number of the character device.
pub const fn name(&self) -> &VolumeName
pub const fn name(&self) -> &VolumeName
Returns the name of the volume.
pub const fn kind(&self) -> VolumeKind
pub const fn kind(&self) -> VolumeKind
Returns the type of the volume.
pub const fn usable_leb_size(&self) -> u32
pub const fn usable_leb_size(&self) -> u32
Returns the bytes of data in a logical eraseblock of the volume. This can be less than the logical eraseblock size of the device because of the alignment.
pub const fn reserved_lebs(&self) -> u32
pub const fn reserved_lebs(&self) -> u32
Returns the logical eraseblocks reserved for the volume.
pub fn reserved_bytes(&self) -> u64
pub fn reserved_bytes(&self) -> u64
Returns the bytes reserved for the volume.
pub const fn data_bytes(&self) -> u64
pub const fn data_bytes(&self) -> u64
Returns the bytes of data in the volume. For a
VolumeKind::Dynamic volume, this equals
VolumeInfo::reserved_bytes.
pub const fn is_corrupted(&self) -> bool
pub const fn is_corrupted(&self) -> bool
Returns whether the kernel found the volume corrupted.
pub const fn has_update_marker(&self) -> bool
pub const fn has_update_marker(&self) -> bool
Returns whether an update of the volume didn’t finish.
pub fn open_read(&self) -> Result<File, DeviceError>
pub fn open_read(&self) -> Result<File, DeviceError>
pub fn truncate(&self) -> Result<(), DeviceError>
pub fn truncate(&self) -> Result<(), DeviceError>
Removes all data from the volume.
§Errors
Returns an error if the device file can’t be opened or the kernel refuses the update.
pub fn update<R: BufRead>(&self, image: R, size: u64) -> Result<(), DeviceError>
pub fn update<R: BufRead>(&self, image: R, size: u64) -> Result<(), DeviceError>
Replaces the content of the volume with the first size bytes of
image.
Each chunk that image returns from BufRead::fill_buf is written
as is. Wrap a File in a std::io::BufReader. The kernel collects
the data into logical eraseblocks, so the chunks can have any size.
If the update fails, the kernel marks the volume corrupted until the next successful update.
§Errors
Returns DeviceError::ImageTooShort if image ends early, and
DeviceError::Update if the kernel refuses the update, for example
because size exceeds the reserved bytes. Returns another error if
reading image or opening the volume fails.
pub(crate) fn read(
root: &Path,
device_number: u32,
id: u32,
) -> Result<Option<Self>, DeviceError>
pub(crate) fn read( root: &Path, device_number: u32, id: u32, ) -> Result<Option<Self>, DeviceError>
Returns volume id of device device_number in the sysfs class
directory root, or None if there is none.
pub(crate) fn from_dir(
sysfs: &SysfsDir,
device_number: u32,
id: u32,
) -> Result<Self, DeviceError>
pub(crate) fn from_dir( sysfs: &SysfsDir, device_number: u32, id: u32, ) -> Result<Self, DeviceError>
Reads volume id of device device_number from its open directory
sysfs.
fn open(&self, flags: OFlags) -> Result<OwnedFd, DeviceError>
fn open(&self, flags: OFlags) -> Result<OwnedFd, DeviceError>
Opens the device file with flags.
Trait Implementations§
§impl Clone for VolumeInfo
impl Clone for VolumeInfo
§fn clone(&self) -> VolumeInfo
fn clone(&self) -> VolumeInfo
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more