Pad the input buffer whenever sync is used, not just if the noerror flag
is also set. Change osync to not to tack on an empty block if the input buffer is null, or an even multiple of the blocksize. Also change osync to pad the output with nulls/spaces depending whether this is a block-oriented conversion or not (same as sync). PR: 3818
This commit is contained in:
parent
b6633f4571
commit
af041bf3fd
22
bin/dd/dd.c
22
bin/dd/dd.c
@ -34,7 +34,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: dd.c,v 1.10 1997/02/22 14:02:44 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -236,19 +236,18 @@ getfdtype(io)
|
||||
static void
|
||||
dd_in()
|
||||
{
|
||||
int flags, n;
|
||||
int n;
|
||||
|
||||
for (flags = ddflags;;) {
|
||||
for (;;) {
|
||||
if (cpy_cnt && (st.in_full + st.in_part) >= cpy_cnt)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Zero the buffer first if trying to recover from errors so
|
||||
* lose the minimum amount of data. If doing block operations
|
||||
* Zero the buffer first if sync; If doing block operations
|
||||
* use spaces.
|
||||
*/
|
||||
if ((flags & (C_NOERROR|C_SYNC)) == (C_NOERROR|C_SYNC))
|
||||
if (flags & (C_BLOCK|C_UNBLOCK))
|
||||
if (ddflags & C_SYNC)
|
||||
if (ddflags & (C_BLOCK|C_UNBLOCK))
|
||||
memset(in.dbp, ' ', in.dbsz);
|
||||
else
|
||||
memset(in.dbp, 0, in.dbsz);
|
||||
@ -265,7 +264,7 @@ dd_in()
|
||||
* If noerror not specified, die. POSIX requires that
|
||||
* the warning message be followed by an I/O display.
|
||||
*/
|
||||
if (!(flags & C_NOERROR))
|
||||
if (!(ddflags & C_NOERROR))
|
||||
err(1, "%s", in.name);
|
||||
warn("%s", in.name);
|
||||
summary();
|
||||
@ -341,8 +340,11 @@ dd_close()
|
||||
block_close();
|
||||
else if (cfunc == unblock)
|
||||
unblock_close();
|
||||
if (ddflags & C_OSYNC && out.dbcnt < out.dbsz) {
|
||||
memset(out.dbp, 0, out.dbsz - out.dbcnt);
|
||||
if (ddflags & C_OSYNC && out.dbcnt && out.dbcnt < out.dbsz) {
|
||||
if (ddflags & (C_BLOCK|C_UNBLOCK))
|
||||
memset(out.dbp, ' ', out.dbsz - out.dbcnt);
|
||||
else
|
||||
memset(out.dbp, 0, out.dbsz - out.dbcnt);
|
||||
out.dbcnt = out.dbsz;
|
||||
}
|
||||
if (out.dbcnt)
|
||||
|
Loading…
x
Reference in New Issue
Block a user