while (1)
{
- if (r_partial + r_full >= max_records + (max_bytes ? 1 : 0))
+ if (r_partial + r_full >= max_records + !!max_bytes)
break;
/* Zero the buffer before reading, so that if we get a read error,
if (seek_records != 0 && !(conversions_mask & C_NOTRUNC))
{
- uintmax_t size = seek_records * output_blocksize;
+ uintmax_t size = seek_records * output_blocksize + seek_bytes;
unsigned long int obs = output_blocksize;
if (OFF_T_MAX / output_blocksize < seek_records)
exit_status = dd_copy ();
- if (max_records == 0)
+ if (max_records == 0 && max_bytes == 0)
{
/* Special case to invalidate cache to end of file. */
if (i_nocache && !invalidate_cache (STDIN_FILENO, 0))
}
else if (max_records != (uintmax_t) -1)
{
- /* Invalidate any pending region less that page size,
+ /* Invalidate any pending region less than page size,
in case the kernel might round up. */
if (i_nocache)
invalidate_cache (STDIN_FILENO, 0);
# seek bytes
echo abcdefghijklm |
dd bs=5 seek=8 oflag=seek_bytes > out 2> /dev/null || fail=1
-echo abcdefghijklm |
- dd bs=4 seek=2 > expected 2> /dev/null || fail=1
+printf '\0\0\0\0\0\0\0\0abcdefghijklm\n' > expected
compare expected out || fail=1
-# seek bytes on empty file
-echo abcdefghijklm |
- dd bs=5 seek=8 oflag=seek_bytes > out2 2> /dev/null || fail=1
-compare expected out2 || fail=1
+# Just truncation, no I/O
+dd bs=5 seek=8 oflag=seek_bytes of=out2 count=0 2> /dev/null || fail=1
+truncate -s8 expected2
+compare expected2 out2 || fail=1
Exit $fail