Bruno Haible <[email protected]> writes: > [CCing bug-gnulib.] > > Collin Funk wrote: >> > -truncate: cannot open '.' for writing: Is a directory >> > +truncate: cannot open '.' for writing: Invalid argument >> ... >> This is almost certainly worth documenting in the Gnulib manual, and >> perhaps replacing: > > Worth documenting: Yes.
I pushed the attached Gnulib patch. The openat function behaves the same way, unsurprisingly. But I figured I should mention that I tested it and did not assume the behavior. > Worth overriding open(): Probably not. There are many situations where > systems, especially old ones, provide errno values that are not those > that POSIX wants to see. Typically the applications can work with either > errno value, the POSIX one and the platform-specific one, without needing > source code changes. Yep, I agree after thinking about it more. In this case the incorrect value just causes a less helpful error message. It isn't used to take a different code path which would be incorrect, for example. Collin
>From b75134c814c38876f04029ffc3fae4e90035dc34 Mon Sep 17 00:00:00 2001 Message-ID: <b75134c814c38876f04029ffc3fae4e90035dc34.1774408328.git.collin.fu...@gmail.com> From: Collin Funk <[email protected]> Date: Tue, 24 Mar 2026 20:11:36 -0700 Subject: [PATCH] doc: Mention a Solaris 11.4 bug. * doc/posix-functions/open.texi: Mention that Solaris 11.4 sets errno to EINVAL instead of EISDIR when open is called on a directory with O_CREAT. * doc/posix-functions/openat.texi: Likewise. --- ChangeLog | 8 ++++++++ doc/posix-functions/open.texi | 5 +++++ doc/posix-functions/openat.texi | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/ChangeLog b/ChangeLog index 0487b1fdb0..fb757efcd0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2026-03-24 Collin Funk <[email protected]> + + doc: Mention a Solaris 11.4 bug. + * doc/posix-functions/open.texi: Mention that Solaris 11.4 sets errno to + EINVAL instead of EISDIR when open is called on a directory with + O_CREAT. + * doc/posix-functions/openat.texi: Likewise. + 2026-03-20 Collin Funk <[email protected]> vasprintf-posix, vasprintf, stdio-windows: Prefer AC_CHECK_FUNCS_ONCE. diff --git a/doc/posix-functions/open.texi b/doc/posix-functions/open.texi index a61f3e76da..ecdf1bdaa2 100644 --- a/doc/posix-functions/open.texi +++ b/doc/posix-functions/open.texi @@ -78,6 +78,11 @@ @node open platforms: NetBSD 10.0. @item +@code{open ("directory", O_CREAT ...)} fails with @code{errno} set to +@code{EINVAL} instead of the POSIX-required @code{EISDIR} on some +platforms: +Solaris 11.4. +@item @code{open ("fifo", O_DIRECTORY ...)} does not fail on some platforms: @c https://dev.haiku-os.org/ticket/19879 Haiku. diff --git a/doc/posix-functions/openat.texi b/doc/posix-functions/openat.texi index 34771eb990..1e5fc7e722 100644 --- a/doc/posix-functions/openat.texi +++ b/doc/posix-functions/openat.texi @@ -60,4 +60,9 @@ @node openat set to @code{EFTYPE} instead of the POSIX-required @code{ELOOP} on some platforms: NetBSD 6.1. +@item +@code{openat (fd, "directory", O_CREAT ...)} fails with @code{errno} set +to @code{EINVAL} instead of the POSIX-required @code{EISDIR} on some +platforms: +Solaris 11.4. @end itemize -- 2.53.0
