public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: drop internal O_NOSYMLINK and O_DIROPEN flags Date: Mon, 7 Sep 2020 20:46:21 +0000 (GMT) [thread overview] Message-ID: <20200907204621.C22C63861035@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=8d0ff0768f6c948feb1d9383c494217f886e6b17 commit 8d0ff0768f6c948feb1d9383c494217f886e6b17 Author: Corinna Vinschen <corinna@vinschen.de> 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 <corinna@vinschen.de> 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 <cygwin/_ucred.h> #include <sys/un.h> -/* 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
reply other threads:[~2020-09-07 20:46 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200907204621.C22C63861035@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).