From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id C22C63861035; Mon, 7 Sep 2020 20:46:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C22C63861035 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: drop internal O_NOSYMLINK and O_DIROPEN flags X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/master X-Git-Oldrev: 1f8e5847dff27e504949cd21bfeadb987d36ad19 X-Git-Newrev: 8d0ff0768f6c948feb1d9383c494217f886e6b17 Message-Id: <20200907204621.C22C63861035@sourceware.org> Date: Mon, 7 Sep 2020 20:46:21 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2020 20:46:21 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=8d0ff0768f6c948feb1d9383c494217f886e6b17 commit 8d0ff0768f6c948feb1d9383c494217f886e6b17 Author: Corinna Vinschen Date: Mon Sep 7 22:45:38 2020 +0200 Cygwin: drop internal O_NOSYMLINK and O_DIROPEN flags Both flags are outdated and collide with official flags in sys/_default_fcntl.h, which may result in weird misbehaviour of file functions. O_NOSYMLINK is not used anyway. O_DIROPEN is used in fhandler_virtual and derived classes. The collision with O_NOFOLLOW results in spurious EISDIR errors when, e. g., reading files in the registry. fhandler_base::open_fs uses O_DIROPEN in the call to fhandler_base::open, but it's not used in this context further down the road. Drop both flags and create an alternative "diropen" bool flag in fhandler_virtual. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/fhandler.h | 5 +---- winsup/cygwin/fhandler_disk_file.cc | 2 +- winsup/cygwin/fhandler_proc.cc | 4 ++-- winsup/cygwin/fhandler_process.cc | 4 ++-- winsup/cygwin/fhandler_procnet.cc | 2 +- winsup/cygwin/fhandler_procsysvipc.cc | 2 +- winsup/cygwin/fhandler_registry.cc | 8 ++++---- winsup/cygwin/fhandler_virtual.cc | 2 +- winsup/cygwin/release/3.2.0 | 3 +++ 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index b4ba9428a..d7bd0ac06 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -14,10 +14,6 @@ details. */ #include #include -/* fcntl flags used only internaly. */ -#define O_NOSYMLINK 0x080000 -#define O_DIROPEN 0x100000 - /* newlib used to define O_NDELAY differently from O_NONBLOCK. Now it properly defines both to be the same. Unfortunately, we have to behave properly the old version, too, to accommodate older executables. */ @@ -2634,6 +2630,7 @@ class fhandler_virtual : public fhandler_base off_t filesize; off_t position; int fileid; // unique within each class + bool diropen; public: fhandler_virtual (); diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index c37b3c504..885b59161 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -1469,7 +1469,7 @@ fhandler_base::open_fs (int flags, mode_t mode) bool new_file = !exists (); - int res = fhandler_base::open (flags | O_DIROPEN, mode); + int res = fhandler_base::open (flags, mode); if (res) { /* The file info in pc is wrong at this point for newly created files. diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc index 9a20c23d4..196bafd18 100644 --- a/winsup/cygwin/fhandler_proc.cc +++ b/winsup/cygwin/fhandler_proc.cc @@ -315,7 +315,7 @@ fhandler_proc::open (int flags, mode_t mode) } else { - flags |= O_DIROPEN; + diropen = true; goto success; } } @@ -342,7 +342,7 @@ fhandler_proc::open (int flags, mode_t mode) } else { - flags |= O_DIROPEN; + diropen = true; goto success; } } diff --git a/winsup/cygwin/fhandler_process.cc b/winsup/cygwin/fhandler_process.cc index e746b5b5c..a6c358217 100644 --- a/winsup/cygwin/fhandler_process.cc +++ b/winsup/cygwin/fhandler_process.cc @@ -272,7 +272,7 @@ fhandler_process::open (int flags, mode_t mode) } else { - flags |= O_DIROPEN; + diropen = true; goto success; } } @@ -287,7 +287,7 @@ fhandler_process::open (int flags, mode_t mode) } if (entry->fhandler == FH_PROCESSFD) { - flags |= O_DIROPEN; + diropen = true; goto success; } if (flags & O_WRONLY) diff --git a/winsup/cygwin/fhandler_procnet.cc b/winsup/cygwin/fhandler_procnet.cc index 2ea827c48..6df46220c 100644 --- a/winsup/cygwin/fhandler_procnet.cc +++ b/winsup/cygwin/fhandler_procnet.cc @@ -141,7 +141,7 @@ fhandler_procnet::open (int flags, mode_t mode) } else { - flags |= O_DIROPEN; + diropen = true; goto success; } } diff --git a/winsup/cygwin/fhandler_procsysvipc.cc b/winsup/cygwin/fhandler_procsysvipc.cc index 6b4fd8889..516864388 100644 --- a/winsup/cygwin/fhandler_procsysvipc.cc +++ b/winsup/cygwin/fhandler_procsysvipc.cc @@ -161,7 +161,7 @@ fhandler_procsysvipc::open (int flags, mode_t mode) } else { - flags |= O_DIROPEN; + diropen = true; goto success; } } diff --git a/winsup/cygwin/fhandler_registry.cc b/winsup/cygwin/fhandler_registry.cc index 5fc03fedd..5696a4904 100644 --- a/winsup/cygwin/fhandler_registry.cc +++ b/winsup/cygwin/fhandler_registry.cc @@ -784,7 +784,7 @@ fhandler_registry::open (int flags, mode_t mode) } else { - flags |= O_DIROPEN; + diropen = true; /* Marking as nohandle allows to call dup. */ nohandle (true); goto success; @@ -824,7 +824,7 @@ fhandler_registry::open (int flags, mode_t mode) handles. */ if (get_handle () >= HKEY_CLASSES_ROOT) nohandle (true); - flags |= O_DIROPEN; + diropen = true; goto success; } } @@ -872,13 +872,13 @@ fhandler_registry::open (int flags, mode_t mode) } } else - flags |= O_DIROPEN; + diropen = true; set_handle (handle); set_close_on_exec (!!(flags & O_CLOEXEC)); value_name = cwcsdup (dec_file); - if (!(flags & O_DIROPEN) && !fill_filebuf ()) + if (!diropen && !fill_filebuf ()) { RegCloseKey (handle); res = 0; diff --git a/winsup/cygwin/fhandler_virtual.cc b/winsup/cygwin/fhandler_virtual.cc index 6169f3c81..b9ee31f76 100644 --- a/winsup/cygwin/fhandler_virtual.cc +++ b/winsup/cygwin/fhandler_virtual.cc @@ -182,7 +182,7 @@ fhandler_virtual::read (void *ptr, size_t& len) { if (len == 0) return; - if (openflags & O_DIROPEN) + if (diropen) { set_errno (EISDIR); len = (size_t) -1; diff --git a/winsup/cygwin/release/3.2.0 b/winsup/cygwin/release/3.2.0 index 32cc4edec..6fdd1463a 100644 --- a/winsup/cygwin/release/3.2.0 +++ b/winsup/cygwin/release/3.2.0 @@ -30,3 +30,6 @@ Bug Fixes - Fix SEGV in modfl call. Addresses: https://cygwin.com/pipermail/cygwin/2020-August/246056.html + +- Fix a collision of offical and internally used file flags. + Addresses: https://cygwin.com/pipermail/cygwin/2020-September/246174.html