X-Git-Url: https://git.wh0rd.org/?p=dump.git;a=blobdiff_plain;f=restore%2Frestore.c;h=618380489adf50aebbf160cc07d0f56ac471549f;hp=3d38150590016867e01c0b6eff60d1f5e90aefe3;hb=9d49c83f5624f5cf13b7e27fd1f058b10dad50a3;hpb=109e9e1d1a904627eeae4d519a0f694795b2892c diff --git a/restore/restore.c b/restore/restore.c index 3d38150..6183804 100644 --- a/restore/restore.c +++ b/restore/restore.c @@ -41,15 +41,21 @@ #ifndef lint static const char rcsid[] = - "$Id: restore.c,v 1.12 2000/12/04 15:43:17 stelian Exp $"; + "$Id: restore.c,v 1.20 2001/12/24 15:53:41 stelian Exp $"; #endif /* not lint */ +#include #include #ifdef __linux__ #include #include +#include +#ifdef HAVE_EXT2FS_EXT2_FS_H +#include +#else #include +#endif #include #else /* __linux__ */ #include @@ -72,14 +78,26 @@ static char *keyval __P((int)); * List entries on the tape. */ long -listfile(char *name, ino_t ino, int type) +listfile(char *name, dump_ino_t ino, int type) { long descend = hflag ? GOOD : FAIL; +#ifdef USE_QFA + long tnum; + long tpos; +#endif if (TSTINO(ino, dumpmap) == 0) return (descend); Vprintf(stdout, "%s", type == LEAF ? "leaf" : "dir "); - fprintf(stdout, "%10lu\t%s\n", (unsigned long)ino, name); +#ifdef USE_QFA + if (tapeposflag) { /* add QFA positions to output */ + (void)Inode2Tapepos(ino, &tnum, &tpos, 1); + fprintf(stdout, "%10lu\t%ld\t%ld\t%s\n", (unsigned long)ino, + tnum, tpos, name); + } + else +#endif + fprintf(stdout, "%10lu\t%s\n", (unsigned long)ino, name); return (descend); } @@ -88,7 +106,7 @@ listfile(char *name, ino_t ino, int type) * Request that new entries be extracted. */ long -addfile(char *name, ino_t ino, int type) +addfile(char *name, dump_ino_t ino, int type) { register struct entry *ep, *np; long descend = hflag ? GOOD : FAIL; @@ -134,7 +152,7 @@ addfile(char *name, ino_t ino, int type) */ /* ARGSUSED */ long -deletefile(char *name, ino_t ino, int type) +deletefile(char *name, dump_ino_t ino, int type) { long descend = hflag ? GOOD : FAIL; struct entry *ep; @@ -175,7 +193,7 @@ void removeoldleaves(void) { register struct entry *ep, *nextep; - register ino_t i, mydirino; + register dump_ino_t i, mydirino; Vprintf(stdout, "Mark entries to be removed.\n"); if ((ep = lookupino(WINO))) { @@ -229,7 +247,7 @@ removeoldleaves(void) * Renames are done at the same time. */ long -nodeupdates(char *name, ino_t ino, int type) +nodeupdates(char *name, dump_ino_t ino, int type) { register struct entry *ep, *np, *ip; long descend = GOOD; @@ -483,7 +501,7 @@ nodeupdates(char *name, ino_t ino, int type) * for it, we discard the name knowing that it will be on the * next incremental tape. */ - case NULL: + case 0: if (compare_ignore_not_found) break; fprintf(stderr, "%s: (inode %lu) not found on tape\n", name, (unsigned long)ino); @@ -541,7 +559,7 @@ void findunreflinks(void) { register struct entry *ep, *np; - register ino_t i; + register dump_ino_t i; Vprintf(stdout, "Find unreferenced names.\n"); for (i = ROOTINO; i < maxino; i++) { @@ -632,7 +650,7 @@ void compareleaves(void) { register struct entry *ep; - ino_t first; + dump_ino_t first; long curvol; first = lowerbnd(ROOTINO); @@ -690,6 +708,25 @@ compareleaves(void) curvol = volno; } } + /* + * If we encounter the end of the tape and the next available + * file is not the one which we expect then we have missed one + * or more files. Since we do not request files that were not + * on the tape, the lost files must have been due to a tape + * read error, or a file that was removed while the dump was + * in progress. + */ + first = lowerbnd(first); + while (first < curfile.ino) { + ep = lookupino(first); + if (ep == NULL) + panic("%d: bad first\n", first); + fprintf(stderr, "%s: (inode %lu) not found on tape\n", + myname(ep), (unsigned long)first); + compare_errors = 1; + ep->e_flags &= ~(NEW|EXTRACT); + first = lowerbnd(first); + } } /* @@ -700,7 +737,7 @@ void createleaves(char *symtabfile) { register struct entry *ep; - ino_t first; + dump_ino_t first; long curvol; if (command == 'R') { @@ -724,7 +761,8 @@ createleaves(char *symtabfile) ep = lookupino(first); if (ep == NULL) panic("%d: bad first\n", first); - fprintf(stderr, "%s: not found on tape\n", myname(ep)); + fprintf(stderr, "%s: (inode %lu) not found on tape\n", + myname(ep), (unsigned long)first); ep->e_flags &= ~(NEW|EXTRACT); first = lowerbnd(first); } @@ -769,6 +807,25 @@ createleaves(char *symtabfile) curvol = volno; } } + /* + * If we encounter the end of the tape and the next available + * file is not the one which we expect then we have missed one + * or more files. Since we do not request files that were not + * on the tape, the lost files must have been due to a tape + * read error, or a file that was removed while the dump was + * in progress. + */ + first = lowerbnd(first); + while (first < curfile.ino) { + ep = lookupino(first); + if (ep == NULL) + panic("%d: bad first\n", first); + fprintf(stderr, "%s: (inode %lu) not found on tape\n", + myname(ep), (unsigned long)first); + compare_errors = 1; + ep->e_flags &= ~(NEW|EXTRACT); + first = lowerbnd(first); + } } /* @@ -778,9 +835,13 @@ createleaves(char *symtabfile) void createfiles(void) { - register ino_t first, next, last; + register dump_ino_t first, next, last; register struct entry *ep; long curvol; +#ifdef USE_QFA + long tnum, tpos, curtpos, tmpcnt; + time_t tistart, tiend, titaken; +#endif Vprintf(stdout, "Extract requested files\n"); curfile.action = SKIP; @@ -790,6 +851,9 @@ createfiles(void) first = lowerbnd(ROOTINO); last = upperbnd(maxino - 1); for (;;) { +#ifdef USE_QFA + tmpcnt = 1; +#endif first = lowerbnd(first); last = upperbnd(last); /* @@ -803,7 +867,21 @@ createfiles(void) */ while (curfile.ino > last) { curfile.action = SKIP; - getvol((long)0); + if (!pipein) + getvol((long)0); + if (curfile.ino == maxino) { + next = lowerbnd(next); + while (next < curfile.ino) { + ep = lookupino(next); + if (ep == NULL) + panic("corrupted symbol table\n"); + fprintf(stderr, "%s: (inode %lu) not found on tape\n", + myname(ep), (unsigned long)next); + ep->e_flags &= ~NEW; + next = lowerbnd(next); + } + return; + } skipmaps(); skipdirs(); } @@ -813,13 +891,64 @@ createfiles(void) * or an out of order volume change is encountered */ next = lowerbnd(curfile.ino); +#ifdef USE_QFA + tistart = time(NULL); + if (tapeposflag) { + /* get tape position for inode (position directly) */ + (void)Inode2Tapepos(next, &tnum, &tpos, 1); + if (tpos == 0) + /* get tape position for last available inode + * (position before) */ + (void)Inode2Tapepos(next, &tnum, &tpos, 0); + if (tpos != 0) { + if (tnum != volno) + (void)RequestVol(tnum); + if (GetTapePos(&curtpos) == 0) { + /* curtpos +1000 ???, some drives + * might be too slow */ + if (tpos > curtpos) { +#ifdef DEBUG_QFA + msg("positioning tape %ld from %ld to %ld for inode %10lu ...\n", volno, curtpos, tpos, (unsigned long)next); +#endif + if (GotoTapePos(tpos) == 0) { +#ifdef DEBUG_QFA + if (GetTapePos(&curtpos) == 0) + msg("before resnyc at tape position %ld\n", curtpos); +#endif + (void)ReReadFromTape(); +#ifdef DEBUG_QFA + if (GetTapePos(&curtpos) == 0) + msg("after resync at tape position %ld\n", curtpos); +#endif + } + } + } + } + } +#endif /* USA_QFA */ + do { curvol = volno; - while (next > curfile.ino && volno == curvol) + while (next > curfile.ino && volno == curvol) { +#ifdef USE_QFA + ++tmpcnt; +#endif skipfile(); + } skipmaps(); skipdirs(); } while (volno == curvol + 1); +#ifdef USE_QFA + tiend = time(NULL); + titaken = tiend - tistart; +#ifdef DEBUG_QFA + if (titaken / 60 > 0) + msg("%ld reads took %d:%02d:%02d\n", + tmpcnt, titaken / 3600, + (titaken % 3600) / 60, titaken % 60); +#endif +#endif /* USE_QFA */ + /* * If volume change out of order occurred the * current state must be recalculated @@ -840,7 +969,8 @@ createfiles(void) ep = lookupino(next); if (ep == NULL) panic("corrupted symbol table\n"); - fprintf(stderr, "%s: not found on tape\n", myname(ep)); + fprintf(stderr, "%s: (inode %lu) not found on tape\n", + myname(ep), (unsigned long)next); ep->e_flags &= ~NEW; next = lowerbnd(next); } @@ -867,7 +997,7 @@ void createlinks(void) { register struct entry *np, *ep; - register ino_t i; + register dump_ino_t i; char name[BUFSIZ]; if ((ep = lookupino(WINO))) { @@ -911,7 +1041,7 @@ void checkrestore(void) { register struct entry *ep; - register ino_t i; + register dump_ino_t i; Vprintf(stdout, "Check the symbol table.\n"); for (i = WINO; i < maxino; i++) { @@ -930,7 +1060,7 @@ checkrestore(void) * A paranoid check that things are as they should be. */ long -verifyfile(char *name, ino_t ino, int type) +verifyfile(char *name, dump_ino_t ino, int type) { struct entry *np, *ep; long descend = GOOD;