[PATCH 2/5] server: Store the real Unix path.

Zebediah Figura z.figura12 at gmail.com
Sat Mar 14 10:40:58 CDT 2020


So that we can query the Unix symlink target from a file handle.

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 dlls/ntdll/tests/file.c |  2 +-
 server/fd.c             | 16 ++++++++++++----
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
index 814353e7625..75a67e8095a 100644
--- a/dlls/ntdll/tests/file.c
+++ b/dlls/ntdll/tests/file.c
@@ -2097,7 +2097,7 @@ static void test_file_rename_information(void)
     res = pNtQueryInformationFile( handle, &io, fni, sizeof(FILE_NAME_INFORMATION) + MAX_PATH * sizeof(WCHAR), FileNameInformation );
     ok( res == STATUS_SUCCESS, "res expected STATUS_SUCCESS, got %x\n", res );
     fni->FileName[ fni->FileNameLength / sizeof(WCHAR) ] = 0;
-    todo_wine ok( !lstrcmpiW(fni->FileName, newpath + 2), "FileName expected %s, got %s\n",
+    ok( !lstrcmpiW(fni->FileName, newpath + 2), "FileName expected %s, got %s\n",
                   wine_dbgstr_w(newpath + 2), wine_dbgstr_w(fni->FileName) );
     HeapFree( GetProcessHeap(), 0, fni );
 
diff --git a/server/fd.c b/server/fd.c
index e7f57966b26..5019ae2da00 100644
--- a/server/fd.c
+++ b/server/fd.c
@@ -1756,6 +1756,7 @@ struct fd *open_fd( struct fd *root, const char *name, int flags, mode_t *mode,
     struct fd *fd;
     int root_fd = -1;
     int rw_mode;
+    char *path;
 
     if (((options & FILE_DELETE_ON_CLOSE) && !(access & DELETE)) ||
         ((options & FILE_DIRECTORY_FILE) && (flags & O_TRUNC)))
@@ -1805,8 +1806,6 @@ struct fd *open_fd( struct fd *root, const char *name, int flags, mode_t *mode,
     }
     else rw_mode = O_RDONLY;
 
-    fd->unix_name = dup_fd_name( root, name );
-
     if ((fd->unix_fd = open( name, rw_mode | (flags & ~O_TRUNC), *mode )) == -1)
     {
         /* if we tried to open a directory for write access, retry read-only */
@@ -1823,6 +1822,13 @@ struct fd *open_fd( struct fd *root, const char *name, int flags, mode_t *mode,
         }
     }
 
+    fd->unix_name = NULL;
+    if ((path = dup_fd_name( root, name )))
+    {
+        fd->unix_name = realpath( path, NULL );
+        free( path );
+    }
+
     closed_fd->unix_fd = fd->unix_fd;
     closed_fd->unlink = 0;
     closed_fd->unix_name = fd->unix_name;
@@ -2441,8 +2447,10 @@ static void set_fd_name( struct fd *fd, struct fd *root, const char *nameptr,
     }
 
     free( fd->unix_name );
-    fd->unix_name = name;
-    fd->closed->unix_name = name;
+    fd->closed->unix_name = fd->unix_name = realpath( name, NULL );
+    free( name );
+    if (!fd->unix_name)
+        set_error( STATUS_NO_MEMORY );
     return;
 
 failed:
-- 
2.25.1




More information about the wine-devel mailing list