Alexandre Julliard : ntdll: Return a cleaner Unix path for z: drive in wine_nt_to_unix_file_name().

Alexandre Julliard julliard at winehq.org
Mon Sep 27 15:21:44 CDT 2021


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Sep 27 16:58:46 2021 +0200

ntdll: Return a cleaner Unix path for z: drive in wine_nt_to_unix_file_name().

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/unix/file.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c
index e6f813966a5..43e85b0c955 100644
--- a/dlls/ntdll/unix/file.c
+++ b/dlls/ntdll/unix/file.c
@@ -3445,9 +3445,24 @@ NTSTATUS WINAPI wine_nt_to_unix_file_name( const OBJECT_ATTRIBUTES *attr, char *
 
     if (buffer)
     {
-        if (*size > strlen(buffer)) strcpy( nameA, buffer );
+        struct stat st1, st2;
+        char *name = buffer;
+
+        /* remove dosdevices prefix for z: drive if it points to the Unix root */
+        if (!strncmp( buffer, config_dir, strlen(config_dir) ) &&
+            !strncmp( buffer + strlen(config_dir), "/dosdevices/z:/", 15 ))
+        {
+            char *p = buffer + strlen(config_dir) + 14;
+            *p = 0;
+            if (!stat( buffer, &st1 ) && !stat( "/", &st2 ) &&
+                st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino)
+                name = p;
+            *p = '/';
+        }
+
+        if (*size > strlen(name)) strcpy( nameA, name );
         else status = STATUS_BUFFER_TOO_SMALL;
-        *size = strlen(buffer) + 1;
+        *size = strlen(name) + 1;
         free( buffer );
     }
     free( redir.Buffer );




More information about the wine-cvs mailing list