about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJosh Triplett <josh@joshtriplett.org>2022-07-20 21:14:24 -0700
committerJosh Triplett <josh@joshtriplett.org>2022-07-22 03:52:50 -0700
commit11d9be63596c28d4f6318194e68e16cf0d172287 (patch)
tree14e04b367720517e36700c22fedbd19488902d1f
parent3da17293e78198575c8adbab40ec783f250e9fe3 (diff)
downloadrust-11d9be63596c28d4f6318194e68e16cf0d172287.tar.gz
rust-11d9be63596c28d4f6318194e68e16cf0d172287.zip
Stub out `set_times` to return unsupported on Redox
Redox doesn't appear to support `UTIME_OMIT`, so we can't set file times
individually.
-rw-r--r--library/std/src/sys/unix/fs.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs
index 59f17a8659d..1a4c2f8caf4 100644
--- a/library/std/src/sys/unix/fs.rs
+++ b/library/std/src/sys/unix/fs.rs
@@ -538,6 +538,11 @@ impl fmt::Debug for FileTimes {
 
 impl Default for FileTimes {
     fn default() -> Self {
+        // Redox doesn't appear to support `UTIME_OMIT`, so we stub it out here, and always return
+        // an error in `set_times`.
+        #[cfg(target_os = "redox")]
+        let omit = libc::timespec { tv_sec: 0, tv_nsec: 0 };
+        #[cfg(not(target_os = "redox"))]
         let omit = libc::timespec { tv_sec: 0, tv_nsec: libc::UTIME_OMIT as _ };
         Self([omit; 2])
     }
@@ -1064,8 +1069,14 @@ impl File {
 
     pub fn set_times(&self, times: FileTimes) -> io::Result<()> {
         cfg_if::cfg_if! {
-            // futimens requires macOS 10.13, and Android API level 19
-            if #[cfg(any(target_os = "android", target_os = "macos"))] {
+            if #[cfg(target_os = "redox")] {
+                // Redox doesn't appear to support `UTIME_OMIT`.
+                return Err(io::const_io_error!(
+                    io::ErrorKind::Unsupported,
+                    "setting file times not supported",
+                ));
+            } else if #[cfg(any(target_os = "android", target_os = "macos"))] {
+                // futimens requires macOS 10.13, and Android API level 19
                 cvt(unsafe {
                     weak!(fn futimens(c_int, *const libc::timespec) -> c_int);
                     match futimens.get() {