-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
decompress to block device using -o is broken #3583
Comments
doing an
|
When the Using it in combination with other endpoints, such as loop devices, opens a pandora box of problems. We have 2 choices here :
Option 1 is tempting if the fixes are deemed simple enough, though there is always a risk that more problems will be discovered later. |
I think option 2 is the safest to do. I stumbled across this bug by writing a disk image to a real block device. No error, but broken file system. I am not familiar with the code and it is pretty complex with regards to multi-OS compatibility. I don't know why this is so complex - maybe due to multi-OS support. This comment is from my (somewhat naive) linux-only perspective: |
Work around: on top of using pipes, I think another way to get your use case working is to add the command |
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 --spare and --no-sparse. fix #3583
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
The commit does not fix the issue. It writes the message ("Sparse File Support is disabled when output is not a file"), but still uses the lseek syscalls. |
There is an else branch missing which resets sparseFileSupport to 1 (which is ZSTD_SPARSE_DEFAULT):
Alternatively, the |
Thanks for the check and suggestion ! Latest update of |
Describe the bug
When decompressing with "-o" to a block device, the output does not match the source file
To Reproduce
The following script shows the problem:
Sample output:
Expected behavior
-o
should generate the same output as piping to a deviceDesktop (please complete the following information):
Additional context
The problem seems to be seeks in the output. This is fine for files, which are generated (seek will generate zeroes in the output file). For block devices, seek must not be used (because it keeps the file contents as is instead of zeroing them as expected)
The text was updated successfully, but these errors were encountered: