]> git.wh0rd.org - dump.git/blobdiff - restore/tape.c
Fix restore of files spanning on the first and second volumes of a dump.
[dump.git] / restore / tape.c
index e60921bf3b86b1afff5ce0a8666978da04fe89d7..b779fd72517dd904a17b3430cd2a8d90790e4081 100644 (file)
@@ -42,7 +42,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: tape.c,v 1.89 2005/05/02 15:10:46 stelian Exp $";
+       "$Id: tape.c,v 1.93 2009/07/23 14:10:39 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
@@ -346,6 +346,7 @@ setup(void)
 #endif
        FLUSHTAPEBUF();
        findtapeblksize();
+       cvtflag = 0;
        if (gethead(&spcl) == FAIL) {
                blkcnt--; /* push back this block */
                blksread--;
@@ -473,7 +474,6 @@ getvol(long nextvol)
        if (nextvol == 1) {
                tapesread = 0;
                gettingfile = 0;
-               tpblksread = 0;
                blksread = 0;
        }
        if (pipein) {
@@ -569,6 +569,8 @@ again:
        }
        if (haderror || (bot_code && !Mflag)) {
                haderror = 0;
+               if (compare_errors)
+                       fprintf(stderr, "%d compare errors so far\n", compare_errors);
 #ifdef sunos
                fprintf(stderr, "Mount volume %ld\n", (long)newvol);
 #else
@@ -905,6 +907,8 @@ extractfile(struct entry *ep, int doremove)
                }
                (void) chown(name, curfile.dip->di_uid, curfile.dip->di_gid);
                (void) chmod(name, mode);
+               extractattr(name);
+               utimes(name, timep);
                if (flags)
 #ifdef  __linux__
                        (void) lsetflags(name, flags);
@@ -919,8 +923,6 @@ extractfile(struct entry *ep, int doremove)
 #endif
 #endif
                skipfile();
-               extractattr(name);
-               utimes(name, timep);
                return (GOOD);
 
        case IFCHR:
@@ -941,6 +943,8 @@ extractfile(struct entry *ep, int doremove)
                }
                (void) chown(name, curfile.dip->di_uid, curfile.dip->di_gid);
                (void) chmod(name, mode);
+               extractattr(name);
+               utimes(name, timep);
                if (flags)
 #ifdef __linux__
                        {
@@ -961,8 +965,6 @@ extractfile(struct entry *ep, int doremove)
 #endif
 #endif
                skipfile();
-               extractattr(name);
-               utimes(name, timep);
                return (GOOD);
 
        case IFREG:
@@ -991,6 +993,8 @@ extractfile(struct entry *ep, int doremove)
                        skipfile();
                (void) chown(name, luid, lgid);
                (void) chmod(name, mode);
+               extractattr(name);
+               utimes(name, timep);
                if (flags)
 #ifdef __linux__
                        (void) lsetflags(name, flags);
@@ -1004,8 +1008,6 @@ extractfile(struct entry *ep, int doremove)
                        (void) chflags(name, flags);
 #endif
 #endif
-               extractattr(name);
-               utimes(name, timep);
                return (GOOD);
        }
        }
@@ -1213,8 +1215,8 @@ extractresourceufs(char *name)
                (void) fchown(ofile, uid, gid);
                (void) fchmod(ofile, mode);
                (void) close(ofile);
-               (void) lsetflags(oFileRsrc, flags);
                utimes(oFileRsrc, timep);
+               (void) lsetflags(oFileRsrc, flags);
                return (GOOD);
        }
        /* NOTREACHED */
@@ -1330,7 +1332,11 @@ loop:
                        break;
                }
        }
-       if (gethead(&spcl) == GOOD && size > 0) {
+       while (gethead(&spcl) != GOOD) {
+               fprintf(stderr, "Incorrect block for %s at %ld blocks\n",
+                       curfile.name, (long)blksread);
+       }
+       if (size > 0) {
                if (spcl.c_type == TS_ADDR)
                        goto loop;
                Dprintf(stdout,
@@ -2412,6 +2418,7 @@ findtapeblksize(void)
                errx(1, "Tape read error on first record");
 
        memcpy(&spclpt, tapebuf, TP_BSIZE);
+       cvtflag = 0;
        if (converthead(&spclpt) == FAIL) {
                cvtflag++;
                if (converthead(&spclpt) == FAIL) {
@@ -2622,7 +2629,7 @@ converthead(struct s_spcl *buf)
                if (checksum((int *)buf) == FAIL)
                        return (FAIL);
                if (Bcvt)
-                       swabst((u_char *)"8i4s31i528bi192b3i", (u_char *)buf);
+                       swabst((u_char *)"8i4s1l29i528bi192b4i", (u_char *)buf);
                goto good;
        }
        memcpy(&u_ospcl.s_ospcl, buf, TP_BSIZE);