-static char *sccsid = "@(#)main.c 1.1 (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 */
-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
main(argc, argv)
int argc;
char *argv[];
{
char *arg;
- register i;
+ int i;
float fetapes;
register struct fstab *dt;
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;
-
+ if (TP_BSIZE / DEV_BSIZE == 0 || TP_BSIZE % DEV_BSIZE != 0) {
+ msg("TP_BSIZE must be a multiple of DEV_BSIZE\n");
+ dumpabort();
+ }
incno = '9';
uflag = 0;
arg = "u";
}
while(*arg)
switch (*arg++) {
+ case 'w':
+ lastdump('w'); /* tell us only what has to be done */
+ exit(0);
+ break;
case 'W': /* what to do */
- lastdump();
+ lastdump('W'); /* tell us the current state of what has been done */
exit(0); /* do nothing else */
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':
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;
+ tape = index(host, ':');
+ if (tape == 0) {
+ msg("need keyletter ``f'' and device ``host:tape''");
+ exit(1);
+ }
+ *tape++ = 0;
+ if (rmthost(host) == 0)
+ exit(X_ABORT);
+ }
+#endif
if (signal(SIGHUP, sighup) == SIG_IGN)
signal(SIGHUP, SIG_IGN);
if (signal(SIGTRAP, sigtrap) == SIG_IGN)
msg("Dumping %s ", disk);
if (dt != 0)
msgtail("(%s) ", dt->fs_file);
+#ifdef RDUMP
+ msgtail("to %s on host %s\n", tape, host);
+#else
msgtail("to %s\n", tape);
+#endif
fi = open(disk, 0);
if (fi < 0) {
msg("Cannot open %s\n", disk);
Exit(X_ABORT);
}
- CLR(clrmap);
- CLR(dirmap);
- CLR(nodmap);
esize = 0;
+ sblock = (struct fs *)buf;
+ sync();
+ bread(SBLOCK, sblock, SBSIZE);
+ if (sblock->fs_magic != FS_MAGIC) {
+ msg("bad sblock magic number\n");
+ dumpabort();
+ }
+ msiz = roundup(howmany(sblock->fs_ipg * sblock->fs_ncg, NBBY),
+ TP_BSIZE);
+ clrmap = (char *)calloc(msiz, sizeof(char));
+ dirmap = (char *)calloc(msiz, sizeof(char));
+ nodmap = (char *)calloc(msiz, sizeof(char));
msg("mapping (Pass I) [regular files]\n");
- pass(mark, (short *)NULL); /* mark updates esize */
+ pass(mark, (char *)NULL); /* mark updates esize */
do {
msg("mapping (Pass II) [directories]\n");
bmapest(clrmap);
bmapest(nodmap);
- fetapes =
- ( esize /* blocks */
- *BSIZE /* bytes / block */
- *(1.0/density) /* 0.1" / byte */
+ 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) /* IRG's / block */
- *7 /* 0.1" / IRG */
- ) * (1.0 / tsize ) /* tape / 0.1" */
- ;
+ 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 */
+ * 7 /* 0.1" / IRG */
+ ) * (1.0 / tsize ); /* tape / 0.1" */
+ }
etapes = fetapes; /* truncating assignment */
etapes++;
- /*
- * esize is typically about 5% too low; we frob it here
- */
- esize += ((5*esize)/100);
+ /* 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);
+ alloctape(); /* Allocate tape buffer */
+
otape(); /* bitmap is the first to tape write */
time(&(tstart_writing));
bitmap(clrmap, TS_CLRI);
pass(dump, nodmap);
spcl.c_type = TS_END;
- for(i=0; i<NTREC; i++)
+#ifndef RDUMP
+ for(i=0; i<ntrec; i++)
spclrec();
+#endif
msg("DUMP: %ld tape blocks on %d tape(s)\n",spcl.c_tapea,spcl.c_volume);
msg("DUMP IS DONE\n");
putitime();
+#ifndef RDUMP
close(to);
+#else
+ tflush(1);
+#endif
rewind();
broadcast("DUMP IS DONE!\7\7\n");
Exit(X_FINOK);
char *cp;
{
static char rawbuf[32];
+ char *rindex();
char *dp = rindex(cp, '/');
if (dp == 0)