On this page
Function std::os::unix::fs::fchown
pub fn fchown<F: AsFd>(fd: F, uid: Option<u32>, gid: Option<u32>) -> Result<()>
Available on Unix only.
Change the owner and group of the file referenced by the specified open file descriptor.
For semantics and required privileges, see chown
.
Examples
use std::os::unix::fs;
fn main() -> std::io::Result<()> {
let f = std::fs::File::open("/file")?;
fs::fchown(&f, Some(0), Some(0))?;
Ok(())
}
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/os/unix/fs/fn.fchown.html