Function nix::unistd::fchownat

source ·
pub fn fchownat<P: ?Sized + NixPath>(
    dirfd: Option<RawFd>,
    path: &P,
    owner: Option<Uid>,
    group: Option<Gid>,
    flag: AtFlags,
) -> Result<()>
Expand description

Change the ownership of the file at path to be owned by the specified owner (user) and group.

The owner/group for the provided path name will not be modified if None is provided for that argument. Ownership change will be attempted for the path only if Some owner/group is provided.

The file to be changed is determined relative to the directory associated with the file descriptor dirfd or the current working directory if dirfd is None.

If flag is AtFlags::AT_SYMLINK_NOFOLLOW and path names a symbolic link, then the mode of the symbolic link is changed.

fchownat(None, path, owner, group, AtFlags::AT_SYMLINK_NOFOLLOW) is identical to a call libc::lchown(path, owner, group). That’s why lchown is unimplemented in the nix crate.

§References

fchownat(2).