[2/3] ntdll: don't treat DOS paths starting with / as Unix paths

Vincent Povirk madewokherd+8cd9 at gmail.com
Sun Apr 5 14:29:22 CDT 2009


This patchset should fix bug 15883.

Vincent Povirk
-------------- next part --------------
From 8155cb50cf406ebc38e92a7f352c83bb830703b6 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <madewokherd at gmail.com>
Date: Sun, 5 Apr 2009 13:52:54 -0500
Subject: [PATCH] ntdll: don't treat DOS paths starting with / as Unix paths

---
 dlls/ntdll/path.c |  112 -----------------------------------------------------
 1 files changed, 0 insertions(+), 112 deletions(-)

diff --git a/dlls/ntdll/path.c b/dlls/ntdll/path.c
index 66d7b7a..79683cf 100644
--- a/dlls/ntdll/path.c
+++ b/dlls/ntdll/path.c
@@ -141,102 +141,6 @@ static NTSTATUS find_drive_rootA( LPCSTR *ppath, unsigned int len, int *drive_re
 
 
 /***********************************************************************
- *           remove_last_componentW
- *
- * Remove the last component of the path. Helper for find_drive_rootW.
- */
-static inline int remove_last_componentW( const WCHAR *path, int len )
-{
-    int level = 0;
-
-    while (level < 1)
-    {
-        /* find start of the last path component */
-        int prev = len;
-        if (prev <= 1) break;  /* reached root */
-        while (prev > 1 && !IS_SEPARATOR(path[prev - 1])) prev--;
-        /* does removing it take us up a level? */
-        if (len - prev != 1 || path[prev] != '.')  /* not '.' */
-        {
-            if (len - prev == 2 && path[prev] == '.' && path[prev+1] == '.')  /* is it '..'? */
-                level--;
-            else
-                level++;
-        }
-        /* strip off trailing slashes */
-        while (prev > 1 && IS_SEPARATOR(path[prev - 1])) prev--;
-        len = prev;
-    }
-    return len;
-}
-
-
-/***********************************************************************
- *           find_drive_rootW
- *
- * Find a drive for which the root matches the beginning of the given path.
- * This can be used to translate a Unix path into a drive + DOS path.
- * Return value is the drive, or -1 on error. On success, ppath is modified
- * to point to the beginning of the DOS path.
- */
-static int find_drive_rootW( LPCWSTR *ppath )
-{
-    /* Starting with the full path, check if the device and inode match any of
-     * the wine 'drives'. If not then remove the last path component and try
-     * again. If the last component was a '..' then skip a normal component
-     * since it's a directory that's ascended back out of.
-     */
-    int drive, lenA, lenW;
-    char *buffer, *p;
-    const WCHAR *path = *ppath;
-    struct stat st;
-    struct drive_info info[MAX_DOS_DRIVES];
-
-    /* get device and inode of all drives */
-    if (!DIR_get_drives_info( info )) return -1;
-
-    /* strip off trailing slashes */
-    lenW = strlenW(path);
-    while (lenW > 1 && IS_SEPARATOR(path[lenW - 1])) lenW--;
-
-    /* convert path to Unix encoding */
-    lenA = ntdll_wcstoumbs( 0, path, lenW, NULL, 0, NULL, NULL );
-    if (!(buffer = RtlAllocateHeap( GetProcessHeap(), 0, lenA + 1 ))) return -1;
-    lenA = ntdll_wcstoumbs( 0, path, lenW, buffer, lenA, NULL, NULL );
-    buffer[lenA] = 0;
-    for (p = buffer; *p; p++) if (*p == '\\') *p = '/';
-
-    for (;;)
-    {
-        if (!stat( buffer, &st ) && S_ISDIR( st.st_mode ))
-        {
-            /* Find the drive */
-            for (drive = 0; drive < MAX_DOS_DRIVES; drive++)
-            {
-                if ((info[drive].dev == st.st_dev) && (info[drive].ino == st.st_ino))
-                {
-                    if (lenW == 1) lenW = 0;  /* preserve root slash in returned path */
-                    TRACE( "%s -> drive %c:, root=%s, name=%s\n",
-                           debugstr_w(path), 'A' + drive, debugstr_a(buffer), debugstr_w(path + lenW));
-                    *ppath += lenW;
-                    RtlFreeHeap( GetProcessHeap(), 0, buffer );
-                    return drive;
-                }
-            }
-        }
-        if (lenW <= 1) break;  /* reached root */
-        lenW = remove_last_componentW( path, lenW );
-
-        /* we only need the new length, buffer already contains the converted string */
-        lenA = ntdll_wcstoumbs( 0, path, lenW, NULL, 0, NULL, NULL );
-        buffer[lenA] = 0;
-    }
-    RtlFreeHeap( GetProcessHeap(), 0, buffer );
-    return -1;
-}
-
-
-/***********************************************************************
  *             RtlDetermineDosPathNameType_U   (NTDLL.@)
  */
 DOS_PATHNAME_TYPE WINAPI RtlDetermineDosPathNameType_U( PCWSTR path )
@@ -684,22 +588,6 @@ static ULONG get_full_path_helper(LPCWSTR name, LPWSTR buffer, ULONG size)
         break;
 
     case ABSOLUTE_PATH:         /* \xxx    */
-        if (name[0] == '/')  /* may be a Unix path */
-        {
-            const WCHAR *ptr = name;
-            int drive = find_drive_rootW( &ptr );
-            if (drive != -1)
-            {
-                reqsize = 3 * sizeof(WCHAR);
-                tmp[0] = 'A' + drive;
-                tmp[1] = ':';
-                tmp[2] = '\\';
-                ins_str = tmp;
-                mark = 3;
-                dep = ptr - name;
-                break;
-            }
-        }
         if (cd->Buffer[1] == ':')
         {
             reqsize = 2 * sizeof(WCHAR);
-- 
1.5.4.3


More information about the wine-patches mailing list