]> git.wh0rd.org - dump.git/blobdiff - dump/tape.c
Fix some compile warnings.
[dump.git] / dump / tape.c
index f55334b1206af6c8f2468449bbc23c7be6a8099b..116b4a3016e0f9d523f81769c4d0cfbaeca83cb2 100644 (file)
@@ -37,7 +37,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: tape.c,v 1.79 2003/11/22 16:52:16 stelian Exp $";
+       "$Id: tape.c,v 1.83 2004/04/21 09:15:08 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
@@ -105,7 +105,8 @@ int    write(), read();
 int    writesize;              /* size of malloc()ed buffer for tape */
 long   lastspclrec = -1;       /* tape block number of last written header */
 int    trecno = 0;             /* next record to write in current block */
-extern long blocksperfile;     /* number of blocks per output file */
+extern long *blocksperfiles;   /* number of blocks per output file(s) */
+long   blocksperfiles_current; /* current position in blocksperfiles */
 long   blocksthisvol;          /* number of blocks on current output file */
 extern int ntrec;              /* blocking factor on tape */
 extern int cartridge;
@@ -197,7 +198,7 @@ alloctape(void)
         * repositioning after stopping, i.e, streaming mode, where the gap is
         * variable, 0.30" to 0.45".  The gap is maximal when the tape stops.
         */
-       if (blocksperfile == 0 && !unlimited)
+       if (!blocksperfiles && !unlimited)
                tenths = (cartridge ? 16 : density == 625 ? 5 : 8);
        else {
                tenths = 0;
@@ -484,9 +485,9 @@ flushtape(void)
        blockswritten += ntrec;
        blocksthisvol += ntrec;
        if (!pipeout && !unlimited) {
-               if (blocksperfile) {
-                       if ( compressed ? (bytes_written - tapea_bytes + SLAVES * (writesize + sizeof(struct tapebuf))) >= (((long long)blocksperfile) * 1024)
-                                       : blocksthisvol >= blocksperfile ) {
+               if (blocksperfiles && blocksperfiles[blocksperfiles_current]) {
+                       if ( compressed ? (bytes_written - tapea_bytes + SLAVES * (writesize + sizeof(struct tapebuf))) >= (((long long)blocksperfiles[blocksperfiles_current]) * 1024)
+                                       : blocksthisvol >= blocksperfiles[blocksperfiles_current] ) {
                                close_rewind();
                                startnewtape(0);
                        }
@@ -572,8 +573,6 @@ close_rewind(void)
 {
        int eot_code = 1;
        (void)trewind();
-       if (nexttape || Mflag)
-               return;
        if (eot_script) {
                msg("Launching %s\n", eot_script);
                eot_code = system_command(eot_script, tape, tapeno);
@@ -584,6 +583,8 @@ close_rewind(void)
        }
        if (eot_code == 0)
                return;
+       if (nexttape || Mflag)
+               return;
        if (!nogripe) {
                msg("Change Volumes: Mount volume #%d\n", tapeno+1);
                broadcast("CHANGE DUMP VOLUMES!\7\7\n");
@@ -871,6 +872,8 @@ restore_check_point:
                        tape[MAXPATHLEN - 1] = '\0';
                        msg("Dumping volume %d on %s\n", tapeno, tape);
                }
+               if (blocksperfiles && blocksperfiles_current < *blocksperfiles)
+                       blocksperfiles_current++;
 #ifdef RDUMP
                while ((tapefd = (host ? rmtopen(tape, O_WRONLY|O_CREAT|O_TRUNC) : pipeout ? 
                        fileno(stdout) : 
@@ -1084,9 +1087,6 @@ doslave(int cmd,
        int compresult;
        volatile int do_compress = !first;
        unsigned long worklen;
-#ifdef HAVE_BZLIB
-       unsigned int worklen2;
-#endif
 #ifdef HAVE_LZO
        lzo_align_t __LZO_MMODEL *LZO_WorkMem;
 #endif
@@ -1223,7 +1223,7 @@ doslave(int cmd,
 #endif /* HAVE_ZLIB */
 #ifdef HAVE_BZLIB
                        if (zipflag == COMPRESS_BZLIB) {
-                               worklen2 = worklen;
+                               unsigned int worklen2 = worklen;
                                compresult = BZ2_bzBuffToBuffCompress(
                                                       comp_buf->buf,
                                                       &worklen2,
@@ -1241,10 +1241,12 @@ doslave(int cmd,
 #endif /* HAVE_BZLIB */
 #ifdef HAVE_LZO
                        if (zipflag == COMPRESS_LZO) {
+                               lzo_uint worklen2 = worklen;
                                compresult = lzo1x_1_compress((char *)slp->tblock[0],writesize,
                                                               comp_buf->buf,
-                                                             (lzo_uintp)&worklen,
+                                                             &worklen2,
                                                               LZO_WorkMem);
+                               worklen = worklen2;
                                if (compresult == LZO_E_OK)
                                        compresult = 1;
                                else