X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=restore%2Ftape.c;h=e5e995d71bfe9fbe7d98521a3b8744efea60f7c2;hb=871ede100ce41d967ebbb4e2d67c6b7587e16f76;hp=f46ac48a1f5ea0a9f60efd916fb66ae4a661f546;hpb=2c99ad2dc97978b437794b14d58d9ae698ecabb9;p=dump.git diff --git a/restore/tape.c b/restore/tape.c index f46ac48..e5e995d 100644 --- a/restore/tape.c +++ b/restore/tape.c @@ -46,7 +46,7 @@ #ifndef lint static const char rcsid[] = - "$Id: tape.c,v 1.34 2001/04/12 16:03:30 stelian Exp $"; + "$Id: tape.c,v 1.36 2001/04/27 12:23:23 stelian Exp $"; #endif /* not lint */ #include @@ -274,7 +274,12 @@ setup(void) magtapein = rmtioctl(MTNOP, 1) != -1; else #endif - magtapein = ioctl(mt, MTIOCGET, (char *) &mt_stat) == 0; + if (ioctl(mt, MTIOCGET, (char *) &mt_stat) == 0) { + if (mt_stat.mt_dsreg & 0xffff) + magtapein = 1; /* fixed blocksize */ + else + magtapein = 2; /* variable blocksize */ + } } Vprintf(stdout,"Input is from %s\n", magtapein? "tape": "file/pipe"); @@ -1325,8 +1330,6 @@ readtape(char *buf) if (numtrec == 0) numtrec = ntrec; cnt = ntrec * TP_BSIZE; - if (zflag) - cnt += PREFIXSIZE; rd = 0; getmore: #ifdef RRESTORE @@ -1639,12 +1642,9 @@ decompress_tapebuf(struct tapebuf *tpbin, int readsize) } switch (cresult) { case Z_OK: - if (worklen != ntrec * TP_BSIZE) { - /* short block, shouldn't happen, but... */ + numtrec = worklen / TP_BSIZE; + if (worklen % TP_BSIZE != 0) reason = "length mismatch"; - if (worklen % TP_BSIZE == 0) - numtrec = worklen / TP_BSIZE; - } break; case Z_MEM_ERROR: reason = "not enough memory"; @@ -1719,7 +1719,12 @@ findtapeblksize(void) * For a pipe or file, read in the first record. For a tape, read * the first block. */ - len = magtapein ? bufsize + PREFIXSIZE: TP_BSIZE; + if (magtapein == 1) /* fixed blocksize tape, not compressed */ + len = ntrec * TP_BSIZE; + else if (magtapein == 2)/* variable blocksize tape */ + len = bufsize + PREFIXSIZE; + else /* not mag tape */ + len = TP_BSIZE; if (read_a_block(mt, tapebuf, len, &i) <= 0) errx(1, "Tape read error on first record"); @@ -1761,11 +1766,12 @@ findtapeblksize(void) } /* - * If the input is a tape, we tried to read PREFIXSIZE + - * ntrec * TP_BSIZE bytes. If it's not a compressed dump tape - * or the value of ntrec is too large, we have read less than - * what we asked for; adjust the value of ntrec and test for - * a compressed dump tape prefix. + * If the input is a variable block size tape, we tried to + * read PREFIXSIZE + ntrec * TP_BSIZE bytes. + * If it's not a compressed dump tape or the value of ntrec is + * too large, we have read less than * what we asked for; + * adjust the value of ntrec and test for * a compressed dump + * tape prefix. */ if (i % TP_BSIZE != 0) {