X-Git-Url: https://git.wh0rd.org/?p=dump.git;a=blobdiff_plain;f=restore%2Ftape.c;h=76dded78fbef7113e3dc2740378fcc4392e59585;hp=fb5c816e974ad6c3a6406d8d7d6282dece01fb97;hb=11856e771fadee7ddb9b5a613c91f562bf363da7;hpb=88ef261eaffd1b09f23eb73d8259336f694d9324 diff --git a/restore/tape.c b/restore/tape.c index fb5c816..76dded7 100644 --- a/restore/tape.c +++ b/restore/tape.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 */ /* @@ -46,7 +46,7 @@ #ifndef lint static const char rcsid[] = - "$Id: tape.c,v 1.46 2001/08/16 15:24:22 stelian Exp $"; + "$Id: tape.c,v 1.52 2002/01/16 09:32:14 stelian Exp $"; #endif /* not lint */ #include @@ -97,7 +97,7 @@ int noresyncmesg = 0; #endif /* USE_QFA */ static long fssize = MAXBSIZE; static int mt = -1; -static int pipein = 0; +int pipein = 0; static int magtapein = 0; /* input is from magtape */ static char magtape[MAXPATHLEN]; static char magtapeprefix[MAXPATHLEN]; @@ -432,12 +432,16 @@ again: fprintf(stderr, "\n"); } do { - fprintf(stderr, "Specify next volume #: "); + fprintf(stderr, "Specify next volume # (none if no more volumes): "); (void) fflush(stderr); (void) fgets(buf, TP_BSIZE, terminal); } while (!feof(terminal) && buf[0] == '\n'); if (feof(terminal)) exit(1); + if (!strcmp(buf, "none\n")) { + terminateinput(); + return; + } newvol = atoi(buf); if (newvol <= 0) { fprintf(stderr, @@ -1076,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 @@ -1093,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)) { @@ -1106,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/ */ @@ -1159,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; } @@ -1174,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: @@ -1196,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'; @@ -1206,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; @@ -1230,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; } @@ -1243,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; @@ -1253,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; @@ -1267,7 +1271,7 @@ comparefile(char *name) } } if (cmperror) - compare_errors = 1; + do_compare_error; close(ifile); } #else @@ -1492,6 +1496,9 @@ readtape_comprfile(char *buf) /* read the block prefix */ ret = read_a_block(mt, tapebuf, PREFIXSIZE, &rl); + + if (Vflag && (ret == 0 || rl < PREFIXSIZE || tpb->length == 0)) + ret = 0; if (ret <= 0) goto readerr; @@ -1926,13 +1933,15 @@ setmagtapein(void) { /* need to know if input is really from a tape */ #ifdef RRESTORE if (host) - magtapein = rmtioctl(MTNOP, 1) != -1; + magtapein = !lflag; else #endif magtapein = ioctl(mt, MTIOCGET, (char *)&mt_stat) == 0; } - Vprintf(stdout,"Input is from %s\n", magtapein? "tape": "file/pipe"); + Vprintf(stdout,"Input is from %s\n", + magtapein ? "tape" : + Vflag ? "multi-volume (no tape)" : "file/pipe"); } /*