From b7d86f5e4cb7d420793e1bc98bf6e15b7d00f190 Mon Sep 17 00:00:00 2001 From: apb Date: Mon, 9 Jan 2006 10:17:05 +0000 Subject: [PATCH] In "dd progress=N", let the value of N control how often to print a "." to stderr. Previously, any non-zero value behaved like "progress=1". PR 24300 Approved by christos --- bin/dd/args.c | 7 +++---- bin/dd/dd.1 | 11 ++++++----- bin/dd/dd.c | 8 ++++---- bin/dd/extern.h | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/bin/dd/args.c b/bin/dd/args.c index 4ce5981eee1e..03abb6391623 100644 --- a/bin/dd/args.c +++ b/bin/dd/args.c @@ -1,4 +1,4 @@ -/* $NetBSD: args.c,v 1.25 2004/01/17 20:48:57 dbj Exp $ */ +/* $NetBSD: args.c,v 1.26 2006/01/09 10:17:05 apb Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)args.c 8.3 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: args.c,v 1.25 2004/01/17 20:48:57 dbj Exp $"); +__RCSID("$NetBSD: args.c,v 1.26 2006/01/09 10:17:05 apb Exp $"); #endif #endif /* not lint */ @@ -275,8 +275,7 @@ static void f_progress(char *arg) { - if (*arg != '0') - progress = 1; + progress = strsuftoll("progress blocks", arg, 0, LLONG_MAX); } #ifdef NO_CONV diff --git a/bin/dd/dd.1 b/bin/dd/dd.1 index 74d823b0b7d8..5dd940fa96cd 100644 --- a/bin/dd/dd.1 +++ b/bin/dd/dd.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: dd.1,v 1.18 2004/02/13 17:56:17 wiz Exp $ +.\" $NetBSD: dd.1,v 1.19 2006/01/09 10:17:05 apb Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -136,11 +136,12 @@ 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 -.Dq 1 , -i.e. a +is set to any non-zero value. +This will cause a .Dq \&. -is printed for each block written to the output file. +to be printed (to the standard error output) for every +.Va n +full or partial blocks written to the output file. .It Xo .Sm off .Cm conv= diff --git a/bin/dd/dd.c b/bin/dd/dd.c index 1580af138746..974a05f8ffa8 100644 --- a/bin/dd/dd.c +++ b/bin/dd/dd.c @@ -1,4 +1,4 @@ -/* $NetBSD: dd.c,v 1.38 2005/04/20 17:38:59 rillig Exp $ */ +/* $NetBSD: dd.c,v 1.39 2006/01/09 10:17:05 apb Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -43,7 +43,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.38 2005/04/20 17:38:59 rillig Exp $"); +__RCSID("$NetBSD: dd.c,v 1.39 2006/01/09 10:17:05 apb Exp $"); #endif #endif /* not lint */ @@ -82,7 +82,7 @@ static off_t pending = 0; /* pending seek if sparse */ u_int ddflags; /* conversion options */ uint64_t cbsz; /* conversion block size */ u_int files_cnt = 1; /* # of files to copy */ -int progress = 0; /* display sign of life */ +uint64_t progress = 0; /* display sign of life */ const u_char *ctab; /* conversion table */ sigset_t infoset; /* a set blocking SIGINFO */ @@ -533,7 +533,7 @@ dd_out(int force) (void)memmove(out.db, out.dbp - out.dbcnt, out.dbcnt); out.dbp = out.db + out.dbcnt; - if (progress) + if (progress && (st.out_full + st.out_part) % progress == 0) (void)write(STDERR_FILENO, ".", 1); } diff --git a/bin/dd/extern.h b/bin/dd/extern.h index 9cc2cea29ad9..26871019edb8 100644 --- a/bin/dd/extern.h +++ b/bin/dd/extern.h @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.16 2003/09/14 19:20:19 jschauma Exp $ */ +/* $NetBSD: extern.h,v 1.17 2006/01/09 10:17:05 apb Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -59,7 +59,7 @@ extern uint64_t cpy_cnt; extern uint64_t cbsz; extern u_int ddflags; extern u_int files_cnt; -extern int progress; +extern uint64_t progress; extern const u_char *ctab; extern const u_char a2e_32V[], a2e_POSIX[]; extern const u_char e2a_32V[], e2a_POSIX[];