Function lchown
pub unsafe fn lchown<P>(filename: P, user: u32, group: u32) -> Result<(), i32> ⓘ
Available on crate feature
dep_nc
only.Expand description
Change ownership of a file. Does not deference symbolic link.
§Examples
let filename = "/tmp/nc-lchown";
let ret = unsafe {
nc::openat(
nc::AT_FDCWD,
filename,
nc::O_CREAT | nc::O_WRONLY | nc::O_TRUNC,
0o644
)
};
assert!(ret.is_ok());
let fd = ret.unwrap();
let ret = unsafe { nc::close(fd) };
assert!(ret.is_ok());
let ret = unsafe { nc::lchown(filename, 0, 0) };
assert!(ret.is_err());
assert_eq!(ret, Err(nc::EPERM));
let ret = unsafe { nc::unlinkat(nc::AT_FDCWD, filename, 0) };
assert!(ret.is_ok());