Pádraig Brady <[EMAIL PROTECTED]> writes:

> * src/dd.c: If output buffer size would be
> the same size as the input buffer, just use
> a single buffer to avoid redundant memory copy.

Unfortunately this patch introduced a bug into 'dd', so that it no
longer conforms to POSIX.

The C_TWOBUFS option has two effects, one having to do with whether a
single buffer is used, and the other having to do with whether output
blocks are dynamically resized to be the same size as input blocks.
This patch inadvertently caused the latter behavior to change.

Here's an example of the problem:

$ (echo 'x'; sleep 10; echo y) | dd ibs=3 obs=3

POSIX says that in this case the output data must be reblocked into
blocks of 3 bytes.  With the working 'dd', you'll see a pause of 10
seconds (because the first 'echo' outputs only 2 bytes), then the x and
y right away (because we now have all 4 input bytes, and can issue a
write of 3 bytes and a write of 1 byte).  With a buggy 'dd', you'll see
the 'x' right away (because we output a 2-byte block), then a pause of
10 seconds, then a 'y' (the other 2-byte block).

The simplest fix I see is to revert the patch.  Of course one could up
with something fancier....


_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to