Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2002-06-02 21:48:05 +0400
committerChristopher Faylor <me@cgf.cx>2002-06-02 21:48:05 +0400
commit37be5a67c94249489b1310a307b7d81592999c80 (patch)
treea2e242947e93305ee9a9bf2735bacefa2d6db946
parentf69af9b3d2352f2343234cc83c93df7375086679 (diff)
* dtable.cc (handle_to_fn): Use largest match for device. Correctly
(?) deal with remote drive weirdness.
-rw-r--r--winsup/cygwin/ChangeLog5
-rw-r--r--winsup/cygwin/dtable.cc40
2 files changed, 37 insertions, 8 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 2c3f10d10..d0fad580f 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,10 @@
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>
+
* fhandler_disk_file.cc (fhandler_disk_file::fstat_by_name): Check
specifically for non-existent file, first.
(fhandler_disk_file::fstat): Perform fd open on files with funny
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;
}