ntdll-avoid-fstatat: New patch.

This commit is contained in:
Zebediah Figura 2020-03-28 13:22:08 -05:00
parent f9d1798edb
commit b14430433d
3 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,37 @@
From 997cebb3b42bb30bdfaab21c6e8260d7088ac972 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Sat, 28 Mar 2020 13:17:25 -0500
Subject: [PATCH] ntdll: Avoid fstatat().
---
dlls/ntdll/file.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index bd27d5a434..e64435252f 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -139,8 +139,18 @@ static inline ULONG get_file_attributes( const struct stat *st )
static BOOL fd_is_mount_point( int fd, const struct stat *st )
{
struct stat parent;
- return S_ISDIR( st->st_mode ) && !fstatat( fd, "..", &parent, 0 )
- && (parent.st_dev != st->st_dev || parent.st_ino == st->st_ino);
+ BOOL ret = FALSE;
+ int cwd;
+
+ if (!S_ISDIR( st->st_mode )) return FALSE;
+ if ((cwd = open(".", O_RDONLY) == -1)) return FALSE;
+ if (!fchdir( fd ))
+ {
+ ret = !stat( "..", &parent ) && (parent.st_dev != st->st_dev || parent.st_ino == st->st_ino);
+ if (fchdir( cwd ) == -1) chdir( "/" );
+ }
+ close( cwd );
+ return ret;
}
/* get the stat info and file attributes for a file (by file descriptor) */
--
2.25.2

View File

@ -0,0 +1,4 @@
# Older versions of the Mac SDK, such as the one currently used to compile Mac
# packages, don't have fstatat(3). We might want to put this into upstream Wine,
# but if we can get away with updating the SDK instead, that might be
# preferable.

View File

@ -214,6 +214,7 @@ patch_enable_all ()
enable_ntdll_WRITECOPY="$1"
enable_ntdll_Zero_mod_name="$1"
enable_ntdll_aarch_TEB="$1"
enable_ntdll_avoid_fstatat="$1"
enable_ntdll_ext4_case_folder="$1"
enable_ntdll_set_full_cpu_context="$1"
enable_ntdll_unaligned_futex="$1"
@ -752,6 +753,9 @@ patch_enable ()
ntdll-aarch-TEB)
enable_ntdll_aarch_TEB="$2"
;;
ntdll-avoid-fstatat)
enable_ntdll_avoid_fstatat="$2"
;;
ntdll-ext4-case-folder)
enable_ntdll_ext4_case_folder="$2"
;;
@ -4955,6 +4959,18 @@ if test "$enable_ntdll_aarch_TEB" -eq 1; then
) >> "$patchlist"
fi
# Patchset ntdll-avoid-fstatat
# |
# | Modified files:
# | * dlls/ntdll/file.c
# |
if test "$enable_ntdll_avoid_fstatat" -eq 1; then
patch_apply ntdll-avoid-fstatat/0001-ntdll-Avoid-fstatat.patch
(
printf '%s\n' '+ { "Zebediah Figura", "ntdll: Avoid fstatat().", 1 },';
) >> "$patchlist"
fi
# Patchset ntdll-ext4-case-folder
# |
# | This patchset fixes the following Wine bugs: