* dtable.cc (handle_to_fn): Use largest match for device. Correctly

(?) deal with remote drive weirdness.
This commit is contained in:
Christopher Faylor 2002-06-02 17:48:05 +00:00
parent f69af9b3d2
commit 37be5a67c9
2 changed files with 37 additions and 8 deletions

View File

@ -1,3 +1,8 @@
2002-06-02 Christopher Faylor <cgf@redhat.com>
* dtable.cc (handle_to_fn): Use largest match for device. Correctly
(?) deal with remote drive weirdness.
2002-06-02 Christopher Faylor <cgf@redhat.com> 2002-06-02 Christopher Faylor <cgf@redhat.com>
* fhandler_disk_file.cc (fhandler_disk_file::fstat_by_name): Check * fhandler_disk_file.cc (fhandler_disk_file::fstat_by_name): Check

View File

@ -756,6 +756,7 @@ handle_to_fn (HANDLE h, char *posix_fn)
char win32_fn[MAX_PATH + 100]; char win32_fn[MAX_PATH + 100];
sys_wcstombs (win32_fn, ntfn->Name.Buffer, ntfn->Name.Length); 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) if (!strncasematch (win32_fn, DEVICE_PREFIX, DEVICE_PREFIX_LEN)
|| !QueryDosDevice (NULL, fnbuf, sizeof (fnbuf))) || !QueryDosDevice (NULL, fnbuf, sizeof (fnbuf)))
return strcpy (posix_fn, win32_fn); 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'); p = strchr (win32_fn + DEVICE_PREFIX_LEN, '\0');
int n = p - win32_fn; 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) for (char *s = fnbuf; *s; s = strchr (s, '\0') + 1)
{ {
char device[MAX_PATH + 10]; char device[MAX_PATH + 10];
@ -774,16 +776,38 @@ handle_to_fn (HANDLE h, char *posix_fn)
continue; continue;
if (!QueryDosDevice (s, device, sizeof (device) - 1)) if (!QueryDosDevice (s, device, sizeof (device) - 1))
continue; continue;
if (!strncasematch (device, win32_fn, n) || char *q = strrchr (device, ';');
(device[n] != '\0' && (device[n] != '\\' || device[n + 1] != ';'))) 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; continue;
n = strlen (s); if (!strncasematch (device, win32_fn, devlen) ||
w32 = p - (n + 1); (win32_fn[devlen] != '\0' && win32_fn[devlen] != '\\'))
memcpy (w32, s, n); continue;
p[-1] = '\\'; maxmatchlen = devlen;
break; 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); cygwin_conv_to_full_posix_path (w32, posix_fn);
return posix_fn; return posix_fn;
} }