]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Revert part of "dd: avoid unnecessary memory copies"
authorPádraig Brady <P@draigBrady.com>
Fri, 21 Nov 2008 22:17:44 +0000 (23:17 +0100)
committerJim Meyering <meyering@redhat.com>
Sat, 22 Nov 2008 09:20:31 +0000 (10:20 +0100)
This reverts part of commit fbd87029cfc494a72bb73ade27ef46382c5bc832.
Paul Eggert noticed the problem in
http://lists.gnu.org/archive/html/bug-coreutils/2008-11/msg00153.html
* doc/coreutils.texi (dd invocation): Clarify.

doc/coreutils.texi
src/dd.c

index 935129f2549632fcc3ffdd0b58bdd5b60b4a2b8d..c9c61cef06085d4e52c992da893f5cd4f0031bea 100644 (file)
@@ -7573,6 +7573,9 @@ This makes @command{dd} write @var{bytes} per block.
 Set both input and output block sizes to @var{bytes}.
 This makes @command{dd} read and write @var{bytes} per block,
 overriding any @samp{ibs} and @samp{obs} settings.
+In addition, if no data-transforming @option{conv} option is specified,
+each input block is copied to the output as a single block,
+without aggregating short reads.
 
 @item cbs=@var{bytes}
 @opindex cbs
index e1e38e954869ce848cb3e1c9444f8ae307ca280a..e54cc14dfc430acdf248d2dd9cc15be08e38a1e1 100644 (file)
--- a/src/dd.c
+++ b/src/dd.c
@@ -455,7 +455,7 @@ Usage: %s [OPERAND]...\n\
       fputs (_("\
 Copy a file, converting and formatting according to the operands.\n\
 \n\
-  bs=BYTES        force ibs=BYTES and obs=BYTES\n\
+  bs=BYTES        read and write BYTES bytes at a time\n\
   cbs=BYTES       convert BYTES bytes at a time\n\
   conv=CONVS      convert the file as per the comma separated symbol list\n\
   count=BLOCKS    copy only BLOCKS input blocks\n\
@@ -1033,13 +1033,17 @@ scanargs (int argc, char *const *argv)
 
   if (blocksize)
     input_blocksize = output_blocksize = blocksize;
+  else
+    {
+      /* POSIX says dd aggregates short reads into
+        output_blocksize if bs= is not specified.  */
+      conversions_mask |= C_TWOBUFS;
+    }
 
   if (input_blocksize == 0)
     input_blocksize = DEFAULT_BLOCKSIZE;
   if (output_blocksize == 0)
     output_blocksize = DEFAULT_BLOCKSIZE;
-  if (input_blocksize != output_blocksize)
-    conversions_mask |= C_TWOBUFS;
   if (conversion_blocksize == 0)
     conversions_mask &= ~(C_BLOCK | C_UNBLOCK);