This is the mail archive of the
cygwin-patches@cygwin.com
mailing list for the Cygwin project.
Re: Patch to allow trailing dots on managed mounts
- From: "Pierre A. Humblet" <pierre at phumblet dot no-ip dot org>
- To: mark dot paulus at mci dot com, cygwin-patches at cygwin dot com
- Date: Thu, 16 Dec 2004 09:55:48 -0500
- Subject: Re: Patch to allow trailing dots on managed mounts
- Reply-to: pierre dot humblet at ieee dot org
Here is an untested patch.
I hope Mark can test it (on managed and unmanaged mounts,
including basenames consisting entirely of dots and spaces)
and possibly make adjustments, without having to file the
paperwork.
Pierre
* path.cc (path_conv::check): Do not strip trailing dots and spaces.
* fhandler.cc (fhandler_base::open): Strip trailing dots and spaces.
Index: path.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/path.cc,v
retrieving revision 1.326
diff -u -p -r1.326 path.cc
--- path.cc 3 Dec 2004 02:00:37 -0000 1.326
+++ path.cc 16 Dec 2004 14:42:58 -0000
@@ -546,25 +546,12 @@ path_conv::check (const char *src, unsig
/* Detect if the user was looking for a directory. We have to strip the
trailing slash initially while trying to add extensions but take it
into account during processing */
- if (tail > path_copy + 1)
+ if (tail > path_copy + 1 && isslash (tail[-1]))
{
- if (isslash (tail[-1]))
- {
- need_directory = 1;
- tail--;
- }
- /* Remove trailing dots and spaces which are ignored by Win32 functions but
- not by native NT functions. */
- while (tail[-1] == '.' || tail[-1] == ' ')
- tail--;
- if (tail > path_copy + 1 && isslash (tail[-1]))
- {
- error = ENOENT;
- return;
- }
+ need_directory = 1;
+ *--tail = '\0';
}
path_end = tail;
- *tail = '\0';
/* Scan path_copy from right to left looking either for a symlink
or an actual existing file. If an existing file is found, just
Index: fhandler.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler.cc,v
retrieving revision 1.207
diff -u -p -r1.207 fhandler.cc
--- fhandler.cc 20 Nov 2004 23:42:36 -0000 1.207
+++ fhandler.cc 16 Dec 2004 14:43:51 -0000
@@ -537,6 +537,17 @@ fhandler_base::open (int flags, mode_t m
UNICODE_STRING upath = {0, sizeof (wpath), wpath};
pc.get_nt_native_path (upath);
+ /* Remove trailing dots and spaces which are ignored by Win32 functions but
+ not by native NT functions. */
+ WCHAR *tail = upath.Buffer + upath.Length;
+ while (tail[-1] == '.' || tail[-1] == ' ')
+ tail--;
+ if (tail[-1] == '\\')
+ {
+ set_errno (ENOENT);
+ return 0;
+ }
+
if (RtlIsDosDeviceName_U (upath.Buffer))
return fhandler_base::open_9x (flags, mode);