Feature #14189


want support for dd status=

Added by Robert Mustacchi 3 months ago. Updated 3 months ago.

cmd - userland programs
Start date:
Due date:
% Done:


Estimated time:
Gerrit CR:


Other implementations have support for the dd option status= with three options status=none, status=noxfer, and status=progress. We should add support for these. Every dd implementation has a slightly different output of its statistics and progress. We implement the progress option by having it go through a similar code path that we do for siginfo, allowing us to try and get the same output format for consistency.

In addition, we make one other notable change from other implementations which is that if stderr is not a tty, then we do not emit carriage returns and instead newlines. While it isn't recommended that folks parse this format (and it is ultimately not stable), control characters in a text file probably aren't useful. Otherwise, by default each line of progress output overwrites the previous one unless the user has emitted output either by typing it on the tty or by using the siginfo/sigusr1 features.

The following shows what dd output looks like if you enable progress and then wait a few seconds, inject a few signals, and then eventually terminate it:

dd bs=1M if=/dev/zero of=/dev/null status=progress 
311584358400 (290 GiB) bytes transferred in 7.000006 secs (41 GiB/sec)
313881+0 records in
313881+0 records out
329128083456 (307 GiB) bytes transferred in 7.393318 secs (41 GiB/sec)
534473867264 (498 GiB) bytes transferred in 12.000018 secs (41 GiB/sec)
515402+0 records in
515402+0 records out
540438167552 (503 GiB) bytes transferred in 12.133880 secs (41 GiB/sec)
712791556096 (664 GiB) bytes transferred in 16.000022 secs (41 GiB/sec)^C
692405+0 records in
692405+0 records out
726039265280 (676 GiB) bytes transferred in 16.306815 secs (41 GiB/sec)

Note, we always fire this when we hit the output loop again during a copy and go as close to the second as we can. This may mean that this will not be aligned; however, it will not drift.

If you specify noxfer, here's instead what you see when you terminate dd:

$ dd bs=1M count=100 if=/dev/zero of=/dev/null status=noxfer
100+0 records in
100+0 records out

Note here there is no output of the throughput statistics. And if you specify status=none, then you'll see none of this at all.


Also available in: Atom PDF