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
path: root/winsup
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2004-04-30 21:36:36 +0400
committerCorinna Vinschen <corinna@vinschen.de>2004-04-30 21:36:36 +0400
commit43b2d5bace17cc901af345c530ee617f530500f1 (patch)
treea4c58d66a6c55bcfc55c51c46667382c444505a3 /winsup
parented8dd3c858ab4fa231d168e21909a8240e56e9c0 (diff)
* fhandler.cc (fhandler_base::open): Call path_conv::get_nt_native_path
for evaluating NT path. * path.cc (normalize_posix_path): Remove trailing dots and spaces. (path_conv::get_nt_native_path): New function. * path.h (class path_conv): Declare get_nt_native_path method.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog8
-rw-r--r--winsup/cygwin/fhandler.cc22
-rw-r--r--winsup/cygwin/path.cc28
-rw-r--r--winsup/cygwin/path.h2
4 files changed, 40 insertions, 20 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index c18f174b4..e57e52103 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,13 @@
2004-04-30 Corinna Vinschen <corinna@vinschen.de>
+ * fhandler.cc (fhandler_base::open): Call path_conv::get_nt_native_path
+ for evaluating NT path.
+ * path.cc (normalize_posix_path): Remove trailing dots and spaces.
+ (path_conv::get_nt_native_path): New function.
+ * path.h (class path_conv): Declare get_nt_native_path method.
+
+2004-04-30 Corinna Vinschen <corinna@vinschen.de>
+
* fhandler.cc (fhandler_base::open): Fix NT native path evaluation
to allow opening serial ports.
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index 2dc3eece0..ae9bd8a04 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -555,26 +555,8 @@ fhandler_base::open (int flags, mode_t mode)
goto done;
}
- if (get_win32_name ()[0] != '\\') /* X:\... or NUL, etc. */
- {
- str2buf2uni (upath, wpath, "\\??\\");
- str2buf2uni_cat (upath, get_win32_name ());
- }
- else if (get_win32_name ()[1] != '\\') /* \Device\... */
- str2buf2uni (upath, wpath, get_win32_name ());
- else if (get_win32_name ()[2] != '.'
- || get_win32_name ()[3] != '\\') /* \\server\share\... */
- {
- str2buf2uni (upath, wpath, "\\??\\UNC\\");
- str2buf2uni_cat (upath, get_win32_name () + 2);
- }
- else /* \\.\device */
- {
- str2buf2uni (upath, wpath, "\\??\\");
- str2buf2uni_cat (upath, get_win32_name () + 4);
- }
-
- InitializeObjectAttributes (&attr, &upath, OBJ_CASE_INSENSITIVE | OBJ_INHERIT,
+ InitializeObjectAttributes (&attr, pc.get_nt_native_path (upath, wpath),
+ OBJ_CASE_INSENSITIVE | OBJ_INHERIT,
sa.lpSecurityDescriptor, NULL);
switch (query_open ())
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 341f8268c..59e454bfc 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -286,6 +286,10 @@ normalize_posix_path (const char *src, char *dst, char **tail)
}
done:
+ /* Remove trailing dots and spaces which are ignored by Win32 functions but
+ not by native NT functions. */
+ while (dst[-1] == '.' || dst[-1] == ' ')
+ --dst;
*dst = '\0';
*tail = dst;
@@ -458,6 +462,30 @@ path_conv::set_normalized_path (const char *path_copy)
memcpy (normalized_path, path_copy, n);
}
+PUNICODE_STRING
+path_conv::get_nt_native_path (UNICODE_STRING &upath, WCHAR *wpath)
+{
+ if (path[0] != '\\') /* X:\... or NUL, etc. */
+ {
+ str2buf2uni (upath, wpath, "\\??\\");
+ str2buf2uni_cat (upath, path);
+ }
+ else if (path[1] != '\\') /* \Device\... */
+ str2buf2uni (upath, wpath, path);
+ else if (path[2] != '.'
+ || path[3] != '\\') /* \\server\share\... */
+ {
+ str2buf2uni (upath, wpath, "\\??\\UNC\\");
+ str2buf2uni_cat (upath, path + 2);
+ }
+ else /* \\.\device */
+ {
+ str2buf2uni (upath, wpath, "\\??\\");
+ str2buf2uni_cat (upath, path + 4);
+ }
+ return &upath;
+}
+
/* Convert an arbitrary path SRC to a pure Win32 path, suitable for
passing to Win32 API routines.
diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h
index 150799d59..c04366014 100644
--- a/winsup/cygwin/path.h
+++ b/winsup/cygwin/path.h
@@ -12,6 +12,7 @@ details. */
#include <sys/ioctl.h>
#include <fcntl.h>
+#include <ntdef.h>
enum executable_states
{
@@ -191,6 +192,7 @@ class path_conv
~path_conv ();
inline char *get_win32 () { return path; }
+ PUNICODE_STRING get_nt_native_path (UNICODE_STRING &upath, WCHAR *wpath);
operator char *() {return path;}
operator const char *() {return path;}
operator DWORD &() {return fileattr;}