From e7850aac218f2c009303b0a65903c54157139d0c Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Wed, 18 Jul 2001 09:50:48 +0000 Subject: [PATCH] -B option knows about compression length now. --- CHANGES | 7 ++++++- THANKS | 3 ++- dump/dump.8.in | 7 +++++-- dump/dump.h | 4 +++- dump/main.c | 13 +++++++++---- dump/tape.c | 29 +++++++++++++++++++++-------- 6 files changed, 46 insertions(+), 17 deletions(-) diff --git a/CHANGES b/CHANGES index 94821f4..a46e316 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -$Id: CHANGES,v 1.119 2001/07/18 08:50:58 stelian Exp $ +$Id: CHANGES,v 1.120 2001/07/18 09:50:48 stelian Exp $ Changes between versions 0.4b22 and 0.4b23 (released ????????????) ================================================================== @@ -21,6 +21,11 @@ Changes between versions 0.4b22 and 0.4b23 (released ????????????) 5. Fixed the looping problem in dump introduced in the previous version. +6. Changed the -B option of dump to limit the size of + _compressed_ output per volume if compression is on. + Patch contributed by Helmut Jarausch + . + Changes between versions 0.4b21 and 0.4b22 (released May 12, 2001) ================================================================== diff --git a/THANKS b/THANKS index f5fc5bc..80e2063 100644 --- a/THANKS +++ b/THANKS @@ -1,4 +1,4 @@ -$Id: THANKS,v 1.45 2001/05/26 11:11:16 stelian Exp $ +$Id: THANKS,v 1.46 2001/07/18 09:50:48 stelian Exp $ Dump and restore were written by the people of the CSRG at the University of California, Berkeley. @@ -41,6 +41,7 @@ Ian Gordon iangordon@users.sourceforge.net Andreas Hasenack andreas@conectiva.com.br Christian Haul haul@informatik.tu-darmstadt.de Jean-Paul van der Jagt jeanpaul@dutepp0.et.tudelft.nl +Helmut Jarausch jarausch@igpm.rwth-aachen.de Eric Jergensen eric@dvns.com Jeff Johnson jbj@redhat.com Charles Karney karney@users.sourceforge.net diff --git a/dump/dump.8.in b/dump/dump.8.in index 5d16fc7..21761d5 100644 --- a/dump/dump.8.in +++ b/dump/dump.8.in @@ -30,7 +30,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: dump.8.in,v 1.26 2001/04/10 13:42:22 stelian Exp $ +.\" $Id: dump.8.in,v 1.27 2001/07/18 09:50:48 stelian Exp $ .\" .Dd __DATE__ .Dt DUMP 8 @@ -117,7 +117,8 @@ The default level is 9. .It Fl B Ar records The number of 1 kB blocks per volume. This option overrides the end-of-media detection, and calculation -of tape size based on length and density. +of tape size based on length and density. If compression is on this +limits the size of the compressed output per volume. .It Fl a .Dq auto-size . Bypass all tape length calculations, and write @@ -483,6 +484,8 @@ Each reel requires a new process, so parent processes for reels already written just hang around until the entire tape is written. .Pp +The estimated number of tapes is not correct if compression is on. +.Pp It would be nice if .Nm knew about the dump sequence, diff --git a/dump/dump.h b/dump/dump.h index b43beb7..2a6020c 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.24 2001/04/10 13:42:22 stelian Exp $ + * $Id: dump.h,v 1.25 2001/07/18 09:50:48 stelian Exp $ */ /*- @@ -79,12 +79,14 @@ char *eot_script; /* end of volume script fiag */ int diskfd; /* disk file descriptor */ int tapefd; /* tape file descriptor */ int pipeout; /* true => output to standard output */ +int fifoout; /* true => output to fifo */ dump_ino_t curino; /* current inumber; used globally */ int newtape; /* new tape flag */ int density; /* density in 0.1" units */ long tapesize; /* estimated tape size, blocks */ long tsize; /* tape size in 0.1" units */ long asize; /* number of 0.1" units written on current tape */ +unsigned long csize; /* number of compressed bytes written on current tape */ int etapes; /* estimated number of tapes */ int nonodump; /* if set, do not honor UF_NODUMP user flags */ int unlimited; /* if set, write to end of medium */ diff --git a/dump/main.c b/dump/main.c index 15d00f3..5953f39 100644 --- a/dump/main.c +++ b/dump/main.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: main.c,v 1.50 2001/07/18 09:12:05 stelian Exp $"; + "$Id: main.c,v 1.51 2001/07/18 09:50:48 stelian Exp $"; #endif /* not lint */ #include @@ -353,7 +353,7 @@ main(int argc, char *argv[]) tapeprefix = "standard output"; } - if (blocksperfile) + if (blocksperfile && !compressed) blocksperfile = blocksperfile / ntrec * ntrec; /* round down */ else if (!unlimited) { /* @@ -519,6 +519,11 @@ main(int argc, char *argv[]) strncpy(tape, tapeprefix, MAXPATHLEN); tape[MAXPATHLEN - 1] = '\0'; + if (!pipeout) { + if (STAT(tape, &statbuf) != -1) + fifoout= statbuf.st_mode & S_IFIFO; + } + if (!sizest) { msg("Date of this level %c dump: %s", level, @@ -820,7 +825,7 @@ main(int argc, char *argv[]) tnow = trewind(); - if (pipeout) + if (pipeout || fifoout) msg("%ld tape blocks (%.2fMB)\n", spcl.c_tapea, ((double)spcl.c_tapea * TP_BSIZE / 1048576)); else @@ -923,7 +928,7 @@ sig(int signo) case SIGHUP: case SIGTERM: case SIGTRAP: - if (pipeout) + if (pipeout || fifoout) quit("Signal on pipe: cannot recover\n"); msg("Rewriting attempted as response to unknown signal: %d.\n", signo); (void)fflush(stderr); diff --git a/dump/tape.c b/dump/tape.c index 25d7c50..984fe07 100644 --- a/dump/tape.c +++ b/dump/tape.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: tape.c,v 1.48 2001/07/18 09:12:05 stelian Exp $"; + "$Id: tape.c,v 1.49 2001/07/18 09:50:48 stelian Exp $"; #endif /* not lint */ #include @@ -443,12 +443,21 @@ flushtape(void) nextblock = slp->tblock; trecno = 0; asize += tenths + returned.clen / density; + csize += returned.clen; blockswritten += ntrec; blocksthisvol += ntrec; - if (!pipeout && !unlimited && (blocksperfile ? - (blocksthisvol >= blocksperfile) : (asize > tsize))) { - close_rewind(); - startnewtape(0); + if (!pipeout && !unlimited) { + if (blocksperfile) { + if ( compressed ? csize >= blocksperfile * 1024 + : blocksthisvol >= blocksperfile ) { + close_rewind(); + startnewtape(0); + } + } + else if (asize > tsize) { + close_rewind(); + startnewtape(0); + } } timeest(); } @@ -552,9 +561,11 @@ trewind(void) #endif { (void) close(tapefd); - while ((f = OPEN(tape, 0)) < 0) - sleep (10); - (void) close(f); + if (!fifoout) { + while ((f = OPEN(tape, 0)) < 0) + sleep (10); + (void) close(f); + } } eot_code = 1; if (eot_script && spcl.c_type != TS_END) { @@ -724,6 +735,7 @@ rollforward(void) slp->count = lastspclrec + blks + 1 - spcl.c_tapea; slp->inode = curino; asize += tenths + returned.clen / density; + csize += returned.clen; blockswritten += ntrec; blocksthisvol += ntrec; #endif @@ -880,6 +892,7 @@ restore_check_point: enslave(); /* Share open tape file descriptor with slaves */ asize = 0; + csize = 0; blocksthisvol = 0; if (top) newtape++; /* new tape signal */ -- 2.39.5