diff options
author | Christopher Faylor <me@cgf.cx> | 2002-06-02 17:48:05 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2002-06-02 17:48:05 +0000 |
commit | 37be5a67c94249489b1310a307b7d81592999c80 (patch) | |
tree | a2e242947e93305ee9a9bf2735bacefa2d6db946 /winsup/cygwin/dtable.cc | |
parent | f69af9b3d2352f2343234cc83c93df7375086679 (diff) | |
download | cygnal-37be5a67c94249489b1310a307b7d81592999c80.tar.gz cygnal-37be5a67c94249489b1310a307b7d81592999c80.tar.bz2 cygnal-37be5a67c94249489b1310a307b7d81592999c80.zip |
* dtable.cc (handle_to_fn): Use largest match for device. Correctly
(?) deal with remote drive weirdness.
Diffstat (limited to 'winsup/cygwin/dtable.cc')
-rw-r--r-- | winsup/cygwin/dtable.cc | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index 51457fd0c..06f48c49f 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -756,6 +756,7 @@ handle_to_fn (HANDLE h, char *posix_fn) char win32_fn[MAX_PATH + 100]; sys_wcstombs (win32_fn, ntfn->Name.Buffer, ntfn->Name.Length); + debug_printf ("nt name '%s'", win32_fn); if (!strncasematch (win32_fn, DEVICE_PREFIX, DEVICE_PREFIX_LEN) || !QueryDosDevice (NULL, fnbuf, sizeof (fnbuf))) return strcpy (posix_fn, win32_fn); @@ -765,7 +766,8 @@ handle_to_fn (HANDLE h, char *posix_fn) p = strchr (win32_fn + DEVICE_PREFIX_LEN, '\0'); int n = p - win32_fn; - char *w32 = win32_fn; + int maxmatchlen = 0; + char *maxmatchdos = NULL; for (char *s = fnbuf; *s; s = strchr (s, '\0') + 1) { char device[MAX_PATH + 10]; @@ -774,16 +776,38 @@ handle_to_fn (HANDLE h, char *posix_fn) continue; if (!QueryDosDevice (s, device, sizeof (device) - 1)) continue; - if (!strncasematch (device, win32_fn, n) || - (device[n] != '\0' && (device[n] != '\\' || device[n + 1] != ';'))) + char *q = strrchr (device, ';'); + if (q) + { + char *r = strchr (q, '\\'); + if (r) + strcpy (q, r + 1); + } + int devlen = strlen (device); + if (device[devlen - 1] == '\\') + device[--devlen] = '\0'; + if (devlen < maxmatchlen) + continue; + if (!strncasematch (device, win32_fn, devlen) || + (win32_fn[devlen] != '\0' && win32_fn[devlen] != '\\')) continue; - n = strlen (s); - w32 = p - (n + 1); - memcpy (w32, s, n); - p[-1] = '\\'; - break; + maxmatchlen = devlen; + maxmatchdos = s; + debug_printf ("current match '%s'", device); + } + + char *w32 = win32_fn; + if (maxmatchlen) + { + n = strlen (maxmatchdos); + if (maxmatchdos[n - 1] == '\\') + n--; + w32 += maxmatchlen - n; + memcpy (w32, maxmatchdos, n); + w32[n] = '\\'; } + debug_printf ("derived path '%s'", w32); cygwin_conv_to_full_posix_path (w32, posix_fn); return posix_fn; } |