summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fhandler.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/fhandler.cc')
-rw-r--r--winsup/cygwin/fhandler.cc25
1 files changed, 15 insertions, 10 deletions
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index 445146aa9..2dc3eece0 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -554,21 +554,26 @@ fhandler_base::open (int flags, mode_t mode)
set_errno (ENOENT);
goto done;
}
- if (get_win32_name ()[0] == '\\')
+
+ if (get_win32_name ()[0] != '\\') /* X:\... or NUL, etc. */
{
- if (get_win32_name ()[1] == '\\')
- {
- str2buf2uni (upath, wpath, "\\??\\UNC");
- str2buf2uni_cat (upath, get_win32_name () + 1);
- }
- else
- str2buf2uni (upath, wpath, get_win32_name ());
+ str2buf2uni (upath, wpath, "\\??\\");
+ str2buf2uni_cat (upath, get_win32_name ());
}
- else
+ 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 ());
+ str2buf2uni_cat (upath, get_win32_name () + 4);
}
+
InitializeObjectAttributes (&attr, &upath, OBJ_CASE_INSENSITIVE | OBJ_INHERIT,
sa.lpSecurityDescriptor, NULL);