[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Re: dd blocks/bytes at a time
From: |
Paul Eggert |
Subject: |
Re: [PATCH] Re: dd blocks/bytes at a time |
Date: |
Thu, 21 Dec 2006 11:06:51 -0800 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux) |
Jim Meyering <address@hidden> writes:
> Andreas Schwab <address@hidden> wrote:
>> But only the preceding ones.
>
> True. Thanks.
Wait a minute -- POSIX says bs= should override all ibs= and obs=
operands (not just preceding ones), and traditional dd conforms to
POSIX here. So the GNU documentation was right and the behavior
wrong.
Here's a patch.
2006-12-21 Paul Eggert <address@hidden>
* 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.)
diff --git a/NEWS b/NEWS
index bf1d287..c934cd9 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,9 @@ GNU coreutils NEWS
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/src/dd.c b/src/dd.c
index 35c0a43..f37445e 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -877,6 +877,7 @@ static void
scanargs (int argc, char **argv)
{
int i;
+ size_t blocksize = 0;
for (i = optind; i < argc; i++)
{
@@ -927,7 +928,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"))
{
@@ -952,6 +953,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 2db5c5b..513221b 100755
--- a/tests/dd/misc
+++ b/tests/dd/misc
@@ -74,6 +74,9 @@ if dd oflag=nolinks if=$tmp_in of=$tmp_o
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
M ChangeLog
M NEWS
M src/dd.c
M tests/dd/misc
Committed as 40bc2cf02aeb0d1ae4a9754b01a0f989c974e4e1
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index dfd9595..ab95db4 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -7170,7 +7170,7 @@ This makes @command{dd} write @var{bytes
@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 address@hidden
@opindex cbs
M doc/ChangeLog
M doc/coreutils.texi
Committed as 6c92651bd3435131f09fb5b7d01f1826fabc3a07
- dd blocks/bytes at a time, Dan Jacobson, 2006/12/20
- [PATCH] Re: dd blocks/bytes at a time, Olivier Delhomme, 2006/12/20
- Re: [PATCH] Re: dd blocks/bytes at a time, Dan Jacobson, 2006/12/20
- Re: [PATCH] Re: dd blocks/bytes at a time, Jim Meyering, 2006/12/21
- Re: [PATCH] Re: dd blocks/bytes at a time, Andreas Schwab, 2006/12/21
- Re: [PATCH] Re: dd blocks/bytes at a time, Jim Meyering, 2006/12/21
- Re: [PATCH] Re: dd blocks/bytes at a time,
Paul Eggert <=
- Re: [PATCH] Re: dd blocks/bytes at a time, Jim Meyering, 2006/12/21
- Re: [PATCH] Re: dd blocks/bytes at a time, Matthew Woehlke, 2006/12/21
- Re: [PATCH] Re: dd blocks/bytes at a time, Jim Meyering, 2006/12/21
- Re: [PATCH] Re: dd blocks/bytes at a time, Matthew Woehlke, 2006/12/21
- Re: [PATCH] Re: dd blocks/bytes at a time, Paul Eggert, 2006/12/21
- Re: [PATCH] Re: dd blocks/bytes at a time, Paul Eggert, 2006/12/21
- Re: [PATCH] Re: dd blocks/bytes at a time, Jim Meyering, 2006/12/22
Re: [PATCH] Re: dd blocks/bytes at a time, Jim Meyering, 2006/12/21