]> git.wh0rd.org - dump.git/blobdiff - restore/tape.c
Fixed restore to correctly access the archive file (-A argument) even when using...
[dump.git] / restore / tape.c
index 2bb447239bed286d20afbe0de2cb57f2afdf7215..9bfb4c5051e74098d6cfa38670cf84d8fcf36ce9 100644 (file)
@@ -46,7 +46,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: tape.c,v 1.67 2003/01/10 14:42:51 stelian Exp $";
+       "$Id: tape.c,v 1.69 2003/02/11 12:43:45 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
@@ -286,7 +286,7 @@ setup(void)
                temptape = magtape;
 
 #ifdef RRESTORE
-       if (host)
+       if (!Afile && host)
                mt = rmtopen(temptape, O_RDONLY);
        else
 #endif
@@ -295,7 +295,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 +502,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';
@@ -1266,6 +1273,16 @@ comparefile(char *name)
        struct STAT stemp;
 #endif
 
+       curfile.name = name;
+       curfile.action = USING;
+       mode = curfile.dip->di_mode;
+
+       if ((mode & IFMT) == IFSOCK) {
+               Vprintf(stdout, "skipped socket %s\n", name);
+               skipfile();
+               return;
+       }
+
        if ((r = LSTAT(name, &sb)) != 0) {
                warn("%s: does not exist (%d)", name, r);
                do_compare_error;
@@ -1273,10 +1290,6 @@ comparefile(char *name)
                return;
        }
 
-       curfile.name = name;
-       curfile.action = USING;
-       mode = curfile.dip->di_mode;
-
        Vprintf(stdout, "comparing %s (size: %ld, mode: 0%o)\n", name,
                (long)sb.st_size, mode);
 
@@ -1481,7 +1494,7 @@ readtape(char *buf)
 #endif
 getmore:
 #ifdef RRESTORE
-       if (host)
+       if (!Afile && host)
                i = rmtread(&tapebuf[rd], cnt);
        else
 #endif
@@ -1543,7 +1556,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
@@ -2024,7 +2037,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
@@ -2048,7 +2061,7 @@ closemt(void)
        if (mt < 0)
                return;
 #ifdef RRESTORE
-       if (host)
+       if (!Afile && host)
                rmtclose();
        else
 #endif