diff --git a/patches/ntdll-Junction_Points/0025-ntdll-Allow-set_file_times_precise-to-work-on-repars.patch b/patches/ntdll-Junction_Points/0025-ntdll-Allow-set_file_times_precise-to-work-on-repars.patch index 4c1fb50d..1e89aec0 100644 --- a/patches/ntdll-Junction_Points/0025-ntdll-Allow-set_file_times_precise-to-work-on-repars.patch +++ b/patches/ntdll-Junction_Points/0025-ntdll-Allow-set_file_times_precise-to-work-on-repars.patch @@ -1,4 +1,4 @@ -From 3ca3985f573529e825c167e8e60d909ad3963260 Mon Sep 17 00:00:00 2001 +From 3191aede6d60d0d253aa4eb57fee1f48445a6fa3 Mon Sep 17 00:00:00 2001 From: "Erich E. Hoover" Date: Sun, 22 Nov 2020 22:37:33 -0700 Subject: [PATCH] ntdll: Allow set_file_times_precise to work on reparse @@ -6,14 +6,14 @@ Subject: [PATCH] ntdll: Allow set_file_times_precise to work on reparse --- configure.ac | 3 ++- - dlls/ntdll/unix/file.c | 21 ++++++++++++++------- - 2 files changed, 16 insertions(+), 8 deletions(-) + dlls/ntdll/unix/file.c | 22 ++++++++++++++++++---- + 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac -index 6a761565e86..2809ff48d1a 100644 +index a944591343d..efb4035295a 100644 --- a/configure.ac +++ b/configure.ac -@@ -2203,7 +2203,8 @@ AC_CHECK_FUNCS(\ +@@ -2224,7 +2224,8 @@ AC_CHECK_FUNCS(\ sigprocmask \ symlink \ tcdrain \ @@ -24,27 +24,25 @@ index 6a761565e86..2809ff48d1a 100644 CFLAGS="$ac_save_CFLAGS" diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c -index ebb79c9963b..c3000b25dcd 100644 +index d4a9aa50108..406ee2242bc 100644 --- a/dlls/ntdll/unix/file.c +++ b/dlls/ntdll/unix/file.c -@@ -1726,12 +1726,12 @@ static int get_file_info( const char *path, struct stat *st, ULONG *attr ) +@@ -1740,6 +1740,14 @@ static int get_file_info( const char *path, struct stat *st, ULONG *attr ) } --#if defined(__ANDROID__) && !defined(HAVE_FUTIMENS) --static int futimens( int fd, const struct timespec spec[2] ) -+#if !defined(HAVE_UTIMENSAT) && defined(__ANDROID__) ++#if defined(__ANDROID__) && !defined(HAVE_UTIMENSAT) +static int utimensat( int fd, const char *name, const struct timespec spec[2], int flags ) - { -- return syscall( __NR_utimensat, fd, NULL, spec, 0 ); ++{ + return syscall( __NR_utimensat, fd, name, spec, flags ); - } --#define HAVE_FUTIMENS ++} +#define HAVE_UTIMENSAT - #endif /* __ANDROID__ */ - - #ifndef UTIME_OMIT -@@ -1741,7 +1741,7 @@ static int futimens( int fd, const struct timespec spec[2] ) ++#endif /* __ANDROID__ */ ++ + #if defined(__ANDROID__) && !defined(HAVE_FUTIMENS) + static int futimens( int fd, const struct timespec spec[2] ) + { +@@ -1755,7 +1763,7 @@ static int futimens( int fd, const struct timespec spec[2] ) static BOOL set_file_times_precise( int fd, const LARGE_INTEGER *mtime, const LARGE_INTEGER *atime, NTSTATUS *status ) { @@ -53,25 +51,26 @@ index ebb79c9963b..c3000b25dcd 100644 struct timespec tv[2]; tv[0].tv_sec = tv[1].tv_sec = 0; -@@ -1757,9 +1757,16 @@ static BOOL set_file_times_precise( int fd, const LARGE_INTEGER *mtime, +@@ -1771,10 +1779,16 @@ static BOOL set_file_times_precise( int fd, const LARGE_INTEGER *mtime, tv[1].tv_nsec = (mtime->QuadPart % 10000000) * 100; } #ifdef __APPLE__ - if (!&futimens) return FALSE; -+ if (!&utimensat) return FALSE; ++ if (!&utimensat || !&futimens) return FALSE; +#endif +#if defined(HAVE_UTIMENSAT) -+ /* futimens does not work on O_PATH|O_NOFOLLOW (O_SYMLINK) file descriptors, so if the file -+ * descriptor is for a symlink then use utimensat with an empty path (.) and do not follow the -+ * link. Since this approach works for both symlinks and regular files, just use utimensat. */ -+ if (utimensat(fd, ".", tv, AT_SYMLINK_NOFOLLOW) == -1) *status = errno_to_status( errno ); -+#else -+ if (futimens(fd, tv) == -1) *status = errno_to_status( errno ); ++ /* futimens does not work on O_PATH|O_NOFOLLOW (O_SYMLINK) file descriptors, so if fd is for a ++ * symlink then use utimensat with an empty path (.) and do not follow the link. */ ++ if (utimensat(fd, ".", tv, AT_SYMLINK_NOFOLLOW) == 0) *status = STATUS_SUCCESS; ++ else #endif - if (futimens( fd, tv ) == -1) *status = errno_to_status( errno ); - else *status = STATUS_SUCCESS; +- else *status = STATUS_SUCCESS; ++ if (futimens(fd, tv) == 0) *status = STATUS_SUCCESS; ++ else *status = errno_to_status( errno ); return TRUE; #else + return FALSE; -- -2.29.2 +2.17.1