]> Savannah Git Hosting - gnulib.git/commitdiff
savewd: remove O_SEARCH optimization
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 20 Nov 2024 02:29:57 +0000 (18:29 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 20 Nov 2024 02:33:19 +0000 (18:33 -0800)
* lib/savewd.c (savewd_save): Remove recently-added optimization
for platforms with O_SEARCH, as it does not work on macOS 12.6
due to what seems to be a bug there.

ChangeLog
doc/posix-functions/open.texi
doc/posix-functions/openat.texi
lib/savewd.c

index 4a6ace7d16b6a76369649abd5e58e6aeee48540b..8cfb8d7102c416e108e28961c83ffefda0d2bebd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2024-11-19  Paul Eggert  <eggert@cs.ucla.edu>
 
+       savewd: remove O_SEARCH optimization
+       * lib/savewd.c (savewd_save): Remove recently-added optimization
+       for platforms with O_SEARCH, as it does not work on macOS 12.6
+       due to what seems to be a bug there.
+
        strerror, vasnprintf: pacify clang 14 on macOS
        * lib/strerror.c, lib/vasnprintf.c: Pacify clang 14 on macOS 12.6.
 
index 67b084525c84506ec28e701259d410a4430baba3..dccadae8c9e842f52cf546935093a2b6a0c4366e 100644 (file)
@@ -45,6 +45,13 @@ Portability problems not fixed by Gnulib:
 The Gnulib replacement for @code{O_CLOEXEC} is not atomic, and so is
 not safe in the presence of multiple threads or signal handlers.
 @item
+The Gnulib replacement for @code{O_SEARCH} may require read access
+instead of search/execute access.
+@item
+On some platforms, @code{O_SEARCH} may reject directories
+where you have search access even though @code{O_SEARCH} is not replaced:
+macOS 12.6.
+@item
 @code{open ("symlink", O_CREAT ...)} fails when the argument points to a
 nonexistent file in an existing directory on some platforms:
 @c https://dev.haiku-os.org/ticket/18355
index 25641ffd5a8309b65d41d0b5198f12223314a5b1..c5ac2ca78421fbd1d63dc6b63e4e4641c2e8f3ef 100644 (file)
@@ -33,6 +33,13 @@ Portability problems not fixed by Gnulib:
 The Gnulib replacement for @code{O_CLOEXEC} is not atomic, and so is
 not safe in the presence of multiple threads or signal handlers.
 @item
+The Gnulib replacement for @code{O_SEARCH} may require read access
+instead of search/execute access.
+@item
+On some platforms, @code{O_SEARCH} may reject directories
+where you have search access even though @code{O_SEARCH} is not replaced:
+macOS 12.6.
+@item
 @code{openat (fd, "symlink", O_NOFOLLOW ...)} fails with @code{errno}
 set to @code{EMLINK} instead of the POSIX-required @code{ELOOP} on
 some platforms:
index debf9e9041310c688cd4a0f25af7997a72d2aafc..3a0361425a9f3af47037325bd053b3f76608798c 100644 (file)
@@ -61,9 +61,12 @@ savewd_save (struct savewd *wd)
             wd->val.fd = fd;
             break;
           }
-# if O_SEARCH != O_RDONLY || (defined _WIN32 && !defined __CYGWIN__)
-        /* There is no point to forking if O_SEARCH conforms to POSIX,
-           or on native MS-Windows which lacks 'fork'.  */
+
+        /* There is no point to forking on native MS-Windows which lacks 'fork'.
+           Although there is also no point on systems that support O_SEARCH,
+           macOS 12.6 APFS open (".", O_SEARCH) incorrectly fails if "." is
+           mode 311, so do not attempt to optimize for O_SEARCH != O_RDONLY.  */
+# if defined _WIN32 && !defined __CYGWIN__
         bool try_fork = false;
 # else
         bool try_fork = errno == EACCES || errno == ESTALE;