summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2004-10-08 10:50:40 +0000
committerphk <phk@FreeBSD.org>2004-10-08 10:50:40 +0000
commitd21b76886c1aea87770916034d1d1248e2485174 (patch)
tree2a847fcffde8341b7b86d2be52d76784cd2c31c4 /sbin
parent9f5083ce90af760631cf197462bebc72c7b3ea75 (diff)
downloadFreeBSD-src-d21b76886c1aea87770916034d1d1248e2485174.zip
FreeBSD-src-d21b76886c1aea87770916034d1d1248e2485174.tar.gz
Only print progress statistics once per second.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/recoverdisk/recoverdisk.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/sbin/recoverdisk/recoverdisk.c b/sbin/recoverdisk/recoverdisk.c
index 9151c3f..76d0a0f 100644
--- a/sbin/recoverdisk/recoverdisk.c
+++ b/sbin/recoverdisk/recoverdisk.c
@@ -11,9 +11,10 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
+#include <err.h>
#include <errno.h>
#include <fcntl.h>
-#include <err.h>
+#include <time.h>
#include <unistd.h>
#include <sys/queue.h>
#include <sys/disk.h>
@@ -55,6 +56,7 @@ main(int argc, const char **argv)
int error;
u_char *buf;
u_int sectorsize;
+ time_t t1, t2;
if (argc < 2)
@@ -85,6 +87,7 @@ main(int argc, const char **argv)
new_lump(0, t, 0);
d = 0;
+ t1 = 0;
for (;;) {
lp = TAILQ_FIRST(&lumps);
if (lp == NULL)
@@ -98,14 +101,18 @@ main(int argc, const char **argv)
i = MEDIUMSIZE;
if (lp->state > 1)
i = sectorsize;
- printf("\r%13jd %7jd %13jd %3d %13jd %13jd %.8f",
- (intmax_t)lp->start,
- (intmax_t)i,
- (intmax_t)lp->len,
- lp->state,
- (intmax_t)d,
- (intmax_t)(t - d),
- (double)d/(double)t);
+ time(&t2);
+ if (t1 != t2 || lp->len < BIGSIZE) {
+ printf("\r%13jd %7jd %13jd %3d %13jd %13jd %.8f",
+ (intmax_t)lp->start,
+ (intmax_t)i,
+ (intmax_t)lp->len,
+ lp->state,
+ (intmax_t)d,
+ (intmax_t)(t - d),
+ (double)d/(double)t);
+ t1 = t2;
+ }
if (i == 0) {
errx(1, "BOGUS i %10jd", (intmax_t)i);
}
OpenPOWER on IntegriCloud