X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=dump%2Ftape.c;h=116b4a3016e0f9d523f81769c4d0cfbaeca83cb2;hb=ddf54486ce578f63194ea1bd12bb5cbce78ff707;hp=a8affbb70817b8954e000d97bfdecf3368b7ad61;hpb=d1925e0c515fcb4f815d75292566d600fd715ff5;p=dump.git diff --git a/dump/tape.c b/dump/tape.c index a8affbb..116b4a3 100644 --- a/dump/tape.c +++ b/dump/tape.c @@ -37,7 +37,7 @@ #ifndef lint static const char rcsid[] = - "$Id: tape.c,v 1.78 2003/10/26 16:05:47 stelian Exp $"; + "$Id: tape.c,v 1.83 2004/04/21 09:15:08 stelian Exp $"; #endif /* not lint */ #include @@ -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 @@ -1404,7 +1406,7 @@ dump_atomic_write(int fd, const void *buf, size_t count) while ((got = write(fd, buf, need)) > 0 && (need -= got) > 0) (char *)buf += got; } while (got == -1 && errno == EINTR); - return (got < 0 ? got : count - need); + return (got < 0 ? got : (ssize_t)count - need); }