X-Git-Url: https://git.wh0rd.org/?p=dump.git;a=blobdiff_plain;f=restore%2Frestore.c;h=c96fe6c7f08f1b86c8613ee0feeacce9336c505e;hp=d9561d810fd6ab892d7d4a1d39d4c1b3a76c84c1;hb=9d8b11d7653be6f936234e8e71e003a18c6cdd4d;hpb=e4a8bde40a6d8319d1b28e054e1a419ba3df2363 diff --git a/restore/restore.c b/restore/restore.c index d9561d8..c96fe6c 100644 --- a/restore/restore.c +++ b/restore/restore.c @@ -2,8 +2,8 @@ * Ported to Linux's Second Extended File System as part of the * dump and restore backup suit * Remy Card , 1994-1997 - * Stelian Pop , 1999-2000 - * Stelian Pop - Alcôve , 2000 + * Stelian Pop , 1999-2000 + * Stelian Pop - Alcôve , 2000-2002 */ /* @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: restore.c,v 1.18 2001/06/18 10:58:28 stelian Exp $"; + "$Id: restore.c,v 1.23 2002/01/16 10:53:28 stelian Exp $"; #endif /* not lint */ #include @@ -505,7 +505,7 @@ nodeupdates(char *name, dump_ino_t ino, int type) if (compare_ignore_not_found) break; fprintf(stderr, "%s: (inode %lu) not found on tape\n", name, (unsigned long)ino); - compare_errors = 1; + do_compare_error; break; /* @@ -637,7 +637,7 @@ compare_entry(struct entry *ep, int do_compare) { if ((ep->e_flags & (NEW|EXTRACT)) == 0) { badentry(ep, "unexpected file on tape"); - compare_errors = 1; + do_compare_error; } if (do_compare) (void) comparefile(myname(ep)); ep->e_flags &= ~(NEW|EXTRACT); @@ -669,7 +669,7 @@ compareleaves(void) if (ep == NULL) panic("%d: bad first\n", first); fprintf(stderr, "%s: not found on tape\n", myname(ep)); - compare_errors = 1; + do_compare_error; ep->e_flags &= ~(NEW|EXTRACT); first = lowerbnd(first); } @@ -683,14 +683,14 @@ compareleaves(void) if (first != curfile.ino) { fprintf(stderr, "expected next file %ld, got %lu\n", (long)first, (unsigned long)curfile.ino); - compare_errors = 1; + do_compare_error; skipfile(); goto next; } ep = lookupino(curfile.ino); if (ep == NULL) { panic("unknown file on tape\n"); - compare_errors = 1; + do_compare_error; } compare_entry(ep, 1); for (ep = ep->e_links; ep != NULL; ep = ep->e_links) { @@ -708,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); + do_compare_error; + ep->e_flags &= ~(NEW|EXTRACT); + first = lowerbnd(first); + } } /* @@ -742,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); } @@ -787,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); + do_compare_error; + ep->e_flags &= ~(NEW|EXTRACT); + first = lowerbnd(first); + } } /* @@ -828,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(first); + 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(); } @@ -916,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); }