summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2006-12-22 10:09:37 +0100
committerJim Meyering <jim@meyering.net>2006-12-22 10:09:37 +0100
commitf24ff8f42b45f868876bde7d21046c01188d42a4 (patch)
treeb0a031d5b386b224b5bc6ad7c52d0b82acb05f29
parent699188aa87648cc487ee7bcdaeebfcbbb182e356 (diff)
downloadcoreutils-f24ff8f42b45f868876bde7d21046c01188d42a4.tar.xz
* NEWS: dd bs= operands now silently override later ibs= and obs=,
as POSIX requires. * src/dd.c (scanargs): Implement it. * tests/dd/misc (outbytes): Test it. * doc/coreutils.texi (dd invocation): Specify that bs=N overrides later ibs and obs, undoing part of the previous change. (The behavior was wrong.)
-rw-r--r--ChangeLog12
-rw-r--r--NEWS3
-rw-r--r--doc/coreutils.texi2
-rw-r--r--src/dd.c6
-rwxr-xr-xtests/dd/misc3
5 files changed, 21 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index e9c84ceb8..fa0a39bf3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,12 @@
-2006-12-21 Jim Meyering <jim@meyering.net>
-
- * Makefile.maint (patch-check): Fix shell quoting.
+2006-12-21 Paul Eggert <eggert@cs.ucla.edu>
+
+ * NEWS: dd bs= operands now silently override later ibs= and obs=,
+ as POSIX requires.
+ * src/dd.c (scanargs): Implement it.
+ * tests/dd/misc (outbytes): Test it.
+ * doc/coreutils.texi (dd invocation): Specify that bs=N
+ overrides later ibs and obs, undoing part of the
+ previous change. (The behavior was wrong.)
2006-12-20 Jim Meyering <jim@meyering.net>
diff --git a/NEWS b/NEWS
index bf1d28798..c934cd981 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,9 @@ GNU coreutils NEWS -*- outline -*-
more file arguments. This was due to a double-free bug, introduced
in coreutils-5.3.0.
+ dd bs= operands now silently override any later ibs= and obs=
+ operands, as POSIX and tradition require.
+
A cross-partition "mv /etc/passwd ~" (by non-root) now prints
a reasonable diagnostic. Before, it would print this:
"mv: cannot remove `/etc/passwd': Not a directory".
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index dfd9595f1..ab95db48a 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -7170,7 +7170,7 @@ This makes @command{dd} write @var{bytes} per block.
@cindex block size
Set both input and output block sizes to @var{bytes}.
This makes @command{dd} read and write @var{bytes} per block,
-overriding any preceding @samp{ibs} and @samp{obs} settings.
+overriding any @samp{ibs} and @samp{obs} settings.
@item cbs=@var{bytes}
@opindex cbs
diff --git a/src/dd.c b/src/dd.c
index 3449e1253..1a3a4e426 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -873,6 +873,7 @@ static void
scanargs (int argc, char **argv)
{
int i;
+ size_t blocksize = 0;
for (i = optind; i < argc; i++)
{
@@ -923,7 +924,7 @@ scanargs (int argc, char **argv)
else if (STREQ (name, "bs"))
{
invalid |= ! (0 < n && n <= MAX_BLOCKSIZE (INPUT_BLOCK_SLOP));
- output_blocksize = input_blocksize = n;
+ blocksize = n;
}
else if (STREQ (name, "cbs"))
{
@@ -948,6 +949,9 @@ scanargs (int argc, char **argv)
}
}
+ if (blocksize)
+ input_blocksize = output_blocksize = blocksize;
+
/* If bs= was given, both `input_blocksize' and `output_blocksize' will
have been set to positive values. If either has not been set,
bs= was not given, so make sure two buffers are used. */
diff --git a/tests/dd/misc b/tests/dd/misc
index 2db5c5bd7..513221bce 100755
--- a/tests/dd/misc
+++ b/tests/dd/misc
@@ -74,6 +74,9 @@ if dd oflag=nolinks if=$tmp_in of=$tmp_out 2> /dev/null; then
dd oflag=nolinks < $tmp_in > $tmp_out 2>&1 || fail=1
fi
+outbytes=`echo x | dd bs=3 ibs=10 obs=10 conv=sync 2>/dev/null | wc -c`
+test "$outbytes" -eq 3 || fail=1
+
rm -f $tmp_in $tmp_in2 $tmp_sym $tmp_out
exit $fail