[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] savewd: remove O_SEARCH optimization
From: |
Paul Eggert |
Subject: |
[PATCH] savewd: remove O_SEARCH optimization |
Date: |
Tue, 19 Nov 2024 18:34:46 -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 | 5 +++++
doc/posix-functions/open.texi | 7 +++++++
doc/posix-functions/openat.texi | 7 +++++++
lib/savewd.c | 9 ++++++---
4 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 4a6ace7d16..8cfb8d7102 100644
--- 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.
diff --git a/doc/posix-functions/open.texi b/doc/posix-functions/open.texi
index 67b084525c..dccadae8c9 100644
--- a/doc/posix-functions/open.texi
+++ b/doc/posix-functions/open.texi
@@ -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
diff --git a/doc/posix-functions/openat.texi b/doc/posix-functions/openat.texi
index 25641ffd5a..c5ac2ca784 100644
--- a/doc/posix-functions/openat.texi
+++ b/doc/posix-functions/openat.texi
@@ -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:
diff --git a/lib/savewd.c b/lib/savewd.c
index debf9e9041..3a0361425a 100644
--- a/lib/savewd.c
+++ b/lib/savewd.c
@@ -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;
--
2.43.0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] savewd: remove O_SEARCH optimization,
Paul Eggert <=