From 88f15c1b41e4c494b7903d6102678e6163ce3118 Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Tue, 5 Dec 2000 16:31:35 +0000 Subject: [PATCH] Added the throughput information in dump's progression messages. --- CHANGES | 6 +++++- dump/dump.h | 3 ++- dump/optr.c | 20 ++++++++------------ dump/tape.c | 45 +++++++++++++++++++++++++++++---------------- 4 files changed, 44 insertions(+), 30 deletions(-) diff --git a/CHANGES b/CHANGES index f71417f..02aa723 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -$Id: CHANGES,v 1.95 2000/12/05 15:43:48 stelian Exp $ +$Id: CHANGES,v 1.96 2000/12/05 16:31:35 stelian Exp $ Changes between versions 0.4b20 and 0.4b21 (released ?????????????????) ======================================================================= @@ -22,6 +22,10 @@ Changes between versions 0.4b20 and 0.4b21 (released ?????????????????) Thanks to Gabriel Somlo and bgjenero for reporting the bug. +5. Added the throughput information in dump's progression + messages. Thanks to Andreas Dilger + for the patch. + Changes between versions 0.4b19 and 0.4b20 (released November 10, 2000) ======================================================================= diff --git a/dump/dump.h b/dump/dump.h index e86ff2a..0db752c 100644 --- a/dump/dump.h +++ b/dump/dump.h @@ -5,7 +5,7 @@ * Stelian Pop , 1999-2000 * Stelian Pop - AlcĂ´ve , 2000 * - * $Id: dump.h,v 1.16 2000/12/04 15:43:16 stelian Exp $ + * $Id: dump.h,v 1.17 2000/12/05 16:31:36 stelian Exp $ */ /*- @@ -147,6 +147,7 @@ void dumpblock __P((daddr_t blkno, int size)); void startnewtape __P((int top)); time_t trewind __P((void)); void writerec __P((const void *dp, int isspcl)); +char *mktimeest __P((time_t tnow)); void Exit __P((int status)); void dumpabort __P((int signo)); diff --git a/dump/optr.c b/dump/optr.c index 99d7295..0ac0ace 100644 --- a/dump/optr.c +++ b/dump/optr.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: optr.c,v 1.16 2000/12/04 15:43:16 stelian Exp $"; + "$Id: optr.c,v 1.17 2000/12/05 16:31:36 stelian Exp $"; #endif /* not lint */ #include @@ -322,7 +322,7 @@ time_t tschedule = 0; void timeest(void) { - time_t tnow, deltat; + time_t tnow; #ifdef __linux__ (void) time4(&tnow); @@ -330,17 +330,13 @@ timeest(void) (void) time((time_t *) &tnow); #endif if (tnow >= tschedule) { + char *buf = mktimeest(tnow); tschedule = tnow + 300; - if (blockswritten < 500) - return; - if (blockswritten > tapesize) - tapesize = blockswritten; - deltat = tstart_writing - tnow + - (1.0 * (tnow - tstart_writing)) - / blockswritten * tapesize; - msg("%3.2f%% done, finished in %d:%02d\n", - (blockswritten * 100.0) / tapesize, - deltat / 3600, (deltat % 3600) / 60); + if (buf) { + fprintf(stderr, " DUMP: "); + fwrite(buf, strlen(buf), 1, stderr); + fflush(stderr); + } } } diff --git a/dump/tape.c b/dump/tape.c index 545c78f..c3628cc 100644 --- a/dump/tape.c +++ b/dump/tape.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: tape.c,v 1.25 2000/12/04 15:43:16 stelian Exp $"; + "$Id: tape.c,v 1.26 2000/12/05 16:31:36 stelian Exp $"; #endif /* not lint */ #ifdef __linux__ @@ -295,36 +295,49 @@ do_stats(void) return(tnow); } +char * +mktimeest(time_t tnow) +{ + static char msgbuf[128]; + time_t deltat; + + msgbuf[0] = '\0'; + + if (blockswritten < 500) + return NULL; + if (blockswritten > tapesize) + tapesize = blockswritten; + deltat = tstart_writing - tnow + (1.0 * (tnow - tstart_writing)) + / blockswritten * tapesize; + (void)snprintf(msgbuf, sizeof(msgbuf), + "%3.2f%% done at %ld KB/s, finished in %d:%02d\n", + (blockswritten * 100.0) / tapesize, + (spcl.c_tapea - tapea_volume) / (tnow - tstart_volume), + (int)(deltat / 3600), (int)((deltat % 3600) / 60)); + + return msgbuf; +} + #if defined(SIGINFO) /* * statussig -- * information message upon receipt of SIGINFO - * (derived from optr.c::timeest()) */ void statussig(int notused) { - time_t tnow, deltat; - char msgbuf[128]; + time_t tnow; int save_errno = errno; + char *buf; - if (blockswritten < 500) - return; #ifdef __linux__ (void) time4(&tnow); #else (void) time((time_t *) &tnow); #endif - if (blockswritten > tapesize) - tapesize = blockswritten; - deltat = tstart_writing - tnow + (1.0 * (tnow - tstart_writing)) - / blockswritten * tapesize; - (void)snprintf(msgbuf, sizeof(msgbuf), - "%3.2f%% done at %ld KB/s, finished in %d:%02d\n", - (blockswritten * 100.0) / tapesize, - (spcl.c_tapea - tapea_volume) / (tnow - tstart_volume), - (int)(deltat / 3600), (int)((deltat % 3600) / 60)); - write(STDERR_FILENO, msgbuf, strlen(msgbuf)); + buf = mktimeest(tnow); + if (buf) + write(STDERR_FILENO, buf, strlen(buf)); errno = save_errno; } #endif -- 2.39.5