* dd: get rid of line-buffered stdout
Line-buffered stdout causes partial write and read operations in dd,
which is an issue when writing binary data to stdout. Partial writes can
lead to data loss and require passing iflag=fullblock to ensure that the
exact number of bytes is read.
* dd: Add test to check for dropped writes
(cherry picked from commit 0f7c53111df8b945bdb06217396b332f24a42100)
* Fix build on Windows
* dd: use OwnedFileDescriptorOrHandle
OwnedFileDescriptorOrHandle can be used to bypass the LineWriter
that is used by default for Stdout.
* Run test_no_dropped_writes only on unix
---------
Co-authored-by: Adrian Kretz <me@akretz.com>
* dd: use seek for stdin skip when possible
* Add Rust tests for skip with seekable stdin
* Address review comments: fix return value, add comment, refactor tests
* dd: use ibs-sized buffer for ESPIPE fallback in skip
Fix dd failures with 'IO Error: Invalid input' when using
oflag=direct with partial blocks. The issue occurs because O_DIRECT requires
proper alignment for all writes, but the final partial block may not meet
these requirements.
This fix:
- Detects EINVAL errors that might be O_DIRECT alignment issues
- Temporarily removes O_DIRECT flag using fcntl(F_SETFL)
- Retries the write operation without the direct flag
- Restores original flags (safer than GNU approach)
- Only activates on Linux/Android platforms where O_DIRECT is supported
Matches GNU dd behavior discovered through strace analysis.
- Added devcontainer configuration based on Ubuntu 24.04
- Added GitHub Actions workflow for devcontainer testing
- Update cSpell configuration to ingore spelling in devcontainer configs
- Update pre-commit hooks to exclude cSpell.json because pre-commit
fails for that file due to json with comments format
- Fix filename for cSpell config in vscode settings
- Two tests in `test_dd.rs` are now skipped if /dev/sda1 is not
available, which is the case in devcontainer
- Update check for existing gnu clone in build-gnu.sh, not checking the
existence of the directory but the presence of the .git directory.
This allows us to have the directly as a volume mount in devcontainer
- Remove temporary file `g` after use in build-gnu.sh
Minor manual cleanup - inlined many format args. This makes the code a bit more readable, and helps spot a few inefficiencies and possible bugs. Note that `&foo` in a `format!` parameter results in a 6% extra performance cost, and does not get inlined by the compiler (yet).