On 29/10/2026 04:17, Collin Funk wrote:
* src/dd.c (main): Also account for seeking bytes in a few conditions.
* tests/dd/bytes.sh: Add a test case.
* tests/dd/fail-ftruncate-fstat.sh (fail_ftruncate_fstat): New function.
Use it to test seeking on bytes, and make sure fstat and ftruncate are
called.
* NEWS: Mention the bug fix.
The code changes look good.
I'd adjust the test as per the attached.
That fixes an obvious typo where $seek_arg wasn't referenced.
Also it checks the first invocation actually does inject or skips,
which is a stonger verification than just checking strace supports the args.
cheers,
Padraig
diff --git a/tests/dd/fail-ftruncate-fstat.sh b/tests/dd/fail-ftruncate-fstat.sh
index 328bb2852..b241e534b 100755
--- a/tests/dd/fail-ftruncate-fstat.sh
+++ b/tests/dd/fail-ftruncate-fstat.sh
@@ -28,20 +28,24 @@ fail_ftruncate_fstat ()
-P out -e quiet=path-resolution "$@" 2>err
}
-fail_ftruncate_fstat true || skip_ 'cannot intercept ftruncate or fstat'
-
for seek_arg in seek=1 seek=1B 'seek=1 oflag=seek_bytes'; do
# Setup the file "out" and preserve it's original contents in "exp-out".
yes | head -n 2048 | tr -d '\n' > out || framework_failure_
cp out exp-out || framework_failure_
- fail_ftruncate_fstat dd if=/dev/zero of=out count=1 seek=1B status=none
+ fail_ftruncate_fstat dd if=/dev/zero of=out count=1 $seek_arg status=none
ret=$?
- # Seeking on bytes wouldn't perform call ftruncate in coreutils-9.12
- # and earlier.
- grep '^fstat.*INJECTED' strace.out || fail=1
- grep '^ftruncate.*INJECTED' strace.out || fail=1
+ # Verify interception using record seeking before checking byte seeking,
+ # which did not call ftruncate in coreutils-9.12 and earlier.
+ for syscall in ftruncate fstat; do
+ grep "^$syscall.*INJECTED" strace.out ||
+ {
+ test "$seek_arg" = seek=1 &&
+ skip_ 'cannot intercept ftruncate or fstat'
+ fail=1
+ }
+ done
# After ftruncate fails, we use fstat to get the file type.
echo "dd: cannot fstat 'out': $EPERM" > exp