-$Id: CHANGES,v 1.55 2000/05/28 16:24:13 stelian Exp $
+$Id: CHANGES,v 1.56 2000/05/28 16:51:13 stelian Exp $
Changes between versions 0.4b16 and 0.4b17 (released ??????????????)
====================================================================
with libc5. Thanks to Jeff Johnson <jbj@redhat.com> for
the patch.
+3. Made the exit code of restore in case of a 'C'ompare
+ command reflect the result of the compare. An exit status
+ of 0 means the dump archive is correct, 1 means tape errors,
+ 2 means that some files were modified.
+
Changes between versions 0.4b15 and 0.4b16 (released March 11, 2000)
====================================================================
#ifndef lint
static const char rcsid[] =
- "$Id: main.c,v 1.11 2000/03/09 13:12:31 stelian Exp $";
+ "$Id: main.c,v 1.12 2000/05/28 16:52:21 stelian Exp $";
#endif /* not lint */
#include <sys/param.h>
FILE *terminal;
char *tmpdir;
int compare_ignore_not_found;
+int compare_errors;
char filesys[NAMELEN];
static const char *stdin_opt = NULL;
Vprintf(stdout, "Begin compare restore\n");
compare_ignore_not_found = 0;
+ compare_errors = 0;
setup();
printf("filesys = %s\n", filesys);
if (stat(filesys, &stbuf) < 0)
treescan(".", ROOTINO, nodeupdates);
compareleaves();
checkrestore();
+ if (compare_errors) {
+ printf("Some files were modified!\n");
+ exit(2);
+ }
break;
}
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: restore.8.in,v 1.9 2000/03/09 13:12:31 stelian Exp $
+.\" $Id: restore.8.in,v 1.10 2000/05/28 16:52:21 stelian Exp $
.\"
.Dd __DATE__
.Dt RESTORE 8
may have to resynchronize itself.
This message lists the number of blocks that were skipped over.
.El
+.Pp
+.Nm Restore
+exits with zero status on success.
+Tape errors are indicated with an exit code of 1.
+.Pp
+When doing a comparison of files from a dump, an exit code
+of 2 indicates that some files were modified or deleted since
+the dump was made.
.Sh ENVIRONMENT
If the following environment variable exists it will be utilized by
.Nm restore :
#ifndef lint
static const char rcsid[] =
- "$Id: restore.c,v 1.7 2000/01/21 10:17:41 stelian Exp $";
+ "$Id: restore.c,v 1.8 2000/05/28 16:52:21 stelian Exp $";
#endif /* not lint */
#include <sys/types.h>
static void
compare_entry(struct entry *ep, int do_compare)
{
- if ((ep->e_flags & (NEW|EXTRACT)) == 0)
+ if ((ep->e_flags & (NEW|EXTRACT)) == 0) {
badentry(ep, "unexpected file on tape");
+ compare_errors = 1;
+ }
if (do_compare) (void) comparefile(myname(ep));
ep->e_flags &= ~(NEW|EXTRACT);
}
if (ep == NULL)
panic("%d: bad first\n", first);
fprintf(stderr, "%s: not found on tape\n", myname(ep));
+ compare_errors = 1;
ep->e_flags &= ~(NEW|EXTRACT);
first = lowerbnd(first);
}
if (first != curfile.ino) {
fprintf(stderr, "expected next file %ld, got %lu\n",
(long)first, (unsigned long)curfile.ino);
+ compare_errors = 1;
skipfile();
goto next;
}
ep = lookupino(curfile.ino);
- if (ep == NULL)
+ if (ep == NULL) {
panic("unknown file on tape\n");
+ compare_errors = 1;
+ }
compare_entry(ep, 1);
for (ep = ep->e_links; ep != NULL; ep = ep->e_links) {
compare_entry(ep, 0);
* Remy Card <card@Linux.EU.Org>, 1994-1997
* Stelian Pop <pop@cybercable.fr>, 1999-2000
*
- * $Id: restore.h,v 1.8 2000/03/02 11:34:51 stelian Exp $
+ * $Id: restore.h,v 1.9 2000/05/28 16:52:21 stelian Exp $
*/
/*
/* used to compare incremental dumps, */
/* so messages about "not found" files */
/* isn't seen. */
+extern int compare_errors; /* did we encounter any compare errors? */
extern char filesys[NAMELEN];/* name of dumped filesystem */
/*
#ifndef lint
static const char rcsid[] =
- "$Id: tape.c,v 1.14 2000/03/03 11:00:55 stelian Exp $";
+ "$Id: tape.c,v 1.15 2000/05/28 16:52:21 stelian Exp $";
#endif /* not lint */
#include <sys/param.h>
if (stat(tapefile, &sbuf_tape) != 0) {
panic("Can't lstat tmp file %s: %s\n", tapefile,
strerror(errno));
+ compare_errors = 1;
}
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;
#ifdef COMPARE_FAIL_KEEP_FILE
return (0);
#else
if ((fd_tape = open(tapefile, O_RDONLY)) < 0) {
panic("Can't open %s: %s\n", tapefile, strerror(errno));
+ compare_errors = 1;
}
if ((fd_disk = open(diskfile, O_RDONLY)) < 0) {
close(fd_tape);
panic("Can't open %s: %s\n", diskfile, strerror(errno));
+ compare_errors = 1;
}
if (do_cmpfiles(fd_tape, fd_disk, sbuf_tape.st_size)) {
diskfile);
close(fd_tape);
close(fd_disk);
+ compare_errors = 1;
#ifdef COMPARE_FAIL_KEEP_FILE
/* rename the file to live in /tmp */
/* rename `tapefile' to /tmp/<basename of diskfile> */
if ((r = lstat(name, &sb)) != 0) {
warn("%s: does not exist (%d)", name, r);
+ compare_errors = 1;
skipfile();
return;
}
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;
}
switch (mode & IFMT) {
default:
if (!(sb.st_mode & S_IFLNK)) {
fprintf(stderr, "%s: is no longer a symbolic link\n",
name);
+ compare_errors = 1;
return;
}
lnkbuf[0] = '\0';
fprintf(stderr,
"%s: zero length symbolic link (ignored)\n",
name);
+ compare_errors = 1;
return;
}
if ((lsize = readlink(name, lbuf, MAXPATHLEN)) < 0) {
panic("readlink of %s failed: %s", name,
strerror(errno));
+ compare_errors = 1;
}
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;
return;
}
return;
if (!(sb.st_mode & (S_IFCHR|S_IFBLK))) {
fprintf(stderr, "%s: no longer a special file\n",
name);
+ compare_errors = 1;
skipfile();
return;
}
(int)curfile.dip->di_rdev & 0xff,
((int)sb.st_rdev >> 8) & 0xff,
(int)sb.st_rdev & 0xff);
+ compare_errors = 1;
}
skipfile();
return;