devela::_dep::nc::call

Function fchmodat2

pub unsafe fn fchmodat2<P>(
    dirfd: i32,
    filename: P,
    mode: u32,
    flags: u32,
) -> Result<(), i32> 
where P: AsRef<Path>,
Available on crate feature dep_nc only.
Expand description

Change permissions of a file.

Like fchmodat(), with specifying extra flags.

§Examples

let filename = "/tmp/nc-fchmodat2";
let fd = unsafe {
    nc::openat(
        nc::AT_FDCWD,
        filename,
        nc::O_CREAT | nc::O_WRONLY,
        0o644
    )
};
assert!(fd.is_ok());
let fd = fd.unwrap();
let ret = unsafe { nc::close(fd) };
assert!(ret.is_ok());
let ret = unsafe { nc::fchmodat2(nc::AT_FDCWD, filename, 0o600, nc::AT_SYMLINK_NOFOLLOW as u32) };
assert!(ret.is_ok());
let ret = unsafe { nc::unlinkat(nc::AT_FDCWD, filename, 0) };
assert!(ret.is_ok());