]> git.wh0rd.org - dump.git/blobdiff - restore/tape.c
Made -Q option work on regular files.
[dump.git] / restore / tape.c
index 4244027162550c97ddd5c2cb13645caace9c0b58..cf024713643ab76e53dca89f0142f14279196b65 100644 (file)
@@ -2,8 +2,8 @@
  *     Ported to Linux's Second Extended File System as part of the
  *     dump and restore backup suit
  *     Remy Card <card@Linux.EU.Org>, 1994-1997
- *     Stelian Pop <pop@noos.fr>, 1999-2000
- *     Stelian Pop <pop@noos.fr> - Alcôve <www.alcove.fr>, 2000
+ *     Stelian Pop <stelian@popies.net>, 1999-2000
+ *     Stelian Pop <stelian@popies.net> - Alcôve <www.alcove.com>, 2000-2002
  */
 
 /*
@@ -46,7 +46,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: tape.c,v 1.51 2002/01/11 08:54:14 stelian Exp $";
+       "$Id: tape.c,v 1.54 2002/01/22 11:12:28 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
@@ -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 {
@@ -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);