Function umount2
pub unsafe fn umount2<P>(name: P, flags: u32) -> Result<(), i32> ⓘ
Available on crate feature
dep_nc
only.Expand description
Unmount filesystem.
§Examples
let target_dir = "/tmp/nc-umount2";
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 flags = nc::UMOUNT_NOFOLLOW;
let ret = unsafe { nc::umount2(target_dir, flags) };
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());