tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

two modifications to dd(1)



I'd like to commit (posibilly with two commits) following changes
taken from FreeBSD and/or OpenBSD.  Objection?

1) Copy argument before modifying it so that ps(1) shows entire
   options.

2) Add to new argument iseek and oseek as an alias of skip and seek.
   Solaris also has these option.

enami.

Index: args.c
===================================================================
RCS file: /cvsroot/src/bin/dd/args.c,v
retrieving revision 1.29
diff -u -r1.29 args.c
--- args.c      9 Dec 2010 10:24:56 -0000       1.29
+++ args.c      9 Dec 2010 10:25:34 -0000
@@ -95,8 +95,10 @@
        { "files",      f_files,        C_FILES, C_FILES },
        { "ibs",        f_ibs,          C_IBS,   C_BS|C_IBS },
        { "if",         f_if,           C_IF,    C_IF|C_RIF },
+       { "iseek",      f_skip,         C_SKIP,  C_SKIP },
        { "obs",        f_obs,          C_OBS,   C_BS|C_OBS },
        { "of",         f_of,           C_OF,    C_OF|C_ROF },
+       { "oseek",      f_seek,         C_SEEK,  C_SEEK },
        { "progress",   f_progress,     0,       0 },
 #ifndef SMALL
        { "rif",        f_rif,          C_RIF|C_RUMP,    C_RIF|C_IF },
@@ -118,6 +120,12 @@
        in.dbsz = out.dbsz = 512;
 
        while ((oper = *++argv) != NULL) {
+               if ((oper = strdup(oper)) == NULL) {
+                       errx(EXIT_FAILURE,
+                           "unable to allocate space for the argument %s",
+                           *argv);
+                       /* NOTREACHED */
+               }
                if ((arg = strchr(oper, '=')) == NULL) {
                        errx(EXIT_FAILURE, "unknown operand %s", oper);
                        /* NOTREACHED */
Index: dd.1
===================================================================
RCS file: /cvsroot/src/bin/dd/dd.1,v
retrieving revision 1.22
diff -u -r1.22 dd.1
--- dd.1        11 Mar 2009 12:43:58 -0000      1.22
+++ dd.1        9 Dec 2010 10:25:34 -0000
@@ -91,6 +91,12 @@
 Read input from
 .Ar file
 instead of the standard input.
+.It Cm iseek= Ns Ar n
+Seek on the input file
+.Ar n
+blocks.
+This is synonymous with
+.Cm skip= Ns Ar n .
 .It Cm obs= Ns Ar n
 Set the output block size to
 .Va n
@@ -106,6 +112,12 @@
 .Cm seek
 operand)
 the output file is truncated at that point.
+.It Cm oseek= Ns Ar n
+Seek on the output file
+.Ar n
+blocks.
+This is synonymous with
+.Cm seek= Ns Ar n .
 .It Cm seek= Ns Ar n
 Seek
 .Va n


Home | Main Index | Thread Index | Old Index