]> git.wh0rd.org - dump.git/commitdiff
Added -L option to restore
authorStelian Pop <stelian@popies.net>
Fri, 11 Jan 2002 08:54:12 +0000 (08:54 +0000)
committerStelian Pop <stelian@popies.net>
Fri, 11 Jan 2002 08:54:12 +0000 (08:54 +0000)
-N restore option man page entry

CHANGES
restore/main.c
restore/restore.8.in
restore/restore.c
restore/restore.h
restore/tape.c

diff --git a/CHANGES b/CHANGES
index 42f7a9874a4beae0c2b7986f7be6c3de340c11a0..fb347681bff505a25426c2b8fa7d53927978484f 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,4 @@
-$Id: CHANGES,v 1.154 2002/01/10 09:02:54 stelian Exp $
+$Id: CHANGES,v 1.155 2002/01/11 08:54:12 stelian Exp $
 
 Changes between versions 0.4b26 and 0.4b27 (released ???????????????)
 =====================================================================
@@ -6,6 +6,12 @@ Changes between versions 0.4b26 and 0.4b27 (released ???????????????)
 1.     Fixed behaviour of dump when exceeding resource limits
        (SIGXFSZ treatment).
 
+2.     Added the -L flag to restore to allow the user to specify a 
+       maximal allowed number of miscompares when using restore
+       with the -C option to check the backup.
+
+3.     Detailed the manual entry for the -N option of restore.
+
 Changes between versions 0.4b25 and 0.4b26 (released January 7, 2002)
 =====================================================================
 
index 8862d0da03d1b7dc4239a608312a874fd666302c..4757dc976236913c1dbefd0df4e63031b5efa802 100644 (file)
@@ -41,7 +41,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: main.c,v 1.32 2001/11/16 14:09:07 stelian Exp $";
+       "$Id: main.c,v 1.33 2002/01/11 08:54:14 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
@@ -82,7 +82,7 @@ static const char rcsid[] =
 
 int    bflag = 0, cvtflag = 0, dflag = 0, vflag = 0, yflag = 0;
 int    hflag = 1, mflag = 1, Mflag = 0, Nflag = 0, Vflag = 0, zflag = 0;
-int    uflag = 0, lflag = 0;
+int    uflag = 0, lflag = 0, Lflag = 0;
 int    dokerberos = 0;
 char   command = '\0';
 long   dumpnum = 1;
@@ -158,7 +158,7 @@ main(int argc, char *argv[])
 #ifdef KERBEROS
                "k"
 #endif
-               "lmMN"
+               "lL:mMN"
 #ifdef USE_QFA
                "Q:"
 #endif
@@ -217,6 +217,13 @@ main(int argc, char *argv[])
                case 'l':
                        lflag = 1;
                        break;
+               case 'L':
+                       Lflag = strtol(optarg, &p, 10);
+                       if (*p)
+                               errx(1, "illegal limit -- %s", optarg);
+                       if (Lflag < 0)
+                               errx(1, "limit must be greater than 0");
+                       break;
                case 'm':
                        mflag = 0;
                        break;
@@ -534,7 +541,7 @@ usage(void)
 
        (void)fprintf(stderr,
          "usage:\t%s%s\n\t%s%s\n\t%s%s\n\t%s%s\n\t%s%s\n\t%s%s\n",
-         __progname, " -C [-c" kerbflag "lMvVy] [-b blocksize] [-D filesystem] [-f file] [-F script] [-s fileno]",
+         __progname, " -C [-c" kerbflag "lMvVy] [-b blocksize] [-D filesystem] [-f file] [-F script] [-L limit] [-s fileno]",
          __progname, " -i [-ch" kerbflag "lmMuvVy] [-b blocksize] [-f file] [-F script] " qfaflag "[-s fileno]",
          __progname, " -r [-c" kerbflag "lMuvVy] [-b blocksize] [-f file] [-F script] [-s fileno] [-T directory]",
          __progname, " -R [-c" kerbflag "lMuvVy] [-b blocksize] [-f file] [-F script] [-s fileno] [-T directory]",
@@ -577,6 +584,7 @@ obsolete(int *argcp, char **argvp[])
                case 'D':
                case 'f':
                case 'F':
+               case 'L':
                case 'Q':
                case 's':
                case 'T':
index ced86a47b463679bdaa44c984b0e1a738169e8ff..36f81a9ae0d7e761599b02b34a54393bbd3cea01 100644 (file)
@@ -29,7 +29,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\"    $Id: restore.8.in,v 1.19 2001/11/16 14:09:07 stelian Exp $
+.\"    $Id: restore.8.in,v 1.20 2002/01/11 08:54:14 stelian Exp $
 .\"
 .Dd __DATE__
 .Dt RESTORE 8
@@ -45,6 +45,7 @@
 .Op Fl D Ar filesystem
 .Op Fl f Ar file
 .Op Fl F Ar script
+.Op Fl L Ar limit
 .Op Fl s Ar fileno
 .Op Fl T Ar directory
 .Nm restore
@@ -133,6 +134,9 @@ disk.
 It first changes its working directory to the root of the filesystem
 that was dumped and compares the tape with the files in its new
 current directory.
+See also the
+.Fl L
+flag described below.
 .It Fl i
 This mode allows interactive restoration of files from a dump.
 After reading in the directory information from the dump,
@@ -375,6 +379,18 @@ a remote compressed file, you will need to specify this
 option or 
 .Nm restore
 will fail to access it correctly.
+.It Fl L Ar limit
+The
+.Fl L
+flag allows the user to specify a maximal number of miscompares
+when using
+.Nm restore
+with the
+.Fl C
+option to check the backup. If this limit is reached, 
+.Nm restore
+will abort with an error message. A value of 0 (the default value) 
+disables the check.
 .It Fl m
 Extract by inode numbers rather than by file name.
 This is useful if only a few files are being extracted,
@@ -394,7 +410,14 @@ The
 .Fl N
 flag causes
 .Nm
-to only print file names. Files are not extracted.
+to perform a full execution as requested by one of
+.Fl i,
+.Fl R,
+.Fl r,
+.Fl t
+or
+.Fl x
+command without actually writing any file on disk.
 .It Fl Q Ar file
 Use the file
 .Ar file
index 618380489adf50aebbf160cc07d0f56ac471549f..e0506000db46e925f3cb50d119e0d6dceb58e8e3 100644 (file)
@@ -41,7 +41,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: restore.c,v 1.20 2001/12/24 15:53:41 stelian Exp $";
+       "$Id: restore.c,v 1.21 2002/01/11 08:54:14 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
@@ -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) {
@@ -723,7 +723,7 @@ compareleaves(void)
                        panic("%d: bad first\n", first);
                fprintf(stderr, "%s: (inode %lu) not found on tape\n", 
                        myname(ep), (unsigned long)first);
-               compare_errors = 1;
+               do_compare_error;
                ep->e_flags &= ~(NEW|EXTRACT);
                first = lowerbnd(first);
        }
@@ -822,7 +822,7 @@ createleaves(char *symtabfile)
                        panic("%d: bad first\n", first);
                fprintf(stderr, "%s: (inode %lu) not found on tape\n", 
                        myname(ep), (unsigned long)first);
-               compare_errors = 1;
+               do_compare_error;
                ep->e_flags &= ~(NEW|EXTRACT);
                first = lowerbnd(first);
        }
index a55a8fdfaa801570cf23ed39480c4792fa663451..6b48f93466413c242505ace9fb0e0213e803b8d8 100644 (file)
@@ -5,7 +5,7 @@
  *     Stelian Pop <pop@noos.fr>, 1999-2000
  *     Stelian Pop <pop@noos.fr> - AlcĂ´ve <www.alcove.fr>, 2000
  *
- *     $Id: restore.h,v 1.20 2001/12/24 15:53:41 stelian Exp $
+ *     $Id: restore.h,v 1.21 2002/01/11 08:54:14 stelian Exp $
  */
 
 /*
@@ -56,6 +56,7 @@ extern int    bflag;          /* set input block size */
 extern int     dflag;          /* print out debugging info */
 extern int     hflag;          /* restore heirarchies */
 extern int     lflag;          /* assume remote filename is a regular file */
+extern int     Lflag;          /* compare errors limit */
 extern int     mflag;          /* restore by name instead of inode number */
 extern int     Mflag;          /* multi-volume restore */
 extern int     Vflag;          /* multi-volume on a single device like CDROM */
@@ -175,3 +176,10 @@ extern char        gTps[255];
 extern long    gSeekstart;
 extern int     tapeposflag;
 #endif /* USE_QFA */
+
+#define do_compare_error \
+       if (++compare_errors >= Lflag && Lflag) { \
+               printf("Compare errors limit reached, exiting...\n"); \
+               exit(2); \
+       }
+
index 4b4f7362ccf6a97713c9edcfd7b8e315cf1f543a..4244027162550c97ddd5c2cb13645caace9c0b58 100644 (file)
@@ -46,7 +46,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: tape.c,v 1.50 2001/12/24 15:53:41 stelian Exp $";
+       "$Id: tape.c,v 1.51 2002/01/11 08:54:14 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
@@ -1080,14 +1080,14 @@ cmpfiles(char *tapefile, char *diskfile, struct STAT *sbuf_disk)
        if (STAT(tapefile, &sbuf_tape) != 0) {
                panic("Can't lstat tmp file %s: %s\n", tapefile,
                      strerror(errno));
-               compare_errors = 1;
+               do_compare_error;
        }
 
        if (sbuf_disk->st_size != sbuf_tape.st_size) {
                fprintf(stderr,
                        "%s: size changed from %ld to %ld.\n",
                        diskfile, (long)sbuf_tape.st_size, (long)sbuf_disk->st_size);
-               compare_errors = 1;
+               do_compare_error;
 #ifdef COMPARE_FAIL_KEEP_FILE
                return (0);
 #else
@@ -1097,12 +1097,12 @@ cmpfiles(char *tapefile, char *diskfile, struct STAT *sbuf_disk)
 
        if ((fd_tape = OPEN(tapefile, O_RDONLY)) < 0) {
                panic("Can't open %s: %s\n", tapefile, strerror(errno));
-               compare_errors = 1;
+               do_compare_error;
        }
        if ((fd_disk = OPEN(diskfile, O_RDONLY)) < 0) {
                close(fd_tape);
                panic("Can't open %s: %s\n", diskfile, strerror(errno));
-               compare_errors = 1;
+               do_compare_error;
        }
 
        if (do_cmpfiles(fd_tape, fd_disk, sbuf_tape.st_size)) {
@@ -1110,7 +1110,7 @@ cmpfiles(char *tapefile, char *diskfile, struct STAT *sbuf_disk)
                        diskfile);
                close(fd_tape);
                close(fd_disk);
-               compare_errors = 1;
+               do_compare_error;
 #ifdef COMPARE_FAIL_KEEP_FILE
                /* rename the file to live in /tmp */
                /* rename `tapefile' to /tmp/<basename of diskfile> */
@@ -1163,7 +1163,7 @@ comparefile(char *name)
 
        if ((r = LSTAT(name, &sb)) != 0) {
                warn("%s: does not exist (%d)", name, r);
-               compare_errors = 1;
+               do_compare_error;
                skipfile();
                return;
        }
@@ -1178,7 +1178,7 @@ comparefile(char *name)
        if (sb.st_mode != mode) {
                fprintf(stderr, "%s: mode changed from 0%o to 0%o.\n",
                        name, mode & 07777, sb.st_mode & 07777);
-               compare_errors = 1;
+               do_compare_error;
        }
        switch (mode & IFMT) {
        default:
@@ -1200,7 +1200,7 @@ comparefile(char *name)
                if (!(sb.st_mode & S_IFLNK)) {
                        fprintf(stderr, "%s: is no longer a symbolic link\n",
                                name);
-                       compare_errors = 1;
+                       do_compare_error;
                        return;
                }
                lnkbuf[0] = '\0';
@@ -1210,20 +1210,20 @@ comparefile(char *name)
                        fprintf(stderr,
                                "%s: zero length symbolic link (ignored)\n",
                                name);
-                       compare_errors = 1;
+                       do_compare_error;
                        return;
                }
                if ((lsize = readlink(name, lbuf, MAXPATHLEN)) < 0) {
                        panic("readlink of %s failed: %s", name,
                              strerror(errno));
-                       compare_errors = 1;
+                       do_compare_error;
                }
                lbuf[lsize] = 0;
                if (strcmp(lbuf, lnkbuf) != 0) {
                        fprintf(stderr,
                                "%s: symbolic link changed from %s to %s.\n",
                                name, lnkbuf, lbuf);
-                       compare_errors = 1;
+                       do_compare_error;
                        return;
                }
                return;
@@ -1234,7 +1234,7 @@ comparefile(char *name)
                if (!(sb.st_mode & (S_IFCHR|S_IFBLK))) {
                        fprintf(stderr, "%s: no longer a special file\n",
                                name);
-                       compare_errors = 1;
+                       do_compare_error;
                        skipfile();
                        return;
                }
@@ -1247,7 +1247,7 @@ comparefile(char *name)
                                (int)curfile.dip->di_rdev & 0xff,
                                ((int)sb.st_rdev >> 8) & 0xff,
                                (int)sb.st_rdev & 0xff);
-                       compare_errors = 1;
+                       do_compare_error;
                }
                skipfile();
                return;
@@ -1257,7 +1257,7 @@ comparefile(char *name)
                if ((ifile = OPEN(name, O_RDONLY)) < 0) {
                        panic("Can't open %s: %s\n", name, strerror(errno));
                        skipfile();
-                       compare_errors = 1;
+                       do_compare_error;
                }
                else {
                        cmperror = 0;
@@ -1271,7 +1271,7 @@ comparefile(char *name)
                                }
                        }
                        if (cmperror)
-                               compare_errors = 1;
+                               do_compare_error;
                        close(ifile);
                }
 #else