]> git.wh0rd.org - dump.git/blobdiff - restore/tape.c
Relicensed dump/restore under the revised BSD license, as per ftp://ftp.cs.berkeley...
[dump.git] / restore / tape.c
index 145f769b949308e38e343a60bd7bbaf4f2e7c098..56830c4f8174944f9ccf9d8ae97f39d8cdf851ba 100644 (file)
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -46,7 +42,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: tape.c,v 1.68 2003/02/11 09:56:48 stelian Exp $";
+       "$Id: tape.c,v 1.73 2003/03/30 15:40:40 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
@@ -286,7 +282,7 @@ setup(void)
                temptape = magtape;
 
 #ifdef RRESTORE
-       if (host)
+       if (!Afile && host)
                mt = rmtopen(temptape, O_RDONLY);
        else
 #endif
@@ -295,7 +291,7 @@ setup(void)
        else
                mt = OPEN(temptape, O_RDONLY, 0);
        if (mt < 0)
-               err(1, "%s", magtape);
+               err(1, "%s", temptape);
        if (!Afile) {
                volno = 1;
                setmagtapein();
@@ -502,6 +498,13 @@ again:
                return;
        }
        closemt();
+
+       /* 
+        * if using an archive file, reset its name so readtape()
+        * could properly use remote access.
+        */
+       Afile = NULL;
+
        if (Mflag) {
                snprintf(magtape, MAXPATHLEN, "%s%03ld", magtapeprefix, newvol);
                magtape[MAXPATHLEN - 1] = '\0';
@@ -1487,7 +1490,7 @@ readtape(char *buf)
 #endif
 getmore:
 #ifdef RRESTORE
-       if (host)
+       if (!Afile && host)
                i = rmtread(&tapebuf[rd], cnt);
        else
 #endif
@@ -1549,7 +1552,7 @@ getmore:
                i = ntrec * TP_BSIZE;
                memset(tapebuf, 0, (size_t)i);
 #ifdef RRESTORE
-               if (host)
+               if (!Afile && host)
                        seek_failed = (rmtseek(i, 1) < 0);
                else
 #endif
@@ -2030,7 +2033,7 @@ static int read_a_block(int fd, char *buf, size_t len, long *lengthread)
        size = len;
        while (size > 0) {
 #ifdef RRESTORE
-               if (host)
+               if (!Afile && host)
                        i = rmtread(buf, size);
                else
 #endif
@@ -2054,7 +2057,7 @@ closemt(void)
        if (mt < 0)
                return;
 #ifdef RRESTORE
-       if (host)
+       if (!Afile && host)
                rmtclose();
        else
 #endif
@@ -2078,7 +2081,8 @@ setmagtapein(void) {
                        magtapein = ioctl(mt, MTIOCGET, (char *)&mt_stat) == 0;
        }
 
-       Vprintf(stdout,"Input is from %s\n", 
+       Vprintf(stdout,"Input is from a %s %s\n",
+                       host ? "remote" : "local",
                        magtapein ? "tape" :
                        Vflag ? "multi-volume (no tape)" : "file/pipe");
 }
@@ -2646,13 +2650,12 @@ ReReadInodeFromTape(dump_ino_t theino)
        do {
                cntloop++;
                gethead(&spcl);
-       } while (!(spcl.c_inumber == theino && spcl.c_type == TS_INODE && spcl.c_date == dumpdate) && (cntloop < 32));
+       } while (!(spcl.c_inumber == theino && spcl.c_type == TS_INODE && spcl.c_date == dumpdate) && (cntloop < ntrec));
 #ifdef DEBUG_QFA
        fprintf(stderr, "%ld reads\n", cntloop);
-       if (cntloop == 32) {
+       if (cntloop == ntrec) {
                fprintf(stderr, "DEBUG: bufsize %d\n", bufsize);
                fprintf(stderr, "DEBUG: ntrec %ld\n", ntrec);
-               fprintf(stderr, "DEBUG: %ld reads\n", cntloop);
        }
 #endif
        findinode(&spcl);