From: Paul Eggert Date: Fri, 30 May 2025 07:41:32 +0000 (-0700) Subject: Document O_CREAT|O_DIRECTORY bugs with Linux <6.4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6c13a0099a8384c6fea9c358bdc40552a9c5b02;p=thirdparty%2Fgnulib.git Document O_CREAT|O_DIRECTORY bugs with Linux <6.4 --- diff --git a/doc/posix-functions/open.texi b/doc/posix-functions/open.texi index 26bb757646..723a15a828 100644 --- a/doc/posix-functions/open.texi +++ b/doc/posix-functions/open.texi @@ -55,6 +55,14 @@ 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 +When the file does not exist, POSIX says +the behavior of @code{O_CREAT | O_DIRECTORY} is unspecified. +Most platforms fail with @code{EINVAL} in this case. +However, in Linux kernels 6.3 and earlier, this function +creates a regular file and then either returns successfully +(Linux kernel 5.6 and earlier) or fails with @code{ENOTDIR} +(Linux kernels 5.7--6.3). +@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 8e39853629..34771eb990 100644 --- a/doc/posix-functions/openat.texi +++ b/doc/posix-functions/openat.texi @@ -43,6 +43,14 @@ 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 +When the file does not exist, POSIX says +the behavior of @code{O_CREAT | O_DIRECTORY} is unspecified. +Most platforms fail with @code{EINVAL} in this case. +However, in Linux kernels 6.3 and earlier, this function +creates a regular file and then either returns successfully +(Linux kernel 5.6 and earlier) or fails with @code{ENOTDIR} +(Linux kernels 5.7--6.3). +@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: