diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2020-09-07 22:45:38 +0200 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2020-09-07 22:45:56 +0200 |
commit | 8d0ff0768f6c948feb1d9383c494217f886e6b17 (patch) | |
tree | ff90a7662c4a4a148c6de4e22862e231ff81f1e2 | |
parent | 1f8e5847dff27e504949cd21bfeadb987d36ad19 (diff) | |
download | cygnal-8d0ff0768f6c948feb1d9383c494217f886e6b17.tar.gz cygnal-8d0ff0768f6c948feb1d9383c494217f886e6b17.tar.bz2 cygnal-8d0ff0768f6c948feb1d9383c494217f886e6b17.zip |
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>
-rw-r--r-- | winsup/cygwin/fhandler.h | 5 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_disk_file.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_proc.cc | 4 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_process.cc | 4 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_procnet.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_procsysvipc.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_registry.cc | 8 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_virtual.cc | 2 | ||||
-rw-r--r-- | 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 |