]> git.wh0rd.org - dump.git/blobdiff - restore/restore.c
Fix errors when trying to restore files not found on tape.
[dump.git] / restore / restore.c
index c0e6b328fa0e1e46f0da72e7b1952e10bc8133fc..f0118f26b01940dc901fee6a925b137232d05cad 100644 (file)
@@ -41,7 +41,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: restore.c,v 1.16 2001/04/12 13:14:15 stelian Exp $";
+       "$Id: restore.c,v 1.19 2001/12/24 12:31:12 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
@@ -51,7 +51,11 @@ static const char rcsid[] =
 #include <sys/param.h>
 #include <sys/time.h>
 #include <time.h>
+#ifdef HAVE_EXT2FS_EXT2_FS_H
+#include <ext2fs/ext2_fs.h>
+#else
 #include <linux/ext2_fs.h>
+#endif
 #include <bsdcompat.h>
 #else  /* __linux__ */
 #include <ufs/ufs/dinode.h>
@@ -497,7 +501,7 @@ nodeupdates(char *name, dump_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);
@@ -704,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);
+       }
 }
 
 /*
@@ -738,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);
                }
@@ -783,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);
+       }
 }
 
 /*
@@ -825,6 +868,19 @@ createfiles(void)
                while (curfile.ino > last) {
                        curfile.action = SKIP;
                        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();
                }
@@ -912,7 +968,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);
                }