From: Bruno Haible Date: Mon, 12 Sep 2022 08:49:25 +0000 (+0200) Subject: supersede: Avoid a failure when writing to /dev/null in Solaris zones. X-Git-Tag: v1.0~2033 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=ff7a4ffc9e87339baa6e02ad10563137cd381474;p=gnulib.git supersede: Avoid a failure when writing to /dev/null in Solaris zones. * lib/supersede.c (open_supersede): Treat EACCES (seen on Solaris 11.3) like EINVAL (seen on Illumos). --- diff --git a/ChangeLog b/ChangeLog index 5f70a80926..d812e73f55 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2022-09-12 Bruno Haible + + supersede: Avoid a failure when writing to /dev/null in Solaris zones. + * lib/supersede.c (open_supersede): Treat EACCES (seen on Solaris 11.3) + like EINVAL (seen on Illumos). + 2022-09-11 Paul Eggert maint: avoid unportable ERE \} diff --git a/lib/supersede.c b/lib/supersede.c index a72c4f40e8..7fbd619fde 100644 --- a/lib/supersede.c +++ b/lib/supersede.c @@ -83,9 +83,12 @@ open_supersede (const char *filename, int flags, mode_t mode, /* Extra flags for existing devices. */ int extra_flags = #if defined __sun || (defined _WIN32 && !defined __CYGWIN__) - /* open ("/dev/null", O_TRUNC | O_WRONLY) fails with error EINVAL on Solaris - zones. See . - Likewise for open ("NUL", O_TRUNC | O_RDWR) on native Windows. + /* open ("/dev/null", O_TRUNC | O_WRONLY) fails on Solaris zones: + - with error EINVAL on Illumos, see + , + - with error EACCES on Solaris 11.3. + Likewise, open ("NUL", O_TRUNC | O_RDWR) fails with error EINVAL on + native Windows. As a workaround, add the O_CREAT flag, although it ought not to be necessary. */ O_CREAT; @@ -204,7 +207,7 @@ open_supersede (const char *filename, int flags, mode_t mode, } #if defined __sun || (defined _WIN32 && !defined __CYGWIN__) /* See the comment regarding extra_flags, above. */ - else if (errno == EINVAL) + else if (errno == EINVAL || errno == EACCES) { struct stat statbuf;