Expand description
High level abstraction over the mount
and umount2
system calls.
If the loop
feature is enabled (default), additionally supports creating 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::builder()
.fstype("btrfs")
.data("subvol=@home")
.mount("/dev/sda1", "/home");
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§
- Mount
- Handle for managing a mounted file system.
- Mount
Builder - Builder API for mounting devices
- Mount
Flags - Flags which may be specified when mounting a file system.
- Mounts
- An abstraction that will ensure that temporary mounts are dropped in reverse.
- Supported
Filesystems - Data structure for validating if a filesystem argument is valid, and used within automatic file system mounting.
- Unmount
Drop - Unmounts the underlying mounted device upon drop.
- Unmount
Flags - Flags which may be specified when unmounting a file system.
Enums§
- Filesystem
Type - Defines how the file system type should be derived for a mount – auto or manual
- Scoped
Mount Error
Traits§
- Unmount
- Unmount trait which enables any type that implements it to be upgraded into an
UnmountDrop
.
Functions§
- scoped_
mount - Mount a partition temporarily for the duration of the scoped block within.
- swapoff
- Unmounts a swap partition using
libc::swapoff
- unmount
- Unmounts the device at
path
using the providedUnmountFlags
.