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.