Struct SysfsDir
pub(crate) struct SysfsDir {
path: PathBuf,
dir: OwnedFd,
}Expand description
Open directory of a UBI device or volume in sysfs, such as
/sys/class/ubi/ubi0.
Attributes are read relative to the open directory into stack buffers, so reading them doesn’t allocate.
Fields§
§path: PathBuf§dir: OwnedFdImplementations§
§impl SysfsDir
impl SysfsDir
pub(crate) fn open_device(
root: &Path,
number: u32,
) -> Result<Option<Self>, DeviceError>
pub(crate) fn open_device( root: &Path, number: u32, ) -> Result<Option<Self>, DeviceError>
Opens the directory of UBI device number in the class directory
root, or returns None if it doesn’t exist.
pub(crate) fn open_volume(
root: &Path,
device_number: u32,
id: u32,
) -> Result<Option<Self>, DeviceError>
pub(crate) fn open_volume( root: &Path, device_number: u32, id: u32, ) -> Result<Option<Self>, DeviceError>
Opens the directory of volume id of UBI device device_number in the
class directory root, or returns None if it doesn’t exist.
pub(crate) fn device_path(root: &Path, number: u32) -> PathBuf
pub(crate) fn device_path(root: &Path, number: u32) -> PathBuf
Returns the path of the directory of UBI device number in root.
pub(crate) fn numbers(
root: &Path,
parse: impl Fn(&str) -> Option<u32>,
) -> Result<Vec<u32>, DeviceError>
pub(crate) fn numbers( root: &Path, parse: impl Fn(&str) -> Option<u32>, ) -> Result<Vec<u32>, DeviceError>
Returns the numbers that parse finds in the entry names of the class
directory root, in ascending order. A missing directory, as without
the UBI driver, has none.
fn for_each_entry(root: &Path, each: impl FnMut(&str)) -> Result<(), Errno>
Available on Android or Linux only.
fn for_each_entry(root: &Path, each: impl FnMut(&str)) -> Result<(), Errno>
Calls each with the name of each entry in the directory root
that is valid UTF-8.
pub(crate) fn parse_digits(digits: &str) -> Option<u32>
pub(crate) fn parse_digits(digits: &str) -> Option<u32>
Parses a decimal number without sign, spaces or other characters.
pub(crate) fn read_text<'b>(
&self,
name: &str,
buf: &'b mut [u8],
) -> Result<Option<&'b str>, DeviceError>
pub(crate) fn read_text<'b>( &self, name: &str, buf: &'b mut [u8], ) -> Result<Option<&'b str>, DeviceError>
Reads the text attribute name into buf without its line break, or
returns None if it doesn’t exist.
pub(crate) fn parse<T: FromStr>(
&self,
name: &str,
) -> Result<Option<T>, DeviceError>
pub(crate) fn parse<T: FromStr>( &self, name: &str, ) -> Result<Option<T>, DeviceError>
Reads and parses the attribute name, or returns None if it doesn’t
exist.
pub(crate) fn parse_required<T: FromStr>(
&self,
name: &str,
) -> Result<T, DeviceError>
pub(crate) fn parse_required<T: FromStr>( &self, name: &str, ) -> Result<T, DeviceError>
Reads and parses the attribute name, which every kernel has.
pub(crate) fn parse_flag(&self, name: &str) -> Result<Option<bool>, DeviceError>
pub(crate) fn parse_flag(&self, name: &str) -> Result<Option<bool>, DeviceError>
Reads the boolean attribute name, 0 or 1, or returns None if
it doesn’t exist.
pub(crate) fn parse_flag_required(
&self,
name: &str,
) -> Result<bool, DeviceError>
pub(crate) fn parse_flag_required( &self, name: &str, ) -> Result<bool, DeviceError>
Reads the boolean attribute name, which every kernel has.
pub(crate) fn parse_volume_name(
&self,
name: &str,
) -> Result<VolumeName, DeviceError>
pub(crate) fn parse_volume_name( &self, name: &str, ) -> Result<VolumeName, DeviceError>
Reads the volume name in the attribute name.
pub(crate) fn parse_char_device(&self) -> Result<(u32, u32), DeviceError>
pub(crate) fn parse_char_device(&self) -> Result<(u32, u32), DeviceError>
Parses the dev attribute, such as 249:0.
pub(crate) fn missing(&self, name: &str) -> DeviceError
pub(crate) fn missing(&self, name: &str) -> DeviceError
Returns the error for the attribute name that doesn’t exist.
pub(crate) fn invalid(&self, name: &str, value: &str) -> DeviceError
pub(crate) fn invalid(&self, name: &str, value: &str) -> DeviceError
Returns the error for the attribute name with an invalid value.
fn open(path: PathBuf) -> Result<Option<Self>, DeviceError>
fn open(path: PathBuf) -> Result<Option<Self>, DeviceError>
Opens the directory at path, or returns None if it doesn’t exist.
fn entry(root: &Path, entry: Arguments<'_>) -> PathBuf
fn entry(root: &Path, entry: Arguments<'_>) -> PathBuf
Returns the path entry in root, with one allocation.
fn read_bytes<'b>(
&self,
name: &str,
buf: &'b mut [u8],
) -> Result<Option<&'b [u8]>, DeviceError>
fn read_bytes<'b>( &self, name: &str, buf: &'b mut [u8], ) -> Result<Option<&'b [u8]>, DeviceError>
Reads the attribute name into buf without its line break, or
returns None if it doesn’t exist.