pub struct Mount { /* private fields */ }
Expand description
Handle for managing a mounted file system.
Implementations
sourceimpl Mount
impl Mount
sourcepub fn builder<'a>() -> MountBuilder<'a>
pub fn builder<'a>() -> MountBuilder<'a>
Performs a mount with builder syntax.
sourcepub 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>>,
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>>,
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 loop
feature is enabled, and the source
is a file with an extension, a loopback
device will be created, and the file will be associated with the loopback device. If the
extension is iso
or squashfs
, the filesystem type will be set accordingly, and 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.
sourcepub fn backing_loop_device(&self) -> Option<&Path>
pub fn backing_loop_device(&self) -> Option<&Path>
If the device was associated with a loopback device, that device’s path can be retrieved here.
sourcepub fn get_fstype(&self) -> &str
pub fn get_fstype(&self) -> &str
Describes the file system which this mount was mounted with.
This is useful in the event that the mounted device was mounted automatically.
sourcepub fn target_path(&self) -> &Path
pub fn target_path(&self) -> &Path
Return the path this mount was mounted on.
Trait Implementations
sourceimpl Unmount for Mount
impl Unmount for Mount
sourcefn unmount(&self, flags: UnmountFlags) -> Result<()>
fn unmount(&self, flags: UnmountFlags) -> Result<()>
Unmount this mount with the given flags
. Read more
sourcefn into_unmount_drop(self, flags: UnmountFlags) -> UnmountDrop<Self> where
Self: Sized,
fn into_unmount_drop(self, flags: UnmountFlags) -> UnmountDrop<Self> where
Self: Sized,
Upgrades Self
into an UnmountDrop
, which will unmount the mount when it is dropped.
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more