Subject: bin/24300: enhance progress=n option in dd(1)
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <apb@cequrux.com>
List: netbsd-bugs
Date: 02/02/2004 13:52:53
>Number: 24300
>Category: bin
>Synopsis: enhance progress=n option in dd(1)
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Mon Feb 02 11:54:01 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator: Alan Barrett
>Release: NetBSD 1.6ZH
>Organization:
not much
>Environment:
System: NetBSD 1.6ZH
>Description:
dd(1) has a "progress=n" option, but at present the only useful values
of n are 0 or 1.
The appended patch allows any positive integer to be used for the value
of the progress option. dd(1) will then print a "." to stderr for every
n blocks written to the output file. (Both full and partial blocks are
counted.)
>How-To-Repeat:
Wish that there was an easy way to say "copy this disk to that disk,
using 64kB blocks, but displaying a progress marker every 1MB".
>Fix:
Index: bin/dd/args.c
===================================================================
--- args.c 17 Jan 2004 20:48:57 -0000 1.25
+++ args.c 31 Jan 2004 11:49:30 -0000
@@ -275,8 +275,7 @@
f_progress(char *arg)
{
- if (*arg != '0')
- progress = 1;
+ progress = strsuftoll("progress blocks", arg, 0, LLONG_MAX);
}
#ifdef NO_CONV
Index: bin/dd/dd.1
===================================================================
--- dd.1 17 Jan 2004 20:48:57 -0000 1.17
+++ dd.1 2 Feb 2004 11:45:24 -0000
@@ -136,11 +136,12 @@
.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=
Index: bin/dd/dd.c
===================================================================
--- dd.c 17 Jan 2004 21:00:16 -0000 1.37
+++ dd.c 2 Feb 2004 11:42:10 -0000
@@ -82,7 +82,7 @@
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 @@
(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);
}
Index: bin/dd/extern.h
===================================================================
--- extern.h 14 Sep 2003 19:20:19 -0000 1.16
+++ extern.h 2 Feb 2004 11:42:24 -0000
@@ -59,7 +59,7 @@
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[];
(end)
>Release-Note:
>Audit-Trail:
>Unformatted: