summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/dd/args.c16
-rw-r--r--bin/dd/dd.119
-rw-r--r--bin/dd/dd.h5
-rw-r--r--bin/dd/misc.c21
4 files changed, 49 insertions, 12 deletions
diff --git a/bin/dd/args.c b/bin/dd/args.c
index 35535c1aefc..730e71fee38 100644
--- a/bin/dd/args.c
+++ b/bin/dd/args.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: args.c,v 1.21 2013/11/11 23:07:28 deraadt Exp $ */
+/* $OpenBSD: args.c,v 1.22 2014/02/12 01:18:36 bluhm Exp $ */
/* $NetBSD: args.c,v 1.7 1996/03/01 01:18:58 jtc Exp $ */
/*-
@@ -59,6 +59,7 @@ static void f_obs(char *);
static void f_of(char *);
static void f_seek(char *);
static void f_skip(char *);
+static void f_status(char *);
static size_t get_bsz(char *);
static off_t get_off(char *);
@@ -78,6 +79,7 @@ static const struct arg {
{ "of", f_of, C_OF, C_OF },
{ "seek", f_seek, C_SEEK, C_SEEK },
{ "skip", f_skip, C_SKIP, C_SKIP },
+ { "status", f_status, C_STATUS,C_STATUS },
};
static char *oper;
@@ -249,6 +251,18 @@ f_skip(char *arg)
in.offset = get_off(arg);
}
+static void
+f_status(char *arg)
+{
+
+ if (strcmp(arg, "none") == 0)
+ ddflags |= C_NOINFO;
+ else if (strcmp(arg, "noxfer") == 0)
+ ddflags |= C_NOXFER;
+ else
+ errx(1, "unknown status %s", arg);
+}
+
static const struct conv {
const char *name;
diff --git a/bin/dd/dd.1 b/bin/dd/dd.1
index 4721e1572ee..ae9d81ad00a 100644
--- a/bin/dd/dd.1
+++ b/bin/dd/dd.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: dd.1,v 1.26 2014/02/02 22:43:40 jmc Exp $
+.\" $OpenBSD: dd.1,v 1.27 2014/02/12 01:18:36 bluhm Exp $
.\" $NetBSD: dd.1,v 1.5 1995/03/21 09:04:04 cgd Exp $
.\"
.\" Copyright (c) 1990, 1993
@@ -33,7 +33,7 @@
.\"
.\" @(#)dd.1 8.2 (Berkeley) 1/13/94
.\"
-.Dd $Mdocdate: February 2 2014 $
+.Dd $Mdocdate: February 12 2014 $
.Dt DD 1
.Os
.Sh NAME
@@ -139,6 +139,21 @@ For all other devices, the correct number of blocks is read without
distinguishing between a partial or complete block being read.
.It Xo
.Sm off
+.Cm status= Ar value
+.Sm on
+.Xc
+Where
+.Ar value
+is one of the symbols from the following list.
+.Bl -tag -width unblock
+.It Cm noxfer
+Do not print the transfer statistics as the last line of status output.
+.It Cm none
+Do not print the status output.
+Error messages are shown, but no informational messages.
+.El
+.It Xo
+.Sm off
.Cm conv= Ar value Oo ,
.Sm on
.Ar value ... Oc
diff --git a/bin/dd/dd.h b/bin/dd/dd.h
index a74d5a6a6aa..b9f57885322 100644
--- a/bin/dd/dd.h
+++ b/bin/dd/dd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dd.h,v 1.5 2003/06/02 23:32:07 millert Exp $ */
+/* $OpenBSD: dd.h,v 1.6 2014/02/12 01:18:36 bluhm Exp $ */
/* $NetBSD: dd.h,v 1.4 1995/03/21 09:04:08 cgd Exp $ */
/*-
@@ -93,3 +93,6 @@ typedef struct {
#define C_UCASE 0x40000
#define C_UNBLOCK 0x80000
#define C_OSYNC 0x100000
+#define C_STATUS 0x200000
+#define C_NOXFER 0x400000
+#define C_NOINFO 0x800000
diff --git a/bin/dd/misc.c b/bin/dd/misc.c
index 1a92010d2ac..4ecb518c123 100644
--- a/bin/dd/misc.c
+++ b/bin/dd/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.17 2013/04/16 22:13:43 deraadt Exp $ */
+/* $OpenBSD: misc.c,v 1.18 2014/02/12 01:18:36 bluhm Exp $ */
/* $NetBSD: misc.c,v 1.4 1995/03/21 09:04:10 cgd Exp $ */
/*-
@@ -58,6 +58,9 @@ summary(void)
double microsecs;
int i = 0;
+ if (ddflags & C_NOINFO)
+ return;
+
(void)gettimeofday(&nowtv, (struct timezone *)NULL);
timersub(&nowtv, &st.startv, &nowtv);
microsecs = ((double)nowtv.tv_sec * 1000000) + nowtv.tv_usec;
@@ -85,13 +88,15 @@ summary(void)
iov[i].iov_base = buf[2];
iov[i++].iov_len = strlen(buf[2]);
}
- (void)snprintf(buf[3], sizeof(buf[3]),
- "%qd bytes transferred in %lld.%03ld secs (%0.0f bytes/sec)\n",
- (long long)st.bytes, (long long)nowtv.tv_sec, nowtv.tv_usec / 1000,
- ((double)st.bytes * 1000000) / microsecs);
-
- iov[i].iov_base = buf[3];
- iov[i++].iov_len = strlen(buf[3]);
+ if (!(ddflags & C_NOXFER)) {
+ (void)snprintf(buf[3], sizeof(buf[3]),
+ "%qd bytes transferred in %lld.%03ld secs "
+ "(%0.0f bytes/sec)\n", (long long)st.bytes,
+ (long long)nowtv.tv_sec, nowtv.tv_usec / 1000,
+ ((double)st.bytes * 1000000) / microsecs);
+ iov[i].iov_base = buf[3];
+ iov[i++].iov_len = strlen(buf[3]);
+ }
(void)writev(STDERR_FILENO, iov, i);
}