new copyright & pathname (savecore)
[unix-history] / usr / src / sbin / dump / tape.c
index fbd6595..c2566da 100644 (file)
@@ -5,15 +5,17 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)tape.c     5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)tape.c     5.10 (Berkeley) %G%";
 #endif not lint
 
 #include <sys/file.h>
 #include "dump.h"
 #endif not lint
 
 #include <sys/file.h>
 #include "dump.h"
+#include "pathnames.h"
 
 
-char   (*tblock)[TP_BSIZE];    /* Pointer to malloc()ed buffer for tape */
-int    writesize;              /* Size of malloc()ed buffer for tape */
-int    trecno = 0;
+char   (*tblock)[TP_BSIZE];    /* pointer to malloc()ed buffer for tape */
+int    writesize;              /* size of malloc()ed buffer for tape */
+long   lastspclrec = -1;       /* tape block number of last written header */
+int    trecno = 0;             /* next record to write in current block */
 extern int ntrec;              /* blocking factor on tape */
 extern int cartridge;
 extern int read(), write();
 extern int ntrec;              /* blocking factor on tape */
 extern int cartridge;
 extern int read(), write();
@@ -74,6 +76,7 @@ taprec(dp)
        req[trecno].dblk = (daddr_t)0;
        req[trecno].count = 1;
        *(union u_spcl *)(*tblock++) = *(union u_spcl *)dp;     /* movc3 */
        req[trecno].dblk = (daddr_t)0;
        req[trecno].count = 1;
        *(union u_spcl *)(*tblock++) = *(union u_spcl *)dp;     /* movc3 */
+       lastspclrec = spcl.c_tapea;
        trecno++;
        spcl.c_tapea++;
        if(trecno >= ntrec)
        trecno++;
        spcl.c_tapea++;
        if(trecno >= ntrec)
@@ -95,7 +98,7 @@ dmpblk(blkno, size)
                spcl.c_tapea += avail;
                if (trecno >= ntrec)
                        flusht();
                spcl.c_tapea += avail;
                if (trecno >= ntrec)
                        flusht();
-               dblkno += avail * (TP_BSIZE / DEV_BSIZE);
+               dblkno += avail * (TP_BSIZE / dev_bsize);
                tpblks -= avail;
        }
 }
                tpblks -= avail;
        }
 }
@@ -217,12 +220,14 @@ otape()
        int     childpid;
        int     status;
        int     waitpid;
        int     childpid;
        int     status;
        int     waitpid;
-       int     (*interrupt)() = signal(SIGINT, SIG_IGN);
+       sig_t   interrupt;
+       int     blks, i;
 
 
+       interrupt = signal(SIGINT, SIG_IGN);
        parentpid = getpid();
 
     restore_check_point:
        parentpid = getpid();
 
     restore_check_point:
-       signal(SIGINT, interrupt);
+       (void)signal(SIGINT, interrupt);
        /*
         *      All signals are inherited...
         */
        /*
         *      All signals are inherited...
         */
@@ -292,17 +297,28 @@ otape()
 #else RDUMP
                while ((to = pipeout ? 1 : creat(tape, 0666)) < 0)
 #endif RDUMP
 #else RDUMP
                while ((to = pipeout ? 1 : creat(tape, 0666)) < 0)
 #endif RDUMP
-                       if (!query("Cannot open tape.  Do you want to retry the open?"))
+                   {
+                       msg("Cannot open tape \"%s\".\n", tape);
+                       if (!query("Do you want to retry the open?"))
                                dumpabort();
                                dumpabort();
+               }
 
                enslave();  /* Share open tape file descriptor with slaves */
 
                asize = 0;
                tapeno++;               /* current tape sequence */
                newtape++;              /* new tape signal */
 
                enslave();  /* Share open tape file descriptor with slaves */
 
                asize = 0;
                tapeno++;               /* current tape sequence */
                newtape++;              /* new tape signal */
+               blks = 0;
+               if (spcl.c_type != TS_END)
+                       for (i = 0; i < spcl.c_count; i++)
+                               if (spcl.c_addr[i] != 0)
+                                       blks++;
+               spcl.c_count = blks + 1 - spcl.c_tapea + lastspclrec;
                spcl.c_volume++;
                spcl.c_type = TS_TAPE;
                spcl.c_volume++;
                spcl.c_type = TS_TAPE;
+               spcl.c_flags |= DR_NEWHEADER;
                spclrec();
                spclrec();
+               spcl.c_flags &=~ DR_NEWHEADER;
                if (tapeno > 1)
                        msg("Tape %d begins with blocks from ino %d\n",
                                tapeno, ino);
                if (tapeno > 1)
                        msg("Tape %d begins with blocks from ino %d\n",
                                tapeno, ino);
@@ -336,7 +352,7 @@ lockfile(fd)
 {
        char tmpname[20];
 
 {
        char tmpname[20];
 
-       strcpy(tmpname, "/tmp/dumplockXXXXXX");
+       strcpy(tmpname, _PATH_LOCK);
        mktemp(tmpname);
        if ((fd[1] = creat(tmpname, 0400)) < 0) {
                msg("Could not create lockfile ");
        mktemp(tmpname);
        if ((fd[1] = creat(tmpname, 0400)) < 0) {
                msg("Could not create lockfile ");
@@ -438,7 +454,7 @@ doslave(cmd, prev, next)
                        } else {
                                if (p->count != 1 || atomic(read, cmd,
                                    tblock[trecno], TP_BSIZE) != TP_BSIZE) {
                        } else {
                                if (p->count != 1 || atomic(read, cmd,
                                    tblock[trecno], TP_BSIZE) != TP_BSIZE) {
-                                       msg("Master/slave protocol botched");
+                                       msg("Master/slave protocol botched.\n");
                                        dumpabort();
                                }
                        }
                                        dumpabort();
                                }
                        }