Struct sys_mount::Mount[][src]

pub struct Mount { /* fields omitted */ }

Handle for managing a mounted file system.

Methods

impl Mount
[src]

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".into(),
        "/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.

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]

Formats the value using the given formatter. Read more

impl Unmount for Mount
[src]

Unmount this mount with the given flags. Read more

Upgrades Self into an UnmountDrop, which will unmount the mount when it is dropped.

Auto Trait Implementations

impl Send for Mount

impl Sync for Mount