From 1f6ac570e472da745256d98acef337ec721bf483 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Fri, 8 Oct 2004 10:50:40 +0000 Subject: [PATCH] Only print progress statistics once per second. --- sbin/recoverdisk/recoverdisk.c | 25 ++++++++++++++++--------- tools/tools/recoverdisk/recoverdisk.c | 25 ++++++++++++++++--------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/sbin/recoverdisk/recoverdisk.c b/sbin/recoverdisk/recoverdisk.c index 9151c3f19d4e..76d0a0fc420f 100644 --- a/sbin/recoverdisk/recoverdisk.c +++ b/sbin/recoverdisk/recoverdisk.c @@ -11,9 +11,10 @@ #include #include #include +#include #include #include -#include +#include #include #include #include @@ -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); } diff --git a/tools/tools/recoverdisk/recoverdisk.c b/tools/tools/recoverdisk/recoverdisk.c index 9151c3f19d4e..76d0a0fc420f 100644 --- a/tools/tools/recoverdisk/recoverdisk.c +++ b/tools/tools/recoverdisk/recoverdisk.c @@ -11,9 +11,10 @@ #include #include #include +#include #include #include -#include +#include #include #include #include @@ -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); }