Skip to content

Commit 227b5af

Browse files
author
B I Mohammed Abbas
committed
Disable dirfd for vxworks, Return unsupported error from set_times and lchown for vxworks
1 parent 22a6797 commit 227b5af

File tree

1 file changed

+16
-2
lines changed
  • std/src/sys/pal/unix

1 file changed

+16
-2
lines changed

std/src/sys/pal/unix/fs.rs

+16-2
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,7 @@ impl Drop for Dir {
857857
target_os = "espidf",
858858
target_os = "fuchsia",
859859
target_os = "horizon",
860+
target_os = "vxworks",
860861
)))]
861862
{
862863
let fd = unsafe { libc::dirfd(self.0) };
@@ -1313,7 +1314,12 @@ impl File {
13131314
}
13141315

13151316
pub fn set_times(&self, times: FileTimes) -> io::Result<()> {
1316-
#[cfg(not(any(target_os = "redox", target_os = "espidf", target_os = "horizon")))]
1317+
#[cfg(not(any(
1318+
target_os = "redox",
1319+
target_os = "espidf",
1320+
target_os = "horizon",
1321+
target_os = "vxworks"
1322+
)))]
13171323
let to_timespec = |time: Option<SystemTime>| match time {
13181324
Some(time) if let Some(ts) = time.t.to_timespec() => Ok(ts),
13191325
Some(time) if time > crate::sys::time::UNIX_EPOCH => Err(io::const_io_error!(
@@ -1327,10 +1333,11 @@ impl File {
13271333
None => Ok(libc::timespec { tv_sec: 0, tv_nsec: libc::UTIME_OMIT as _ }),
13281334
};
13291335
cfg_if::cfg_if! {
1330-
if #[cfg(any(target_os = "redox", target_os = "espidf", target_os = "horizon"))] {
1336+
if #[cfg(any(target_os = "redox", target_os = "espidf", target_os = "horizon", target_os = "vxworks"))] {
13311337
// Redox doesn't appear to support `UTIME_OMIT`.
13321338
// ESP-IDF and HorizonOS do not support `futimens` at all and the behavior for those OS is therefore
13331339
// the same as for Redox.
1340+
// `futimens` and `UTIME_OMIT` are a work in progress for vxworks.
13341341
let _ = times;
13351342
Err(io::const_io_error!(
13361343
io::ErrorKind::Unsupported,
@@ -1962,13 +1969,20 @@ pub fn fchown(fd: c_int, uid: u32, gid: u32) -> io::Result<()> {
19621969
Ok(())
19631970
}
19641971

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

1980+
#[cfg(target_os = "vxworks")]
1981+
pub fn lchown(path: &Path, uid: u32, gid: u32) -> io::Result<()> {
1982+
let (_, _, _) = (path, uid, gid);
1983+
Err(io::const_io_error!(io::ErrorKind::Unsupported, "lchown not supported by vxworks",))
1984+
}
1985+
19721986
#[cfg(not(any(target_os = "fuchsia", target_os = "vxworks")))]
19731987
pub fn chroot(dir: &Path) -> io::Result<()> {
19741988
run_path_with_cstr(dir, &|dir| cvt(unsafe { libc::chroot(dir.as_ptr()) }).map(|_| ()))

0 commit comments

Comments
 (0)