GNU bug report logs -
#75405
gzip --synchronous doesn't work with musl
Previous Next
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your message dated Fri, 10 Jan 2025 10:19:32 -0800
with message-id <ba8cb748-cfca-4377-8695-976b25549d4d <at> cs.ucla.edu>
and subject line Re: bug#75405: gzip --synchronous doesn't work with musl
has caused the debbugs.gnu.org bug report #75405,
regarding gzip --synchronous doesn't work with musl
to be marked as done.
(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)
--
75405: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=75405
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
[Message part 3 (text/plain, inline)]
On Linux/musl:
$ echo foo > foo
$ gzip --synchronous foo
gzip: foo.gz: Bad file descriptor
From gzip.c:
dfd = open (dfname, O_SEARCH | O_DIRECTORY);
...
if ((synchronous
&& ((0 <= dfd && fdatasync (dfd) != 0 && errno != EINVAL)
|| (fsync (ofd) != 0 && errno != EINVAL)))
|| close (ofd) != 0)
write_error ();
In musl, O_SEARCH maps to Linux-specific O_PATH which doesn't allow
fsync or fdatasync. Gnulib's fcntl module's docs already warn about a
similar situation with fchmod.
As far as I understand this, O_SEARCH in POSIX is only meant for openat
and such APIs. Then it makes sense that O_SEARCH becomes O_PATH because
O_PATH can open a directory that lacks read permission. This way openat
can be used even for such directories.
Maybe there is no way to sync a directory that only has write and search
permissions. Luckily such a combination is rare.
A short fix is using O_RDONLY when --synchronous has been specified:
dfd = open (dfname, (synchronous ? O_RDONLY : O_SEARCH)
| O_DIRECTORY);
I also tried opening a separate file descriptor for syncing (see the
attachment) but I think the above change is better. However, both have
a weakness that if the directory cannot be opened, --synchronous will
silently skip syncing the directory. It would be safer to show an error
if the directory cannot be opened when --synchronous has been specified.
--
Lasse Collin
[dfd_sync.patch (text/x-patch, attachment)]
[Message part 5 (message/rfc822, inline)]
Thanks, I installed that test. Marking this gzip bug as done.
This bug report was last modified 186 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.