summaryrefslogtreecommitdiffstats
path: root/sbin/restore
diff options
context:
space:
mode:
authoriedowse <iedowse@FreeBSD.org>2002-02-13 12:06:58 +0000
committeriedowse <iedowse@FreeBSD.org>2002-02-13 12:06:58 +0000
commit649891b041c164ebdb7da1e81a7dcbc42b709ea5 (patch)
tree54485245da5504c3d4ce2f501d7578b72ecf886f /sbin/restore
parent3a8afc40394d66c55f70aad6b771649dd7fd91ef (diff)
downloadFreeBSD-src-649891b041c164ebdb7da1e81a7dcbc42b709ea5.zip
FreeBSD-src-649891b041c164ebdb7da1e81a7dcbc42b709ea5.tar.gz
Fix a number of long-standing restore bugs in tape.c, mainly relating
to multi-volume restores: - In findinode(), keep a copy of header->c_type so that we don't exit the do-while loop until we have processed the current header. Exiting too early leaves curfile.ino set to 0, which confuses the logic in createfiles(), so multi-volume restores with the 'x' command don't work if you follow the instructions and supply the tapes in reverse order. This appears to have been broken by CSRG revision 5.33 tape.c (Oct 1992). - The logic in getvol() for deciding how many records to skip after the volume header was confused; sometimes it would skip too few records and sometimes too many, leading to "resync restore" warnings and missing files. Skip to the next header only when the current action is not `USING'. Work around a dump bug that sets c_count incorrectly in the volume header of the first tape. Some of the problems here date back to at least 1991. - Back out revision 1.23. This appeared to avoid warnings about missing files in the 'rN' verification case, but it made the problems with the 'x' command worse by stopping getvol() from even attempting to find the first inode number on the newly inserted tape. The bug it addressed is fixed by correcting the skipping logic as described above. - Save the value of `tpblksread' in case the wrong volume is supplied, because it is incremented each time we read a volume header. We already saved `blksread' for the same reson.
Diffstat (limited to 'sbin/restore')
-rw-r--r--sbin/restore/tape.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/sbin/restore/tape.c b/sbin/restore/tape.c
index cbb93e5..560c437 100644
--- a/sbin/restore/tape.c
+++ b/sbin/restore/tape.c
@@ -297,7 +297,7 @@ void
getvol(nextvol)
long nextvol;
{
- long newvol, savecnt, wantnext, i;
+ long newvol, savecnt, savetpcnt, i;
union u_spcl tmpspcl;
# define tmpbuf tmpspcl.s_spcl
char buf[TP_BSIZE];
@@ -318,16 +318,15 @@ getvol(nextvol)
goto gethdr;
}
savecnt = blksread;
+ savetpcnt = tpblksread;
again:
+ tpblksread = savetpcnt;
if (pipein)
done(1); /* pipes do not get a second chance */
- if (command == 'R' || command == 'r' || curfile.action != SKIP) {
+ if (command == 'R' || command == 'r' || curfile.action != SKIP)
newvol = nextvol;
- wantnext = 1;
- } else {
+ else
newvol = 0;
- wantnext = 0;
- }
while (newvol <= 0) {
if (tapesread == 0) {
fprintf(stderr, "%s%s%s%s%s",
@@ -424,10 +423,16 @@ gethdr:
dprintf(stdout, "read %ld recs, tape starts with %ld\n",
tpblksread, tmpbuf.c_firstrec);
if (tmpbuf.c_type == TS_TAPE && (tmpbuf.c_flags & DR_NEWHEADER)) {
- if (!wantnext) {
+ if (curfile.action != USING) {
tpblksread = tmpbuf.c_firstrec;
- for (i = tmpbuf.c_count; i > 0; i--)
- readtape(buf);
+ /*
+ * XXX Dump incorrectly sets c_count to 1 in the
+ * volume header of the first tape, so ignore
+ * c_count when volno == 1.
+ */
+ if (volno != 1)
+ for (i = tmpbuf.c_count; i > 0; i--)
+ readtape(buf);
} else if (tmpbuf.c_firstrec > 0 &&
tmpbuf.c_firstrec < tpblksread - 1) {
/*
@@ -440,17 +445,11 @@ gethdr:
readtape(buf);
}
}
- if (curfile.action == USING || curfile.action == SKIP) {
+ if (curfile.action == USING) {
if (volno == 1)
panic("active file into volume 1\n");
return;
}
- /*
- * Skip up to the beginning of the next record
- */
- if (tmpbuf.c_type == TS_TAPE && (tmpbuf.c_flags & DR_NEWHEADER))
- for (i = tmpbuf.c_count; i > 0; i--)
- readtape(buf);
(void) gethead(&spcl);
findinode(&spcl);
if (gettingfile) {
@@ -1222,6 +1221,7 @@ findinode(header)
static long skipcnt = 0;
long i;
char buf[TP_BSIZE];
+ int htype;
curfile.name = "<name unknown>";
curfile.action = UNKNOWN;
@@ -1234,7 +1234,8 @@ findinode(header)
_time32_to_time(header->c_date) != dumpdate)
skipcnt++;
}
- switch (header->c_type) {
+ htype = header->c_type;
+ switch (htype) {
case TS_ADDR:
/*
@@ -1274,7 +1275,7 @@ findinode(header)
/* NOTREACHED */
}
- } while (header->c_type == TS_ADDR);
+ } while (htype == TS_ADDR);
if (skipcnt > 0)
fprintf(stderr, "resync restore, skipped %ld blocks\n",
skipcnt);
OpenPOWER on IntegriCloud