diff --git a/bin/dd/dd.c b/bin/dd/dd.c index 451715bc756d..60d7e677c1b1 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)