From 05f23c0c51be02f2bb0a3706247027dc8fa17af1 Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Fri, 11 Jan 2002 08:54:12 +0000 Subject: [PATCH] Added -L option to restore -N restore option man page entry --- CHANGES | 8 +++++++- restore/main.c | 16 ++++++++++++---- restore/restore.8.in | 27 +++++++++++++++++++++++++-- restore/restore.c | 16 ++++++++-------- restore/restore.h | 10 +++++++++- restore/tape.c | 32 ++++++++++++++++---------------- 6 files changed, 77 insertions(+), 32 deletions(-) diff --git a/CHANGES b/CHANGES index 42f7a98..fb34768 100644 --- 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) ===================================================================== diff --git a/restore/main.c b/restore/main.c index 8862d0d..4757dc9 100644 --- a/restore/main.c +++ b/restore/main.c @@ -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 @@ -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': diff --git a/restore/restore.8.in b/restore/restore.8.in index ced86a4..36f81a9 100644 --- a/restore/restore.8.in +++ b/restore/restore.8.in @@ -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 diff --git a/restore/restore.c b/restore/restore.c index 6183804..e050600 100644 --- a/restore/restore.c +++ b/restore/restore.c @@ -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 @@ -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); } diff --git a/restore/restore.h b/restore/restore.h index a55a8fd..6b48f93 100644 --- a/restore/restore.h +++ b/restore/restore.h @@ -5,7 +5,7 @@ * Stelian Pop , 1999-2000 * Stelian Pop - AlcĂ´ve , 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); \ + } + diff --git a/restore/tape.c b/restore/tape.c index 4b4f736..4244027 100644 --- a/restore/tape.c +++ b/restore/tape.c @@ -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 @@ -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/ */ @@ -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 -- 2.39.5