Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/dd Add "progress=1" switch to show a sign of life by pri...
details: https://anonhg.NetBSD.org/src/rev/309a9a747b57
branches: trunk
changeset: 475021:309a9a747b57
user: hubertf <hubertf%NetBSD.org@localhost>
date: Thu Jul 29 19:03:31 1999 +0000
description:
Add "progress=1" switch to show a sign of life by printing a '.' for
every block written to the output file.
diffstat:
bin/dd/args.c | 27 ++++++++++++++-------------
bin/dd/dd.1 | 9 +++++++--
bin/dd/dd.c | 8 ++++++--
bin/dd/extern.h | 3 ++-
bin/dd/misc.c | 7 +++++--
5 files changed, 34 insertions(+), 20 deletions(-)
diffs (249 lines):
diff -r 3b64c2c00185 -r 309a9a747b57 bin/dd/args.c
--- a/bin/dd/args.c Thu Jul 29 18:25:53 1999 +0000
+++ b/bin/dd/args.c Thu Jul 29 19:03:31 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: args.c,v 1.13 1998/07/28 03:47:15 mycroft Exp $ */
+/* $NetBSD: args.c,v 1.14 1999/07/29 19:03:31 hubertf Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)args.c 8.3 (Berkeley) 4/2/94";
#else
-__RCSID("$NetBSD: args.c,v 1.13 1998/07/28 03:47:15 mycroft Exp $");
+__RCSID("$NetBSD: args.c,v 1.14 1999/07/29 19:03:31 hubertf Exp $");
#endif
#endif /* not lint */
@@ -71,6 +71,7 @@
static void f_of __P((char *));
static void f_seek __P((char *));
static void f_skip __P((char *));
+static void f_progress __P((char *));
static u_long get_bsz __P((char *));
static const struct arg {
@@ -78,6 +79,8 @@
void (*f) __P((char *));
u_int set, noset;
} args[] = {
+ /* the array needs to be sorted by the first column so
+ bsearch() can be used to find commands quickly */
{ "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 },
@@ -87,6 +90,7 @@
{ "if", f_if, C_IF, C_IF },
{ "obs", f_obs, C_OBS, C_BS|C_OBS },
{ "of", f_of, C_OF, C_OF },
+ { "progress", f_progress, 0, 0 },
{ "seek", f_seek, C_SEEK, C_SEEK },
{ "skip", f_skip, C_SKIP, C_SKIP },
};
@@ -188,7 +192,6 @@
c_arg(a, b)
const void *a, *b;
{
-
return (strcmp(((const struct arg *)a)->name,
((const struct arg *)b)->name));
}
@@ -197,7 +200,6 @@
f_bs(arg)
char *arg;
{
-
in.dbsz = out.dbsz = (int)get_bsz(arg);
}
@@ -205,7 +207,6 @@
f_cbs(arg)
char *arg;
{
-
cbsz = (int)get_bsz(arg);
}
@@ -213,7 +214,6 @@
f_count(arg)
char *arg;
{
-
cpy_cnt = (u_int)get_bsz(arg);
if (!cpy_cnt)
terminate(0);
@@ -223,7 +223,6 @@
f_files(arg)
char *arg;
{
-
files_cnt = (int)get_bsz(arg);
}
@@ -231,7 +230,6 @@
f_ibs(arg)
char *arg;
{
-
if (!(ddflags & C_BS))
in.dbsz = (int)get_bsz(arg);
}
@@ -240,7 +238,6 @@
f_if(arg)
char *arg;
{
-
in.name = arg;
}
@@ -248,7 +245,6 @@
f_obs(arg)
char *arg;
{
-
if (!(ddflags & C_BS))
out.dbsz = (int)get_bsz(arg);
}
@@ -257,7 +253,6 @@
f_of(arg)
char *arg;
{
-
out.name = arg;
}
@@ -265,7 +260,6 @@
f_seek(arg)
char *arg;
{
-
out.offset = (u_int)get_bsz(arg);
}
@@ -273,8 +267,15 @@
f_skip(arg)
char *arg;
{
+ in.offset = (u_int)get_bsz(arg);
+}
- in.offset = (u_int)get_bsz(arg);
+static void
+f_progress(arg)
+ char *arg;
+{
+ if (*arg != '0')
+ progress = 1;
}
#ifdef NO_CONV
diff -r 3b64c2c00185 -r 309a9a747b57 bin/dd/dd.1
--- a/bin/dd/dd.1 Thu Jul 29 18:25:53 1999 +0000
+++ b/bin/dd/dd.1 Thu Jul 29 19:03:31 1999 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: dd.1,v 1.7 1998/02/06 05:39:31 perry Exp $
+.\" $NetBSD: dd.1,v 1.8 1999/07/29 19:03:31 hubertf Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -36,7 +36,7 @@
.\"
.\" @(#)dd.1 8.2 (Berkeley) 1/13/94
.\"
-.Dd January 13, 1994
+.Dd July 28, 1999
.Dt DD 1
.Os
.Sh NAME
@@ -137,6 +137,11 @@
For pipes, the correct number of bytes is read.
For all other devices, the correct number of blocks is read without
distinguishing between a partial or complete block being read.
+.It Cm progress= Ns Ar n
+Switch on display of progress if
+.Va n
+is set to ``1'', i.e. a ``.'' is printed for each
+block written to the output file.
.It Xo
.Cm conv=
.Ns Cm value Ns Op \&, Cm value \&...
diff -r 3b64c2c00185 -r 309a9a747b57 bin/dd/dd.c
--- a/bin/dd/dd.c Thu Jul 29 18:25:53 1999 +0000
+++ b/bin/dd/dd.c Thu Jul 29 19:03:31 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dd.c,v 1.12 1998/08/19 01:32:44 thorpej Exp $ */
+/* $NetBSD: dd.c,v 1.13 1999/07/29 19:03:31 hubertf Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -47,7 +47,7 @@
#if 0
static char sccsid[] = "@(#)dd.c 8.5 (Berkeley) 4/2/94";
#else
-__RCSID("$NetBSD: dd.c,v 1.12 1998/08/19 01:32:44 thorpej Exp $");
+__RCSID("$NetBSD: dd.c,v 1.13 1999/07/29 19:03:31 hubertf Exp $");
#endif
#endif /* not lint */
@@ -84,6 +84,7 @@
u_int ddflags; /* conversion options */
u_int cbsz; /* conversion block size */
u_int files_cnt = 1; /* # of files to copy */
+int progress = 0; /* display sign of life */
const u_char *ctab; /* conversion table */
int
@@ -409,4 +410,7 @@
if (out.dbcnt)
(void)memmove(out.db, out.dbp - out.dbcnt, out.dbcnt);
out.dbp = out.db + out.dbcnt;
+
+ if (progress)
+ (void)write(STDERR_FILENO, ".", 1);
}
diff -r 3b64c2c00185 -r 309a9a747b57 bin/dd/extern.h
--- a/bin/dd/extern.h Thu Jul 29 18:25:53 1999 +0000
+++ b/bin/dd/extern.h Thu Jul 29 19:03:31 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.8 1997/07/20 21:58:40 christos Exp $ */
+/* $NetBSD: extern.h,v 1.9 1999/07/29 19:03:31 hubertf Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -62,6 +62,7 @@
extern u_int cbsz;
extern u_int ddflags;
extern u_int files_cnt;
+extern int progress;
extern const u_char *ctab;
extern const u_char a2e_32V[], a2e_POSIX[];
extern const u_char e2a_32V[], e2a_POSIX[];
diff -r 3b64c2c00185 -r 309a9a747b57 bin/dd/misc.c
--- a/bin/dd/misc.c Thu Jul 29 18:25:53 1999 +0000
+++ b/bin/dd/misc.c Thu Jul 29 19:03:31 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: misc.c,v 1.8 1998/07/28 05:31:23 mycroft Exp $ */
+/* $NetBSD: misc.c,v 1.9 1999/07/29 19:03:31 hubertf Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)misc.c 8.3 (Berkeley) 4/2/94";
#else
-__RCSID("$NetBSD: misc.c,v 1.8 1998/07/28 05:31:23 mycroft Exp $");
+__RCSID("$NetBSD: misc.c,v 1.9 1999/07/29 19:03:31 hubertf Exp $");
#endif
#endif /* not lint */
@@ -64,6 +64,9 @@
time_t secs;
char buf[100];
+ if (progress)
+ (void)write(STDERR_FILENO, "\n", 1);
+
(void)time(&secs);
if ((secs -= st.start) == 0)
secs = 1;
Home |
Main Index |
Thread Index |
Old Index