diff options
author | jlemon <jlemon@FreeBSD.org> | 1997-08-19 19:46:18 +0000 |
---|---|---|
committer | jlemon <jlemon@FreeBSD.org> | 1997-08-19 19:46:18 +0000 |
commit | 276d42acd0a55ebdb8e4458e142f40402939e4ba (patch) | |
tree | 0da30525722b07cba56ca7f4df310b0c3db275a9 /bin/dd | |
parent | 070f42a366d1f592be37f248439635c1d36eaaa3 (diff) | |
download | FreeBSD-src-276d42acd0a55ebdb8e4458e142f40402939e4ba.zip FreeBSD-src-276d42acd0a55ebdb8e4458e142f40402939e4ba.tar.gz |
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
Diffstat (limited to 'bin/dd')
-rw-r--r-- | bin/dd/dd.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/bin/dd/dd.c b/bin/dd/dd.c index 451715b..60d7e67 100644 --- a/bin/dd/dd.c +++ b/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) |