X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=dump%2Ftape.c;h=16328bd0a313ca691400985edf414bd888776104;hb=d6967896bc4e18f9b4359a2ef5be5c0f1bcc456a;hp=c1046674682714d459d00a25574d494fda3f9208;hpb=d8574d458324cdde27484485cb09e7c9b8fa1a77;p=dump.git diff --git a/dump/tape.c b/dump/tape.c index c104667..16328bd 100644 --- a/dump/tape.c +++ b/dump/tape.c @@ -2,7 +2,8 @@ * Ported to Linux's Second Extended File System as part of the * dump and restore backup suit * Remy Card , 1994-1997 - * Stelian Pop , 1999-2000 + * Stelian Pop , 1999-2000 + * Stelian Pop - AlcĂ´ve , 2000 */ /*- @@ -40,9 +41,10 @@ #ifndef lint static const char rcsid[] = - "$Id: tape.c,v 1.20 2000/06/01 18:30:08 stelian Exp $"; + "$Id: tape.c,v 1.27 2000/12/21 11:14:54 stelian Exp $"; #endif /* not lint */ +#include #ifdef __linux__ #include #include @@ -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 @@ -877,9 +892,9 @@ Exit(int status) static void proceed(int signo) { - caught++; if (ready) siglongjmp(jmpbuf, 1); + caught++; } void @@ -895,6 +910,8 @@ enslave(void) master = getpid(); { struct sigaction sa; + memset(&sa, 0, sizeof sa); + sigemptyset(&sa.sa_mask); sa.sa_handler = dumpabort; sigaction(SIGTERM, &sa, NULL); /* Slave sends SIGTERM on dumpabort() */ sa.sa_handler = sigpipe; @@ -1081,6 +1098,7 @@ doslave(int cmd, int slave_number) if (wrote < 0) { (void) kill(master, SIGUSR1); sigemptyset(&sigset); + sigaddset(&sigset, SIGINT); for (;;) sigsuspend(&sigset); } else {