]> git.wh0rd.org - dump.git/commitdiff
Added the throughput information in dump's progression messages.
authorStelian Pop <stelian@popies.net>
Tue, 5 Dec 2000 16:31:35 +0000 (16:31 +0000)
committerStelian Pop <stelian@popies.net>
Tue, 5 Dec 2000 16:31:35 +0000 (16:31 +0000)
CHANGES
dump/dump.h
dump/optr.c
dump/tape.c

diff --git a/CHANGES b/CHANGES
index f71417fca3b6cc1c7957a28a1a960e1445c830ef..02aa723bf51c7df24506a2f62fd740fb55c387d8 100644 (file)
--- 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 <somlo@cs.colostate.edu> and
        bgjenero <bgjenero@sympatico.ca> for reporting the bug.
 
+5.     Added the throughput information in dump's progression
+       messages.  Thanks to Andreas Dilger <adilger@turbolinux.com> 
+       for the patch.
+
 Changes between versions 0.4b19 and 0.4b20 (released November 10, 2000)
 =======================================================================
 
index e86ff2a0f43777eb5d061593d9a3fbc38a2bd6ca..0db752c24dcb931c49b4d0cfdb56bf7ed6420c5b 100644 (file)
@@ -5,7 +5,7 @@
  *     Stelian Pop <pop@noos.fr>, 1999-2000
  *     Stelian Pop <pop@noos.fr> - AlcĂ´ve <www.alcove.fr>, 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));
index 99d7295cbb04ae5470ffcc5abb47dce027dc5199..0ac0acee6db937e42fc64d112acb68d9786a4727 100644 (file)
@@ -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 <sys/param.h>
@@ -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);
+               }
        }
 }
 
index 545c78fd0c5778dbab784d5b8a7dfc6e89f95c86..c3628ccc0b4a83d31d26d24e7e0bcc72d63021dc 100644 (file)
@@ -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