[PATCH v9 1/2] ntdll: Strip trailing slashes after looking up unix name.

Gabriel Ivăncescu gabrielopcode at gmail.com
Thu Apr 29 10:39:26 CDT 2021


As they are useless anyway, and have inconsistencies, plus not useful
to new code that assumes there's not any on the unix side. See:
https://www.winehq.org/pipermail/wine-devel/2021-April/185850.html

Note that the root / is not stripped, which is still correct.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---

winepath still reports multiple slashes, but I checked the trace from this,
it doesn't return trailing slash anymore (except for / root component),
so that's an unrelated problem in winepath, I think.

 dlls/ntdll/unix/file.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c
index 2f18325..ec0beaa 100644
--- a/dlls/ntdll/unix/file.c
+++ b/dlls/ntdll/unix/file.c
@@ -3155,6 +3155,8 @@ static NTSTATUS lookup_unix_name( const WCHAR *name, int name_len, char **buffer
         char *p;
         unix_name[pos + 1 + ret] = 0;
         for (p = unix_name + pos ; *p; p++) if (*p == '\\') *p = '/';
+        while (p - 1 > unix_name && p[-1] == '/') p--;
+        *p = 0;
         if (!stat( unix_name, &st ))
         {
             if (disposition == FILE_CREATE) return STATUS_OBJECT_NAME_COLLISION;
@@ -3221,6 +3223,12 @@ static NTSTATUS lookup_unix_name( const WCHAR *name, int name_len, char **buffer
         name = next;
     }
 
+    if (status == STATUS_SUCCESS || status == STATUS_NO_SUCH_FILE)
+    {
+        char *p = unix_name + strlen( unix_name );
+        while (p - 1 > unix_name && p[-1] == '/') p--;
+        *p = 0;
+    }
     return status;
 }
 
-- 
2.30.0




More information about the wine-devel mailing list