GNU bug report logs - #75405
gzip --synchronous doesn't work with musl

Previous Next

Package: gzip;

Reported by: Lasse Collin <lasse.collin <at> tukaani.org>

Date: Mon, 6 Jan 2025 13:30:01 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Lasse Collin <lasse.collin <at> tukaani.org>
Cc: 75405 <at> debbugs.gnu.org
Subject: bug#75405: gzip --synchronous doesn't work with musl
Date: Mon, 6 Jan 2025 10:02:41 -0800
On 2025-01-06 05:29, Lasse Collin wrote:

> In musl, O_SEARCH maps to Linux-specific O_PATH

That is a bug in musl. musl should not define O_SEARCH to O_PATH on 
Linux, because O_PATH is not a valid implementation of O_SEARCH. Or if 
musl wants to do some sort of approximate-but-invalid implementation to 
POSIX, a better approximation is "#define O_SEARCH O_RDONLY", which is 
what Gnulib does in lib/fcntl.in.h. The approximation "#define O_SEARCH 
O_PATH" is more likely to break real-world applications than the 
approximation "#define O_SEARCH O_RDONLY" is.


> As far as I understand this, O_SEARCH in POSIX is only meant for openat
> and such APIs.

No, O_SEARCH is well defined in POSIX to work in plain 'open'. See 
<https://pubs.opengroup.org/onlinepubs/9799919799/functions/open.html>.


Would the following Gnulib patch work around the musl bug?

diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h
index 5f06c4fe10..44d02fb9fd 100644
--- a/lib/fcntl.in.h
+++ b/lib/fcntl.in.h
@@ -369,6 +369,11 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
 # define O_RSYNC 0
 #endif

+/* musl on GNU/Linux mistakenly has "#define O_SEARCH O_PATH".  */
+#if defined O_SEARCH && defined O_PATH && O_SEARCH == O_PATH
+# undef O_SEARCH
+#endif
+
 #ifndef O_SEARCH
 # define O_SEARCH O_RDONLY /* This is often close enough in older 
systems.  */
 #endif





This bug report was last modified 188 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.