]> git.ipfire.org Git - thirdparty/zstd.git/commit
fix decompression with -o writing into a block device
authorYann Collet <cyan@fb.com>
Fri, 31 Mar 2023 18:13:52 +0000 (11:13 -0700)
committerYann Collet <cyan@fb.com>
Fri, 31 Mar 2023 18:29:16 +0000 (11:29 -0700)
commit5bf1359e3be0e64149bbb989f2addfc42adf30d3
treed6865ffecdd0e39f5137f0b934d2f5c7bfb1422b
parent871f3a402653697a22eb892c19db295333a85168
fix decompression with -o writing into a block device

decompression features automatic support of sparse files,
aka a form of "compression" where entire blocks consists only of zeroes.
This only works for some compatible file systems (like ext4),
others simply ignore it (like afs).

Triggering this feature relies of `fseek()`.
But `fseek()` is not compatible with non-seekable devices, such as pipes.
Therefore it's disabled for pipes.

However, there are other objects which are not compatible with `fseek()`, such as block devices.

Changed the logic, so that `fseek()` (and therefore sparse write) is only automatically enabled on regular files.

Note that this automatic behavior can always be overridden by explicit commands `--sparse` and `--no-sparse`.

fix #3583
programs/fileio.c