File: use-correct-syscall-on-time64.patch

package info (click to toggle)
rust-filetime 0.2.26-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 224 kB
  • sloc: makefile: 2
file content (27 lines) | stat: -rw-r--r-- 1,242 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Index: rust-filetime-0.2.23/src/unix/linux.rs
===================================================================
--- rust-filetime-0.2.23.orig/src/unix/linux.rs
+++ rust-filetime-0.2.23/src/unix/linux.rs
@@ -40,8 +40,21 @@ pub fn set_file_handle_times(
         // Linux, the syscall itself can accept a file descriptor there).
         #[cfg(not(target_env = "musl"))]
         let rc = unsafe {
+            let mut syscallno = libc::SYS_utimensat;
+
+            // on 32-bit systems using 64-bit time through the "time64" mechanism
+            // we need to use a different syscall.
+            // we exclude x86_64 specifically, because "x32" systems use 64-bit
+            // time but do not use the time64 ABI
+            #[cfg(all(target_pointer_width="32",not(target_arch = "x86_64")))]
+            if std::mem::size_of::<libc::time_t>() == 8 {
+                // unfortunately the libc crate doesn't provide a constant
+                // for this.
+                syscallno = 412; // utimensat_time64
+            }
+
             libc::syscall(
-                libc::SYS_utimensat,
+                syscallno,
                 f.as_raw_fd(),
                 ptr::null::<libc::c_char>(),
                 times.as_ptr(),