Mike Karels at BSDI's changes for osync, to make output padding work
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Fri, 14 Jan 1994 04:10:30 +0000 (20:10 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Fri, 14 Jan 1994 04:10:30 +0000 (20:10 -0800)
correctly (this is not POSIX.2, but POSIX.2 is wrong)

SCCS-vsn: bin/dd/args.c 8.2
SCCS-vsn: bin/dd/dd.1 8.2
SCCS-vsn: bin/dd/dd.c 8.2
SCCS-vsn: bin/dd/dd.h 8.2

usr/src/bin/dd/args.c
usr/src/bin/dd/dd.1
usr/src/bin/dd/dd.c
usr/src/bin/dd/dd.h

index 2a401c3..6e923a3 100644 (file)
@@ -10,7 +10,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)args.c     8.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)args.c     8.2 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -41,7 +41,7 @@ static struct arg {
        void (*f) __P((char *));
        u_int set, noset;
 } args[] = {
        void (*f) __P((char *));
        u_int set, noset;
 } args[] = {
-       "bs",           f_bs,           C_BS,           C_BS|C_IBS|C_OBS,
+       "bs",           f_bs,           C_BS,           C_BS|C_IBS|C_OBS|C_OSYNC,
        "cbs",          f_cbs,          C_CBS,          C_CBS,
        "conv",         f_conv,         0,              0,
        "count",        f_count,        C_COUNT,        C_COUNT,
        "cbs",          f_cbs,          C_CBS,          C_CBS,
        "conv",         f_conv,         0,              0,
        "count",        f_count,        C_COUNT,        C_COUNT,
@@ -240,6 +240,7 @@ static struct conv {
        "oldascii",     C_ASCII,        C_EBCDIC,       e2a_32V,
        "oldebcdic",    C_EBCDIC,       C_ASCII,        a2e_32V,
        "oldibm",       C_EBCDIC,       C_ASCII,        a2ibm_32V,
        "oldascii",     C_ASCII,        C_EBCDIC,       e2a_32V,
        "oldebcdic",    C_EBCDIC,       C_ASCII,        a2e_32V,
        "oldibm",       C_EBCDIC,       C_ASCII,        a2ibm_32V,
+       "osync",        C_OSYNC,        C_BS,           NULL,
        "swab",         C_SWAB,         0,              NULL,
        "sync",         C_SYNC,         0,              NULL,
        "ucase",        C_UCASE,        C_LCASE,        NULL,
        "swab",         C_SWAB,         0,              NULL,
        "sync",         C_SYNC,         0,              NULL,
        "ucase",        C_UCASE,        C_LCASE,        NULL,
index 9a9ac7a..e3e14fc 100644 (file)
@@ -6,7 +6,7 @@
 .\"
 .\" %sccs.include.redist.roff%
 .\"
 .\"
 .\" %sccs.include.redist.roff%
 .\"
-.\"     @(#)dd.1       8.1 (Berkeley) %G%
+.\"     @(#)dd.1       8.2 (Berkeley) %G%
 .\"
 .Dd 
 .Dt DD 1
 .\"
 .Dd 
 .Dt DD 1
@@ -214,6 +214,15 @@ by
 The
 .Cm notrunc
 value is not supported for tapes.
 The
 .Cm notrunc
 value is not supported for tapes.
+.It Cm osync
+Pad the final output block to the full output block size.
+If the input file is not a multiple of the output block size
+after conversion, this conversion forces the final output block
+to be the same size as preceding blocks for use on devices that require
+regularly sized blocks to be written.
+This option is incompatible with use of the
+.Cm bs= Ns Ar n
+block size specification.
 .It Cm swab
 Swap every pair of input bytes.
 If an input buffer has an odd number of bytes, the last byte will be
 .It Cm swab
 Swap every pair of input bytes.
 If an input buffer has an odd number of bytes, the last byte will be
index c4bd89b..01d0675 100644 (file)
@@ -16,7 +16,7 @@ static char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)dd.c       8.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)dd.c       8.2 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -196,7 +196,7 @@ dd_in()
                 * lose the minimum amount of data.  If doing block operations
                 * use spaces.
                 */
                 * lose the minimum amount of data.  If doing block operations
                 * use spaces.
                 */
-               if (flags & (C_NOERROR|C_SYNC))
+               if ((flags & (C_NOERROR|C_SYNC)) == (C_NOERROR|C_SYNC))
                        if (flags & (C_BLOCK|C_UNBLOCK))
                                memset(in.dbp, ' ', in.dbsz);
                        else
                        if (flags & (C_BLOCK|C_UNBLOCK))
                                memset(in.dbp, ' ', in.dbsz);
                        else
@@ -290,6 +290,10 @@ dd_close()
                block_close();
        else if (cfunc == unblock)
                unblock_close();
                block_close();
        else if (cfunc == unblock)
                unblock_close();
+       if (ddflags & C_OSYNC && out.dbcnt < out.dbsz) {
+               bzero(out.dbp, out.dbsz - out.dbcnt);
+               out.dbcnt = out.dbsz;
+       }
        if (out.dbcnt)
                dd_out(1);
 }
        if (out.dbcnt)
                dd_out(1);
 }
index 0c4430a..cca5930 100644 (file)
@@ -8,7 +8,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)dd.h        8.1 (Berkeley) %G%
+ *     @(#)dd.h        8.2 (Berkeley) %G%
  */
 
 /* Input/output stream state. */
  */
 
 /* Input/output stream state. */
@@ -67,3 +67,4 @@ typedef struct {
 #define        C_SYNC          0x20000
 #define        C_UCASE         0x40000
 #define        C_UNBLOCK       0x80000
 #define        C_SYNC          0x20000
 #define        C_UCASE         0x40000
 #define        C_UNBLOCK       0x80000
+#define        C_OSYNC         0x100000