]> git.wh0rd.org - dump.git/blobdiff - dump/tape.c
LFS compatibility.
[dump.git] / dump / tape.c
index 851a5cdc5204375bac819394cfd9f894fbe7014b..16328bd0a313ca691400985edf414bd888776104 100644 (file)
@@ -2,7 +2,8 @@
  *     Ported to Linux's Second Extended File System as part of the
  *     dump and restore backup suit
  *     Remy Card <card@Linux.EU.Org>, 1994-1997
- *     Stelian Pop <pop@cybercable.fr>, 1999-2000
+ *     Stelian Pop <pop@noos.fr>, 1999-2000
+ *     Stelian Pop <pop@noos.fr> - AlcĂ´ve <www.alcove.fr>, 2000
  */
 
 /*-
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: tape.c,v 1.21 2000/08/19 22:06:03 stelian Exp $";
+       "$Id: tape.c,v 1.27 2000/12/21 11:14:54 stelian Exp $";
 #endif /* not lint */
 
+#include <config.h>
 #ifdef __linux__
 #include <sys/types.h>
 #include <linux/types.h>
@@ -294,36 +296,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
@@ -895,9 +910,8 @@ enslave(void)
        master = getpid();
 
     {  struct sigaction sa;
-       sa.sa_sigaction = NULL;
+       memset(&sa, 0, sizeof sa);
        sigemptyset(&sa.sa_mask);
-       sa.sa_flags = 0;
        sa.sa_handler = dumpabort;
        sigaction(SIGTERM, &sa, NULL); /* Slave sends SIGTERM on dumpabort() */
        sa.sa_handler = sigpipe;