Skip to content

Commit

Permalink
Add lchonw unsupported implementation for vxworks
Browse files Browse the repository at this point in the history
  • Loading branch information
B I Mohammed Abbas committed Jul 22, 2024
1 parent 792b498 commit 590fcdd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 0 additions & 1 deletion library/std/src/os/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,6 @@ pub fn fchown<F: AsFd>(fd: F, uid: Option<u32>, gid: Option<u32>) -> io::Result<
/// }
/// ```
#[stable(feature = "unix_chown", since = "1.73.0")]
#[cfg(not(any(target_os = "vxworks")))]
pub fn lchown<P: AsRef<Path>>(dir: P, uid: Option<u32>, gid: Option<u32>) -> io::Result<()> {
sys::fs::lchown(dir.as_ref(), uid.unwrap_or(u32::MAX), gid.unwrap_or(u32::MAX))
}
Expand Down
10 changes: 8 additions & 2 deletions library/std/src/sys/pal/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,7 @@ impl File {
// Redox doesn't appear to support `UTIME_OMIT`.
// ESP-IDF and HorizonOS do not support `futimens` at all and the behavior for those OS is therefore
// the same as for Redox.
// `futimens` and `UTIME_OMIT` are a work in progress for vxworks.
// `futimens` and `UTIME_OMIT` are a work in progress for vxworks.
let _ = times;
Err(io::const_io_error!(
io::ErrorKind::Unsupported,
Expand Down Expand Up @@ -1969,14 +1969,20 @@ pub fn fchown(fd: c_int, uid: u32, gid: u32) -> io::Result<()> {
Ok(())
}

#[cfg(not(any(target_os = "vxworks")))]
#[cfg(not(target_os = "vxworks"))]
pub fn lchown(path: &Path, uid: u32, gid: u32) -> io::Result<()> {
run_path_with_cstr(path, &|path| {
cvt(unsafe { libc::lchown(path.as_ptr(), uid as libc::uid_t, gid as libc::gid_t) })
.map(|_| ())
})
}

#[cfg(target_os = "vxworks")]
pub fn lchown(path: &Path, uid: u32, gid: u32) -> io::Result<()> {
let (_, _, _) = (path, uid, gid);
Err(io::const_io_error!(io::ErrorKind::Unsupported, "lchown not supported by vxworks",))
}

#[cfg(not(any(target_os = "fuchsia", target_os = "vxworks")))]
pub fn chroot(dir: &Path) -> io::Result<()> {
run_path_with_cstr(dir, &|dir| cvt(unsafe { libc::chroot(dir.as_ptr()) }).map(|_| ()))
Expand Down

0 comments on commit 590fcdd

Please sign in to comment.