Add "progress=1" switch to show a sign of life by printing a '.' for

every block written to the output file.
This commit is contained in:
hubertf 1999-07-29 19:03:31 +00:00
parent 265b6769d5
commit 4d486ab67d
5 changed files with 34 additions and 20 deletions

View File

@ -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_obs __P((char *));
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 @@ static const struct arg {
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 @@ static const struct arg {
{ "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 @@ static int
c_arg(a, b)
const void *a, *b;
{
return (strcmp(((const struct arg *)a)->name,
((const struct arg *)b)->name));
}
@ -197,7 +200,6 @@ static void
f_bs(arg)
char *arg;
{
in.dbsz = out.dbsz = (int)get_bsz(arg);
}
@ -205,7 +207,6 @@ static void
f_cbs(arg)
char *arg;
{
cbsz = (int)get_bsz(arg);
}
@ -213,7 +214,6 @@ static void
f_count(arg)
char *arg;
{
cpy_cnt = (u_int)get_bsz(arg);
if (!cpy_cnt)
terminate(0);
@ -223,7 +223,6 @@ static void
f_files(arg)
char *arg;
{
files_cnt = (int)get_bsz(arg);
}
@ -231,7 +230,6 @@ static void
f_ibs(arg)
char *arg;
{
if (!(ddflags & C_BS))
in.dbsz = (int)get_bsz(arg);
}
@ -240,7 +238,6 @@ static void
f_if(arg)
char *arg;
{
in.name = arg;
}
@ -248,7 +245,6 @@ static void
f_obs(arg)
char *arg;
{
if (!(ddflags & C_BS))
out.dbsz = (int)get_bsz(arg);
}
@ -257,7 +253,6 @@ static void
f_of(arg)
char *arg;
{
out.name = arg;
}
@ -265,7 +260,6 @@ static void
f_seek(arg)
char *arg;
{
out.offset = (u_int)get_bsz(arg);
}
@ -273,10 +267,17 @@ static void
f_skip(arg)
char *arg;
{
in.offset = (u_int)get_bsz(arg);
}
static void
f_progress(arg)
char *arg;
{
if (*arg != '0')
progress = 1;
}
#ifdef NO_CONV
/* Build a small version (i.e. for a ramdisk root) */
static void

View File

@ -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 @@ Otherwise, input data is read and discarded.
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 \&...

View File

@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 1993, 1994\n\
#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_long cpy_cnt; /* # of blocks to copy */
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 @@ dd_out(force)
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);
}

View File

@ -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_long cpy_cnt;
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[];

View File

@ -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 @@ summary()
time_t secs;
char buf[100];
if (progress)
(void)write(STDERR_FILENO, "\n", 1);
(void)time(&secs);
if ((secs -= st.start) == 0)
secs = 1;