[−][src]Struct sys_mount::Mount
Handle for managing a mounted file system.
Implementations
impl Mount[src]
pub fn new<'a, S, T, F>(
source: S,
target: T,
fstype: F,
flags: MountFlags,
data: Option<&str>
) -> Result<Self> where
S: AsRef<Path>,
T: AsRef<Path>,
F: Into<FilesystemType<'a>>, [src]
source: S,
target: T,
fstype: F,
flags: MountFlags,
data: Option<&str>
) -> Result<Self> where
S: AsRef<Path>,
T: AsRef<Path>,
F: Into<FilesystemType<'a>>,
Mounts a file system at source to a target path in the system.
extern crate sys_mount; use sys_mount::{ Mount, MountFlags, SupportedFilesystems }; fn main() { // Fetch a list of supported file systems. // When mounting, a file system will be selected from this. let supported = SupportedFilesystems::new().unwrap(); // Attempt to mount the src device to the dest directory. let mount_result = Mount::new( "/imaginary/block/device", "/tmp/location", &supported, MountFlags::empty(), None ); }
Notes
The provided source device and target destinations must exist within the file system.
If the source is a file with an iso or squashfs extension, a loopback device will
be created, and the file will be associated with the loopback device. The MountFlags
will also be modified to ensure that the MountFlags::RDONLY flag is set before mounting.
The fstype parameter accepts either a &str or &SupportedFilesystem as input. If the
input is a &str, then a particular file system will be used to mount the source with.
If the input is a &SupportedFilesystems, then the file system will be selected
automatically from the list.
The automatic variant of fstype works by attempting to mount the source with all
supported device-based file systems until it succeeds, or fails after trying all
possible options.
pub fn backing_loop_device(&self) -> Option<&Path>[src]
If the device was associated with a loopback device, that device's path can be retrieved here.
pub fn get_fstype(&self) -> &str[src]
Describes the file system which this mount was mounted with.
This is useful in the event that the mounted device was mounted automatically.
Trait Implementations
impl Debug for Mount[src]
impl Unmount for Mount[src]
fn unmount(&self, flags: UnmountFlags) -> Result<()>[src]
fn into_unmount_drop(self, flags: UnmountFlags) -> UnmountDrop<Self> where
Self: Sized, [src]
Self: Sized,
Auto Trait Implementations
impl RefUnwindSafe for Mount
impl Send for Mount
impl Sync for Mount
impl Unpin for Mount
impl UnwindSafe for Mount
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,