X-Git-Url: https://git.wh0rd.org/?p=dump.git;a=blobdiff_plain;f=restore%2Ftape.c;h=cf024713643ab76e53dca89f0142f14279196b65;hp=4b4f7362ccf6a97713c9edcfd7b8e315cf1f543a;hb=103122b3455278bdf377ce24821168be90238fda;hpb=9d49c83f5624f5cf13b7e27fd1f058b10dad50a3 diff --git a/restore/tape.c b/restore/tape.c index 4b4f736..cf02471 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.50 2001/12/24 15:53:41 stelian Exp $"; + "$Id: tape.c,v 1.54 2002/01/22 11:12:28 stelian Exp $"; #endif /* not lint */ #include @@ -190,6 +190,10 @@ setinput(char *source) #ifdef RRESTORE if (strchr(source, ':')) { +#ifdef USE_QFA + if (tapeposflag) + errx(1, "cannot use -Q option on remote media"); +#endif host = source; source = strchr(host, ':'); *source++ = '\0'; @@ -406,7 +410,7 @@ getvol(long nextvol) again: if (pipein) exit(1); /* pipes do not get a second chance */ - if (command == 'R' || command == 'r' || curfile.action != SKIP) { + if (aflag || curfile.action != SKIP) { newvol = nextvol; wantnext = 1; } else { @@ -1080,14 +1084,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 +1101,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 +1114,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 +1167,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 +1182,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 +1204,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 +1214,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 +1238,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 +1251,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 +1261,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 +1275,7 @@ comparefile(char *name) } } if (cmperror) - compare_errors = 1; + do_compare_error; close(ifile); } #else @@ -2385,8 +2389,15 @@ GetTapePos(long *pos) { int err = 0; - *pos = 0; - if (ioctl(mt, MTIOCPOS, pos) == -1) { + if (magtapein) { + *pos = 0; + err = (ioctl(mt, MTIOCPOS, pos) < 0); + } + else { + *pos = lseek(mt, 0, SEEK_CUR); + err = (*pos < 0); + } + if (err) { err = errno; fprintf(stdout, "[%ld] error: %d (getting tapepos: %ld)\n", (unsigned long)getpid(), err, *pos); @@ -2407,11 +2418,18 @@ int GotoTapePos(long pos) { int err = 0; - struct mt_pos buf; - buf.mt_op = MTSEEK; - buf.mt_count = pos; - if (ioctl(mt, MTIOCTOP, &buf) == -1) { + if (magtapein) { + struct mt_pos buf; + buf.mt_op = MTSEEK; + buf.mt_count = pos; + err = (ioctl(mt, MTIOCTOP, &buf) < 0); + } + else { + pos = lseek(mt, pos, SEEK_SET); + err = (pos < 0); + } + if (err) { err = errno; fprintf(stdout, "[%ld] error: %d (setting tapepos: %ld)\n", (unsigned long)getpid(), err, pos);