From e6b21dafc1e29f42ac20248d29a93d37fc69e8a9 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Fri, 30 Apr 2004 14:02:37 +0000 Subject: [PATCH] * fhandler.cc (fhandler_base::open): Fix NT native path evaluation to allow opening serial ports. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/fhandler.cc | 27 ++++++++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index e07a3a7f9..c18f174b4 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2004-04-30 Corinna Vinschen + + * fhandler.cc (fhandler_base::open): Fix NT native path evaluation + to allow opening serial ports. + 2004-04-30 DJ Delorie * init.cc (threadfunc_fe): Hack to make thread stacks always 16 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 ()[1] == '\\') - { - str2buf2uni (upath, wpath, "\\??\\UNC"); - str2buf2uni_cat (upath, get_win32_name () + 1); - } - else - str2buf2uni (upath, wpath, get_win32_name ()); - } - else + + 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, sa.lpSecurityDescriptor, NULL);