merge from sun
authorSam Leffler <sam@ucbvax.Berkeley.EDU>
Sat, 12 Feb 1983 04:58:45 +0000 (20:58 -0800)
committerSam Leffler <sam@ucbvax.Berkeley.EDU>
Sat, 12 Feb 1983 04:58:45 +0000 (20:58 -0800)
SCCS-vsn: sbin/dump/Makefile 1.10
SCCS-vsn: sbin/dump/main.c 1.11
SCCS-vsn: sbin/dump/optr.c 1.6
SCCS-vsn: sbin/dump/tape.c 1.6
SCCS-vsn: sbin/dump/traverse.c 1.13

usr/src/sbin/dump/Makefile
usr/src/sbin/dump/main.c
usr/src/sbin/dump/optr.c
usr/src/sbin/dump/tape.c
usr/src/sbin/dump/traverse.c

index 3546c7f..2901399 100644 (file)
@@ -1,4 +1,4 @@
-# sccsid = "@(#)Makefile       1.9 (Berkeley) %G%"
+# sccsid = "@(#)Makefile       1.10 (Berkeley) %G%"
 #
 #      dump.h                  header file
 #      dumpitime.c             reads /etc/ddate
 #
 #      dump.h                  header file
 #      dumpitime.c             reads /etc/ddate
@@ -41,11 +41,13 @@ install: rdump dump
        install -s rdump $(DESTDIR)/etc
        install -s dump $(DESTDIR)/etc
 
        install -s rdump $(DESTDIR)/etc
        install -s dump $(DESTDIR)/etc
 
-dumprmain.o: dumprmain.c
-       cc -c -DRDUMP dumprmain.c
+dumprmain.o: dumpmain.c
+       cp dumpmain.c dumprmain.c
+       ${CC} -c -DRDUMP ${CFLAGS} dumprmain.c
+       rm -f dumprmain.c
 
 clean:
 
 clean:
-       rm -f *.o rdump dump errs
+       rm -f *.o rdump dump errs dumprmain.c
 
 lint:
        lint $(DFLAGS) $(SRCS)
 
 lint:
        lint $(DFLAGS) $(SRCS)
index 78a3b8c..2eb3a78 100644 (file)
@@ -1,10 +1,12 @@
-static char *sccsid = "@(#)main.c      1.10 (Berkeley) %G%";
+static char *sccsid = "@(#)main.c      1.11 (Berkeley) %G%";
 #include "dump.h"
 
 int    notify = 0;     /* notify operator flag */
 int    blockswritten = 0;      /* number of blocks written on current tape */
 int    tapeno = 0;     /* current tape number */
 #include "dump.h"
 
 int    notify = 0;     /* notify operator flag */
 int    blockswritten = 0;      /* number of blocks written on current tape */
 int    tapeno = 0;     /* current tape number */
-int    density = 160;  /* density in 0.1" units */
+int    density = 0;    /* density in bytes/0.1" */
+int    ntrec = NTREC;  /* # tape blocks in each tape record */
+int    cartridge = 0;  /* Assume non-cartridge tape */
 #ifdef RDUMP
 char   *host;
 #endif
 #ifdef RDUMP
 char   *host;
 #endif
@@ -20,7 +22,7 @@ main(argc, argv)
 
        time(&(spcl.c_date));
 
 
        time(&(spcl.c_date));
 
-       tsize = 2300L*12L*10L;
+       tsize = 0;      /* Default later, based on 'c' option for cart tapes */
        tape = TAPE;
        disk = DISK;
        increm = NINCREM;
        tape = TAPE;
        disk = DISK;
        increm = NINCREM;
@@ -79,6 +81,18 @@ main(argc, argv)
                }
                break;
 
                }
                break;
 
+       case 'b':                       /* blocks per tape write */
+               if(argc > 1) {
+                       argv++;
+                       argc--;
+                       ntrec = atol(*argv);
+               }
+               break;
+
+       case 'c':                       /* Tape is cart. not 9-track */
+               cartridge++;
+               break;
+
        case '0':                       /* dump level */
        case '1':
        case '2':
        case '0':                       /* dump level */
        case '1':
        case '2':
@@ -109,6 +123,20 @@ main(argc, argv)
                argc--;
                disk = *argv;
        }
                argc--;
                disk = *argv;
        }
+
+       /*
+        * 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")        4000 ft. (450*9 - slop)
+        */
+       if (density == 0)
+               density = cartridge ? 100 : 160;
+       if (tsize == 0)
+               tsize = cartridge ? 4000L*120L : 2300L*120L;
+
 #ifdef RDUMP
        { char *index();
          host = tape;
 #ifdef RDUMP
        { char *index();
          host = tape;
@@ -194,16 +222,34 @@ main(argc, argv)
        bmapest(clrmap);
        bmapest(nodmap);
 
        bmapest(clrmap);
        bmapest(nodmap);
 
-       fetapes =
+       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 */
                (         esize         /* blocks */
                        * TP_BSIZE      /* bytes / block */
                        * (1.0/density) /* 0.1" / byte */
                  +
                          esize         /* blocks */
-                       * (1.0/NTREC)   /* IRG's / block */
+                       * (1.0/ntrec)   /* IRG's / block */
+                       * tenthsperirg  /* 0.1" / IRG */
                        * 7             /* 0.1" / IRG */
                        * 7             /* 0.1" / IRG */
-               ) * (1.0 / tsize )      /* tape / 0.1" */
-       ;
+               ) * (1.0 / tsize );     /* tape / 0.1" */
+       }
        etapes = fetapes;               /* truncating assignment */
        etapes++;
        /* count the nodemap on each additional tape */
        etapes = fetapes;               /* truncating assignment */
        etapes++;
        /* count the nodemap on each additional tape */
@@ -212,6 +258,8 @@ main(argc, argv)
        esize += i + 10;        /* headers + 10 trailer blocks */
        msg("estimated %ld tape blocks on %3.2f tape(s).\n", esize, fetapes);
 
        esize += i + 10;        /* headers + 10 trailer blocks */
        msg("estimated %ld tape blocks on %3.2f tape(s).\n", esize, fetapes);
 
+       alloctape();                    /* Allocate tape buffer */
+
        otape();                        /* bitmap is the first to tape write */
        time(&(tstart_writing));
        bitmap(clrmap, TS_CLRI);
        otape();                        /* bitmap is the first to tape write */
        time(&(tstart_writing));
        bitmap(clrmap, TS_CLRI);
@@ -224,7 +272,7 @@ main(argc, argv)
 
        spcl.c_type = TS_END;
 #ifndef RDUMP
 
        spcl.c_type = TS_END;
 #ifndef RDUMP
-       for(i=0; i<NTREC; i++)
+       for(i=0; i<ntrec; i++)
                spclrec();
 #endif
        msg("DUMP: %ld tape blocks on %d tape(s)\n",spcl.c_tapea,spcl.c_volume);
                spclrec();
 #endif
        msg("DUMP: %ld tape blocks on %d tape(s)\n",spcl.c_tapea,spcl.c_volume);
index 602943a..7c75584 100644 (file)
@@ -1,4 +1,4 @@
-static char *sccsid = "@(#)optr.c      1.5 (Berkeley) %G%";
+static char *sccsid = "@(#)optr.c      1.6 (Berkeley) %G%";
 
 #include "dump.h"
 
 
 #include "dump.h"
 
@@ -382,7 +382,7 @@ lastdump(arg)
                  fprintf(stdout,"%c %8s\t(%6s) Last dump: Level %c, Date %s\n",
                        dumpme && (arg != 'w') ? '>' : ' ',
                        itwalk->id_name,
                  fprintf(stdout,"%c %8s\t(%6s) Last dump: Level %c, Date %s\n",
                        dumpme && (arg != 'w') ? '>' : ' ',
                        itwalk->id_name,
-                       dt ? dt->fs_file : 0,
+                       dt ? dt->fs_file : "",
                        itwalk->id_incno,
                        date
                    );
                        itwalk->id_incno,
                        date
                    );
index 9851fa3..f588c70 100644 (file)
@@ -1,8 +1,28 @@
-static char *sccsid = "@(#)tape.c      1.5 (Berkeley) %G%";
+static char *sccsid = "@(#)tape.c      1.6 (Berkeley) %G%";
 #include "dump.h"
 
 #include "dump.h"
 
-char   tblock[NTREC][TP_BSIZE];
+char   (*tblock)[TP_BSIZE];    /* Pointer to malloc()ed buffer for tape */
+int    writesize;              /* Size of malloc()ed buffer for tape */
 int    trecno = 0;
 int    trecno = 0;
+extern int ntrec;              /* blocking factor on tape */
+
+/*
+ * Allocate the buffer for tape operations.
+ *
+ * Depends on global variable ntrec, set from 'b' option in command line.
+ * Returns 1 if successful, 0 if failed.
+ *
+ * For later kernel performance improvement, this buffer should be allocated
+ * on a page boundary.
+ */
+alloctape()
+{
+
+       writesize = ntrec * TP_BSIZE;
+       tblock = (char (*)[TP_BSIZE])malloc(writesize);
+       return (tblock != NULL);
+}
+
 
 taprec(dp)
        char *dp;
 
 taprec(dp)
        char *dp;
@@ -13,7 +33,7 @@ taprec(dp)
                tblock[trecno][i] = *dp++;
        trecno++;
        spcl.c_tapea++;
                tblock[trecno][i] = *dp++;
        trecno++;
        spcl.c_tapea++;
-       if(trecno >= NTREC)
+       if(trecno >= ntrec)
                flusht();
 }
 
                flusht();
 }
 
@@ -25,7 +45,7 @@ dmpblk(blkno, size)
 
        if (size % TP_BSIZE != 0)
                msg("bad size to dmpblk: %d\n", size);
 
        if (size % TP_BSIZE != 0)
                msg("bad size to dmpblk: %d\n", size);
-       avail = NTREC - trecno;
+       avail = ntrec - trecno;
        dblkno = fsbtodb(sblock, blkno);
        for (tpblks = size / TP_BSIZE; tpblks > avail; ) {
                bread(dblkno, tblock[trecno], TP_BSIZE * avail);
        dblkno = fsbtodb(sblock, blkno);
        for (tpblks = size / TP_BSIZE; tpblks > avail; ) {
                bread(dblkno, tblock[trecno], TP_BSIZE * avail);
@@ -34,12 +54,12 @@ dmpblk(blkno, size)
                flusht();
                dblkno += avail * (TP_BSIZE / DEV_BSIZE);
                tpblks -= avail;
                flusht();
                dblkno += avail * (TP_BSIZE / DEV_BSIZE);
                tpblks -= avail;
-               avail = NTREC - trecno;
+               avail = ntrec - trecno;
        }
        bread(dblkno, tblock[trecno], TP_BSIZE * tpblks);
        trecno += tpblks;
        spcl.c_tapea += tpblks;
        }
        bread(dblkno, tblock[trecno], TP_BSIZE * tpblks);
        trecno += tpblks;
        spcl.c_tapea += tpblks;
-       if(trecno >= NTREC)
+       if(trecno >= ntrec)
                flusht();
 }
 
                flusht();
 }
 
@@ -51,7 +71,7 @@ flusht()
        daddr_t d;
 
        trecno = 0;
        daddr_t d;
 
        trecno = 0;
-       if (write(to, tblock[0], sizeof(tblock)) != sizeof(tblock) ){
+       if (write(to, tblock[0], writesize) != writesize){
                msg("Tape write error on tape %d\n", tapeno);
                broadcast("TAPE ERROR!\n");
                if (query("Do you want to restart?")){
                msg("Tape write error on tape %d\n", tapeno);
                broadcast("TAPE ERROR!\n");
                if (query("Do you want to restart?")){
@@ -73,9 +93,9 @@ flusht()
                }
        }
 
                }
        }
 
-       asize += sizeof(tblock)/density;
+       asize += writesize/density;
        asize += 7;
        asize += 7;
-       blockswritten += NTREC;
+       blockswritten += ntrec;
        if (asize > tsize) {
                close_rewind();
                otape();
        if (asize > tsize) {
                close_rewind();
                otape();
index 849f231..a16ca73 100644 (file)
@@ -1,4 +1,4 @@
-static char *sccsid = "@(#)traverse.c  1.12 (Berkeley) %G%";
+static char *sccsid = "@(#)traverse.c  1.13 (Berkeley) %G%";
 
 #include "dump.h"
 
 
 #include "dump.h"
 
@@ -146,7 +146,7 @@ dmpindir(blk, lvl, size)
        if (blk != 0)
                bread(fsbtodb(sblock, blk), (char *)idblk, sblock->fs_bsize);
        else
        if (blk != 0)
                bread(fsbtodb(sblock, blk), (char *)idblk, sblock->fs_bsize);
        else
-               blkclr(idblk, sblock->fs_bsize);
+               bzero(idblk, sblock->fs_bsize);
        if (lvl <= 0) {
                if (*size < NINDIR(sblock) * sblock->fs_bsize)
                        cnt = howmany(*size, sblock->fs_fsize);
        if (lvl <= 0) {
                if (*size < NINDIR(sblock) * sblock->fs_bsize)
                        cnt = howmany(*size, sblock->fs_fsize);
@@ -315,10 +315,3 @@ bread(da, ba, c)
                }
        }
 }
                }
        }
 }
-
-blkclr(cp, size)
-       char *cp;
-       long size;
-{
-       asm("movc5      $0,(r0),$0,8(ap),*4(ap)");
-}