devela::_dep::nc

Function mount

pub unsafe fn mount<P>(
    dev_name: P,
    dir_name: P,
    fs_type: P,
    flags: u32,
    data_page: *mut c_void,
) -> Result<(), i32> 
where P: AsRef<Path>,
Available on crate feature dep_nc only.
Expand description

Mount filesystem.

§Examples

let target_dir = "/tmp/nc-mount";
let ret = unsafe { nc::mkdirat(nc::AT_FDCWD, target_dir, 0o755) };
assert!(ret.is_ok());

let src_dir = "/etc";
let fs_type = "";
let mount_flags = nc::MS_BIND | nc::MS_RDONLY;
let data = std::ptr::null_mut();
let ret = unsafe { nc::mount(src_dir, target_dir, fs_type, mount_flags, data) };
assert!(ret.is_err());
assert_eq!(ret, Err(nc::EPERM));

let ret = unsafe { nc::unlinkat(nc::AT_FDCWD, target_dir, nc::AT_REMOVEDIR) };
assert!(ret.is_ok());