You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ mkfifo inpipe
$ dd ibs=3 obs=3 if=inpipe &
$ (printf 'ab'; sleep 1; printf 'cd') > inpipe
abcd0+2 records in
1+1 records out
4 bytes copied, 1.00373 s, 0.0 kB/s
uutils dd:
$ mkfifo inpipe
$ ./target/debug/dd ibs=3 obs=3 if=inpipe &
$ (printf 'ab'; sleep 1; printf 'cd') > inpipe
0+2 records in
2+0 records out
4 bytes (4 B, 4 B) copied, 1.0 s, 0 B/s
abcd
There's a couple of minor differences here, but this issue is about the difference in the number of "records out": 1+1 records out versus 2+0 records out. The number on the left of the + sign is the number of complete blocks written, and the number on the right is the number of partial blocks written. In this case, the input block size is 3 and the output block size is 3, so 1+1 records out means that 1 complete block was written ('abc') and 1 partial block was written ('d'). However, the uutils dd is reporting 2 complete blocks written (presumably 'ab' and 'cd'), which is incorrect.
I believe this is happening because we are not buffering the output appropriately. I'm thinking that by maintaining a buffer of size obs, only flushing it when full, and only incrementing the number of complete blocks on flush, then we can get the correct behavior.
This makes dd read and write bytes per block, overriding any ‘ibs’ and ‘obs’ settings. In addition, if no data-transforming conv operand is specified, input is copied to the output as soon as it’s read, even if it is smaller than the block size.
In that case:
$ mkfifo inpipe
$ dd bs=3 if=inpipe &
$ (printf 'ab'; sleep 1; printf 'cd') > inpipe
abcd0+2 records in
0+2 records out
4 bytes copied, 1.00381 s, 0.0 kB/s
and you can see when you run it that the first partial block 'ab' gets written, then there is a 1 second pause, then the second partial block 'cd' gets written.
The text was updated successfully, but these errors were encountered:
GNU dd:
uutils dd:
There's a couple of minor differences here, but this issue is about the difference in the number of "records out":
1+1 records out
versus2+0 records out
. The number on the left of the + sign is the number of complete blocks written, and the number on the right is the number of partial blocks written. In this case, the input block size is 3 and the output block size is 3, so1+1 records out
means that 1 complete block was written ('abc'
) and 1 partial block was written ('d'
). However, the uutils dd is reporting 2 complete blocks written (presumably'ab'
and'cd'
), which is incorrect.I believe this is happening because we are not buffering the output appropriately. I'm thinking that by maintaining a buffer of size
obs
, only flushing it when full, and only incrementing the number of complete blocks on flush, then we can get the correct behavior.One caveat: if
bs=3
is given instead ofibs=3 obs=3
on the command-line, then the behavior is different, as described in https://www.gnu.org/software/coreutils/manual/html_node/dd-invocation.html :In that case:
and you can see when you run it that the first partial block
'ab'
gets written, then there is a 1 second pause, then the second partial block'cd'
gets written.The text was updated successfully, but these errors were encountered: