From 1173990cc1511ffccde9b291020a8f3f694910f4 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 28 Aug 2024 11:03:34 +0200 Subject: [PATCH] doc: Add more details about O_EXEC and O_SEARCH. * doc/posix-headers/fcntl.texi: Add platforms list and revisit note about O_EXEC and O_SEARCH. --- ChangeLog | 6 ++++++ doc/posix-headers/fcntl.texi | 29 ++++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index d7124060b8..8a7f812b67 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2024-08-28 Bruno Haible + + doc: Add more details about O_EXEC and O_SEARCH. + * doc/posix-headers/fcntl.texi: Add platforms list and revisit note + about O_EXEC and O_SEARCH. + 2024-08-27 Bruno Haible mcel: Fix compilation error with MSVC. diff --git a/doc/posix-headers/fcntl.texi b/doc/posix-headers/fcntl.texi index c7ffba8cf4..b190761e6a 100644 --- a/doc/posix-headers/fcntl.texi +++ b/doc/posix-headers/fcntl.texi @@ -36,11 +36,30 @@ which is generally safe. non-zero value; otherwise, the gnulib replacement is 0. @item -@samp{O_EXEC} and @samp{O_SEARCH} are not defined on some platforms. -Gnulib defines these macros to @samp{O_RDONLY}, which is typically 0. -The @samp{O_PATH} macro of GNU/Linux is not a suitable substitute, as -fchmod fails with @samp{errno==EBADF} when invoked on a file -descriptor that was opened with @samp{O_PATH}. +@samp{O_EXEC} is not defined on some platforms: +glibc 2.40, macOS 12, FreeBSD 7.4, NetBSD 9.4, OpenBSD 7.5, HP-UX 11, Solaris 10, Cygwin 1.5.x, mingw, MSVC 14, Android. +When not otherwise defined, +Gnulib defines this macro to @samp{O_RDONLY}, which is typically 0. + +Note: @samp{O_EXEC} is not suitable for opening a file descriptor +that you want to use with @code{fchmod} later, because +musl libc defines @samp{O_EXEC} to @code{O_PATH} and +@c https://lists.gnu.org/archive/html/bug-gnulib/2012-11/msg00029.html +Linux @code{fchmod} fails with error @code{EBADF} when given such a file +descriptor. + +@item +@samp{O_SEARCH} is not defined on some platforms: +glibc 2.40, macOS 12, FreeBSD 12.4, NetBSD 6.1, OpenBSD 7.5, AIX 6.1, HP-UX 11, Solaris 10, Cygwin 1.5.x, mingw, MSVC 14, Android. +When not otherwise defined, +Gnulib defines this macro to @samp{O_RDONLY}, which is typically 0. + +Note: @samp{O_SEARCH} is not suitable for opening a file descriptor +that you want to use with @code{fchmod} later, because +musl libc defines @samp{O_EXEC} to @code{O_PATH} and +@c https://lists.gnu.org/archive/html/bug-gnulib/2012-11/msg00029.html +Linux @code{fchmod} fails with error @code{EBADF} when given such a file +descriptor. @item @samp{O_ACCMODE} is not defined on some platforms: -- 2.39.5