* lib/fcntl.in.h (O_SEARCH): Redefine to O_RDONLY on musl,
which mistakenly defines it to be O_PATH on GNU/Linux.
Problem reported by Lasse Collin in:
https://bugs.gnu.org/75405
---
 ChangeLog      | 8 ++++++++
 lib/fcntl.in.h | 6 +++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 2acacb69a2..39e35c04a7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2025-01-08  Paul Eggert  <egg...@cs.ucla.edu>
+
+       fcntl-h: port better to musl on GNU/Linux
+       * lib/fcntl.in.h (O_SEARCH): Redefine to O_RDONLY on musl,
+       which mistakenly defines it to be O_PATH on GNU/Linux.
+       Problem reported by Lasse Collin in:
+       https://bugs.gnu.org/75405
+
 2025-01-06  Collin Funk  <collin.fu...@gmail.com>
 
        servent tests: Fix mistake in previous commit.
diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h
index 5f06c4fe10..ac61c0865a 100644
--- a/lib/fcntl.in.h
+++ b/lib/fcntl.in.h
@@ -369,8 +369,12 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
 # define O_RSYNC 0
 #endif
 
+#if defined O_SEARCH && defined O_PATH && O_SEARCH == O_PATH
+# undef O_SEARCH /* musl mistakenly #defines O_SEARCH to O_PATH.  */
+#endif
+
 #ifndef O_SEARCH
-# define O_SEARCH O_RDONLY /* This is often close enough in older systems.  */
+# define O_SEARCH O_RDONLY /* Often close enough in non-POSIX systems.  */
 #endif
 
 #ifndef O_SYNC
-- 
2.47.1


Reply via email to