Expand description
High level abstraction over the mount
and umount2
system calls.
Additionally creates loopback devices automatically when mounting an iso or squashfs file.
Example
extern crate sys_mount;
use std::process::exit;
use sys_mount::{
Mount,
MountFlags,
SupportedFilesystems,
Unmount,
UnmountFlags
};
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
);
match mount_result {
Ok(mount) => {
// Make the mount temporary, so that it will be unmounted on drop.
let mount = mount.into_unmount_drop(UnmountFlags::DETACH);
// Do thing with the mounted device.
}
Err(why) => {
eprintln!("failed to mount device: {}", why);
exit(1);
}
}
}
Structs
Handle for managing a mounted file system.
Flags which may be specified when mounting a file system.
An abstraction that will ensure that temporary mounts are dropped in reverse.
Data structure for validating if a filesystem argument is valid, and used within
automatic file system mounting.
Unmounts the underlying mounted device upon drop.
Flags which may be specified when unmounting a file system.
Enums
Defines how the file system type should be derived for a mount – auto or manual
Traits
Unmount trait which enables any type that implements it to be upgraded into an
UnmountDrop
.