Piotr Caban : ntdll: Work around futimens weak linking problem in set_file_times.

Alexandre Julliard julliard at winehq.org
Thu Nov 7 16:16:05 CST 2019


Module: wine
Branch: master
Commit: b4ec4028597c06bbdbf283b4a5f5957dd2c1b809
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=b4ec4028597c06bbdbf283b4a5f5957dd2c1b809

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Thu Nov  7 16:24:34 2019 +0100

ntdll: Work around futimens weak linking problem in set_file_times.

Newer XCode versions are weak linking to futimens function. Because of
that Wine will crash trying to execute the function on Mac OS <= 10.12.

Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/file.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 655dcb2eaf..dd6d1341b0 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -1907,10 +1907,9 @@ static int futimens( int fd, const struct timespec spec[2] )
 #define UTIME_OMIT ((1 << 30) - 2)
 #endif
 
-static NTSTATUS set_file_times( int fd, const LARGE_INTEGER *mtime, const LARGE_INTEGER *atime )
+static BOOL set_file_times_precise( int fd, const LARGE_INTEGER *mtime,
+        const LARGE_INTEGER *atime, NTSTATUS *status )
 {
-    NTSTATUS status = STATUS_SUCCESS;
-
 #ifdef HAVE_FUTIMENS
     struct timespec tv[2];
 
@@ -1926,12 +1925,29 @@ static NTSTATUS set_file_times( int fd, const LARGE_INTEGER *mtime, const LARGE_
         tv[1].tv_sec = mtime->QuadPart / 10000000 - SECS_1601_TO_1970;
         tv[1].tv_nsec = (mtime->QuadPart % 10000000) * 100;
     }
-    if (futimens( fd, tv ) == -1) status = FILE_GetNtStatus();
+#ifdef __APPLE__
+    if (!&futimens) return FALSE;
+#endif
+    if (futimens( fd, tv ) == -1) *status = FILE_GetNtStatus();
+    else *status = STATUS_SUCCESS;
+    return TRUE;
+#else
+    return FALSE;
+#endif
+}
 
-#elif defined(HAVE_FUTIMES) || defined(HAVE_FUTIMESAT)
+static NTSTATUS set_file_times( int fd, const LARGE_INTEGER *mtime, const LARGE_INTEGER *atime )
+{
+    NTSTATUS status = STATUS_SUCCESS;
+#if defined(HAVE_FUTIMES) || defined(HAVE_FUTIMESAT)
     struct timeval tv[2];
     struct stat st;
+#endif
+
+    if (set_file_times_precise( fd, mtime, atime, &status ))
+        return status;
 
+#if defined(HAVE_FUTIMES) || defined(HAVE_FUTIMESAT)
     if (!atime->QuadPart || !mtime->QuadPart)
     {
 




More information about the wine-cvs mailing list