diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 5cbb19c8c..1812cd2e7 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. */ @@ -2640,6 +2636,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