updates from Mike to make messages more media independent;
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Mon, 25 Feb 1991 06:03:34 +0000 (22:03 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Mon, 25 Feb 1991 06:03:34 +0000 (22:03 -0800)
add 'B' flag to specify number of blocks per volume

SCCS-vsn: sbin/dump/main.c 5.11
SCCS-vsn: sbin/dump/tape.c 5.13

usr/src/sbin/dump/main.c
usr/src/sbin/dump/tape.c

index edf71c5..cf08595 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     5.10 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c     5.11 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "dump.h"
 #endif /* not lint */
 
 #include "dump.h"
@@ -19,6 +19,7 @@ int   density = 0;    /* density in bytes/0.1" */
 int    ntrec = NTREC;  /* # tape blocks in each tape record */
 int    cartridge = 0;  /* Assume non-cartridge tape */
 long   dev_bsize = 1;  /* recalculated below */
 int    ntrec = NTREC;  /* # tape blocks in each tape record */
 int    cartridge = 0;  /* Assume non-cartridge tape */
 long   dev_bsize = 1;  /* recalculated below */
+long   blocksperfile;  /* output blocks per file */
 #ifdef RDUMP
 char   *host;
 int    rmthost();
 #ifdef RDUMP
 char   *host;
 int    rmthost();
@@ -98,6 +99,20 @@ main(argc, argv)
                        argc--;
                        bflag++;
                        ntrec = atol(*argv);
                        argc--;
                        bflag++;
                        ntrec = atol(*argv);
+                       if (ntrec <= 0) {
+                               fprintf(stderr,
+                                   "bad number of blocks per write \"%s\"\n",
+                                   *arg);
+                               Exit(X_ABORT);
+                       }
+               }
+               break;
+
+       case 'B':                       /* blocks per output file */
+               if(argc > 1) {
+                       argv++;
+                       argc--;
+                       blocksperfile = atol(*argv);
                }
                break;
 
                }
                break;
 
@@ -127,7 +142,7 @@ main(argc, argv)
                break;
 
        default:
                break;
 
        default:
-               fprintf(stderr, "bad key '%c%'\n", arg[-1]);
+               fprintf(stderr, "bad key '%c'\n", arg[-1]);
                Exit(X_ABORT);
        }
        if(argc > 1) {
                Exit(X_ABORT);
        }
        if(argc > 1) {
@@ -140,18 +155,23 @@ main(argc, argv)
                tape = "standard output";
        }
 
                tape = "standard output";
        }
 
-       /*
-        * Determine how to default tape size and density
-        *
-        *              density                         tape size
-        * 9-track      1600 bpi (160 bytes/.1")        2300 ft.
-        * 9-track      6250 bpi (625 bytes/.1")        2300 ft.
-        * cartridge    8000 bpi (100 bytes/.1")        1700 ft. (450*4 - slop)
-        */
-       if (density == 0)
-               density = cartridge ? 100 : 160;
-       if (tsize == 0)
-               tsize = cartridge ? 1700L*120L : 2300L*120L;
+       if (blocksperfile)
+               blocksperfile = blocksperfile / ntrec * ntrec; /* round down */
+       else {
+               /*
+                * Determine how to default tape size and density
+                *
+                *              density                         tape size
+                * 9-track      1600 bpi (160 bytes/.1")        2300 ft.
+                * 9-track      6250 bpi (625 bytes/.1")        2300 ft.
+                * cartridge    8000 bpi (100 bytes/.1")        1700 ft.
+                *                                              (450*4 - slop)
+                */
+               if (density == 0)
+                       density = cartridge ? 100 : 160;
+               if (tsize == 0)
+                       tsize = cartridge ? 1700L*120L : 2300L*120L;
+       }
 
 #ifdef RDUMP
        { char *index();
 
 #ifdef RDUMP
        { char *index();
@@ -167,18 +187,18 @@ main(argc, argv)
        }
        setuid(getuid());       /* rmthost() is the only reason to be setuid */
 #endif
        }
        setuid(getuid());       /* rmthost() is the only reason to be setuid */
 #endif
-       if (signal(SIGHUP, sighup) == SIG_IGN)
-               signal(SIGHUP, SIG_IGN);
-       if (signal(SIGTRAP, sigtrap) == SIG_IGN)
-               signal(SIGTRAP, SIG_IGN);
-       if (signal(SIGFPE, sigfpe) == SIG_IGN)
-               signal(SIGFPE, SIG_IGN);
-       if (signal(SIGBUS, sigbus) == SIG_IGN)
-               signal(SIGBUS, SIG_IGN);
-       if (signal(SIGSEGV, sigsegv) == SIG_IGN)
-               signal(SIGSEGV, SIG_IGN);
-       if (signal(SIGTERM, sigterm) == SIG_IGN)
-               signal(SIGTERM, SIG_IGN);
+       if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
+               signal(SIGHUP, sighup);
+       if (signal(SIGTRAP, SIG_IGN) != SIG_IGN)
+               signal(SIGTRAP, sigtrap);
+       if (signal(SIGFPE, SIG_IGN) != SIG_IGN)
+               signal(SIGFPE, sigfpe);
+       if (signal(SIGBUS, SIG_IGN) != SIG_IGN)
+               signal(SIGBUS, sigbus);
+       if (signal(SIGSEGV, SIG_IGN) != SIG_IGN)
+               signal(SIGSEGV, sigsegv);
+       if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
+               signal(SIGTERM, sigterm);
        
 
        if (signal(SIGINT, interrupt) == SIG_IGN)
        
 
        if (signal(SIGINT, interrupt) == SIG_IGN)
@@ -259,40 +279,51 @@ main(argc, argv)
        bmapest(clrmap);
        bmapest(nodmap);
 
        bmapest(clrmap);
        bmapest(nodmap);
 
-       if (cartridge) {
-               /* Estimate number of tapes, assuming streaming stops at
-                  the end of each block written, and not in mid-block.
-                  Assume no erroneous blocks; this can be compensated for
-                  with an artificially low tape size. */
-               fetapes = 
-               (         esize         /* blocks */
-                       * TP_BSIZE      /* bytes/block */
-                       * (1.0/density) /* 0.1" / byte */
-                 +
-                         esize         /* blocks */
-                       * (1.0/ntrec)   /* streaming-stops per block */
-                       * 15.48         /* 0.1" / streaming-stop */
-               ) * (1.0 / tsize );     /* tape / 0.1" */
-       } else {
-               /* Estimate number of tapes, for old fashioned 9-track tape */
-               int tenthsperirg = (density == 625) ? 3 : 7;
-               fetapes =
-               (         esize         /* blocks */
-                       * TP_BSIZE      /* bytes / block */
-                       * (1.0/density) /* 0.1" / byte */
-                 +
-                         esize         /* blocks */
-                       * (1.0/ntrec)   /* IRG's / block */
-                       * tenthsperirg  /* 0.1" / IRG */
-               ) * (1.0 / tsize );     /* tape / 0.1" */
+       if (pipeout)
+               esize += 10;    /* 10 trailer blocks */
+       else {
+               if (blocksperfile)
+                       fetapes = esize / blocksperfile;
+               else if (cartridge) {
+                       /* Estimate number of tapes, assuming streaming stops at
+                          the end of each block written, and not in mid-block.
+                          Assume no erroneous blocks; this can be compensated
+                          for with an artificially low tape size. */
+                       fetapes = 
+                       (         esize         /* blocks */
+                               * TP_BSIZE      /* bytes/block */
+                               * (1.0/density) /* 0.1" / byte */
+                         +
+                                 esize         /* blocks */
+                               * (1.0/ntrec)   /* streaming-stops per block */
+                               * 15.48         /* 0.1" / streaming-stop */
+                       ) * (1.0 / tsize );     /* tape / 0.1" */
+               } else {
+                       /* Estimate number of tapes, for old fashioned 9-track
+                          tape */
+                       int tenthsperirg = (density == 625) ? 3 : 7;
+                       fetapes =
+                       (         esize         /* blocks */
+                               * TP_BSIZE      /* bytes / block */
+                               * (1.0/density) /* 0.1" / byte */
+                         +
+                                 esize         /* blocks */
+                               * (1.0/ntrec)   /* IRG's / block */
+                               * tenthsperirg  /* 0.1" / IRG */
+                       ) * (1.0 / tsize );     /* tape / 0.1" */
+               }
+               etapes = fetapes;               /* truncating assignment */
+               etapes++;
+               /* count the nodemap on each additional tape */
+               for (i = 1; i < etapes; i++)
+                       bmapest(nodmap);
+               esize += i + 10;        /* headers + 10 trailer blocks */
        }
        }
-       etapes = fetapes;               /* truncating assignment */
-       etapes++;
-       /* count the nodemap on each additional tape */
-       for (i = 1; i < etapes; i++)
-               bmapest(nodmap);
-       esize += i + 10;        /* headers + 10 trailer blocks */
-       msg("estimated %ld tape blocks on %3.2f tape(s).\n", esize, fetapes);
+       if (pipeout)
+               msg("estimated %ld tape blocks.\n", esize);
+       else
+               msg("estimated %ld tape blocks on %3.2f tape(s).\n",
+                   esize, fetapes);
 
        alloctape();                    /* Allocate tape buffer */
 
 
        alloctape();                    /* Allocate tape buffer */
 
@@ -311,7 +342,11 @@ main(argc, argv)
        for(i=0; i<ntrec; i++)
                spclrec();
 #endif
        for(i=0; i<ntrec; i++)
                spclrec();
 #endif
-       msg("DUMP: %ld tape blocks on %d tape(s)\n",spcl.c_tapea,spcl.c_volume);
+       if (pipeout)
+               msg("DUMP: %ld tape blocks\n",spcl.c_tapea);
+       else
+               msg("DUMP: %ld tape blocks on %d volumes(s)\n",
+                   spcl.c_tapea, spcl.c_volume);
        msg("DUMP IS DONE\n");
 
        putitime();
        msg("DUMP IS DONE\n");
 
        putitime();
index 7577214..f86971e 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)tape.c     5.12 (Berkeley) %G%";
+static char sccsid[] = "@(#)tape.c     5.13 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "dump.h"
 #endif /* not lint */
 
 #include "dump.h"
@@ -19,6 +19,7 @@ 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 */
 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 long blocksperfile;     /* number of blocks per output file */
 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();
@@ -120,16 +121,15 @@ void
 tperror()
 {
        if (pipeout) {
 tperror()
 {
        if (pipeout) {
-               msg("Tape write error on %s\n", tape);
+               msg("write error on %s\n", tape);
                quit("Cannot recover\n");
                /* NOTREACHED */
        }
                quit("Cannot recover\n");
                /* NOTREACHED */
        }
-       msg("Tape write error %d feet into tape %d\n", asize/120L, tapeno);
-       broadcast("TAPE ERROR!\n");
+       msg("write error %d blocks into volume %d\n", blockswritten, tapeno);
+       broadcast("DUMP WRITE ERROR!\n");
        if (!query("Do you want to restart?"))
                dumpabort();
        if (!query("Do you want to restart?"))
                dumpabort();
-       msg("This tape will rewind.  After it is rewound,\n");
-       msg("replace the faulty tape with a new one;\n");
+       msg("Closing this volume.  Prepare to restart with new media;\n");
        msg("this dump volume will be rewritten.\n");
        killall();
        nogripe = 1;
        msg("this dump volume will be rewritten.\n");
        killall();
        nogripe = 1;
@@ -171,7 +171,8 @@ flusht()
        trecno = 0;
        asize += tenths;
        blockswritten += ntrec;
        trecno = 0;
        asize += tenths;
        blockswritten += ntrec;
-       if (!pipeout && asize > tsize) {
+       if (!pipeout && (blocksperfile ?
+           (blockswritten >= blocksperfile) : (asize > tsize))) {
                close_rewind();
                otape();
        }
                close_rewind();
                otape();
        }
@@ -210,10 +211,10 @@ close_rewind()
 {
        trewind();
        if (!nogripe) {
 {
        trewind();
        if (!nogripe) {
-               msg("Change Tapes: Mount tape #%d\n", tapeno+1);
-               broadcast("CHANGE TAPES!\7\7\n");
+               msg("Change Volumes: Mount volume #%d\n", tapeno+1);
+               broadcast("CHANGE DUMP VOLUMES!\7\7\n");
        }
        }
-       while (!query("Is the new tape mounted and ready to go?"))
+       while (!query("Is the new volume mounted and ready to go?"))
                if (query("Do you want to abort?")) {
                        dumpabort();
                        /*NOTREACHED*/
                if (query("Do you want to abort?")) {
                        dumpabort();
                        /*NOTREACHED*/
@@ -315,7 +316,7 @@ otape()
                while ((to = pipeout ? 1 : creat(tape, 0666)) < 0)
 #endif RDUMP
                    {
                while ((to = pipeout ? 1 : creat(tape, 0666)) < 0)
 #endif RDUMP
                    {
-                       msg("Cannot open tape \"%s\".\n", tape);
+                       msg("Cannot open output \"%s\".\n", tape);
                        if (!query("Do you want to retry the open?"))
                                dumpabort();
                }
                        if (!query("Do you want to retry the open?"))
                                dumpabort();
                }