Skip to content

Commit

Permalink
Return chroot unsupported error for vxworks and fuchsia
Browse files Browse the repository at this point in the history
  • Loading branch information
B I Mohammed Abbas committed Jul 23, 2024
1 parent 786ad3d commit 4f4f362
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 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 @@ -1064,7 +1064,6 @@ pub fn lchown<P: AsRef<Path>>(dir: P, uid: Option<u32>, gid: Option<u32>) -> io:
/// }
/// ```
#[stable(feature = "unix_chroot", since = "1.56.0")]
#[cfg(not(any(target_os = "fuchsia", target_os = "vxworks")))]
pub fn chroot<P: AsRef<Path>>(dir: P) -> io::Result<()> {
sys::fs::chroot(dir.as_ref())
}
8 changes: 7 additions & 1 deletion library/std/src/sys/pal/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1980,14 +1980,20 @@ pub fn lchown(path: &Path, uid: u32, gid: u32) -> io::Result<()> {
#[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",))
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(|_| ()))
}

#[cfg(any(target_os = "fuchsia", target_os = "vxworks"))]
pub fn chroot(dir: &Path) -> io::Result<()> {
let _ = dir;
Err(io::const_io_error!(io::ErrorKind::Unsupported, "chroot not supported."))
}

pub use remove_dir_impl::remove_dir_all;

// Fallback for REDOX, ESP-ID, Horizon, Vita, Vxworks and Miri
Expand Down

0 comments on commit 4f4f362

Please sign in to comment.