Skip to main content

AttachOptions

Struct AttachOptions 

pub struct AttachOptions {
    mtd_number: u32,
    number: Option<u32>,
    vid_header_offset: Option<u32>,
    max_beb_per1024: Option<u16>,
    disable_fastmap: bool,
    reserve_pool: bool,
    wl_threshold: Option<u32>,
}
Expand description

Attach of an MTD device to UBI, returned by DeviceInfo::attach.

Options that aren’t set leave the choice to the kernel, and kernels that don’t know an option ignore it. AttachOptions::run attaches the device.

use flashkit_ubi_linux::DeviceInfo;

let device = DeviceInfo::attach(3)
    .vid_header_offset(2048)
    .max_beb_per1024(20)
    .run()?;

Fields§

§mtd_number: u32§number: Option<u32>§vid_header_offset: Option<u32>§max_beb_per1024: Option<u16>§disable_fastmap: bool§reserve_pool: bool§wl_threshold: Option<u32>

Implementations§

§

impl AttachOptions

pub(crate) const fn new(mtd_number: u32) -> Self

Returns the options for MTD device mtd_number with nothing set.

pub const fn number(self, number: u32) -> Self

Sets the number of the new UBI device. By default, the kernel picks one.

pub const fn vid_header_offset(self, offset: u32) -> Self

Sets the offset of the VID header in each physical eraseblock. By default, it follows the EC header at the next subpage.

pub const fn max_beb_per1024(self, count: u16) -> Self

Sets the most bad physical eraseblocks expected per 1024, from 0 to 768. UBI reserves blocks to replace them. By default, the kernel uses CONFIG_MTD_UBI_BEB_LIMIT. Added in Linux 3.7.

pub const fn disable_fastmap(self) -> Self

Stops using fastmap and removes an existing one. Added in Linux 6.1.

pub const fn reserve_pool(self) -> Self

Reserves free physical eraseblocks for the fastmap pools. Added in Linux 6.7.

pub const fn wl_threshold(self, threshold: u32) -> Self

Sets the largest difference between the highest and the lowest erase counter before wear leveling moves data, from 2 to 65536. By default, the kernel uses CONFIG_MTD_UBI_WL_THRESHOLD. Added in Linux 7.3.

pub fn run(&self) -> Result<DeviceInfo, DeviceError>

Attaches the MTD device to UBI with these options.

§Errors

Returns DeviceError::OutOfRange if a number doesn’t fit into the request of the kernel, DeviceError::Attach if the kernel refuses to attach, for example because the MTD device is attached already, and another error if the UBI control device or the new device in sysfs can’t be read.

fn request(&self) -> Result<UbiAttachReq, DeviceError>

Returns the request of the kernel.

Trait Implementations§

§

impl Clone for AttachOptions

§

fn clone(&self) -> AttachOptions

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 Copy for AttachOptions

§

impl Debug for AttachOptions

§

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

Formats the value using the given formatter. Read more
§

impl Eq for AttachOptions

§

impl PartialEq for AttachOptions

§

fn eq(&self, other: &AttachOptions) -> bool

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

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

Inequality operator !=. Read more
§

impl StructuralPartialEq for AttachOptions

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.