-static char *sccsid = "@(#)main.c 1.14 (Berkeley) %G%";
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)main.c 5.9 (Berkeley) %G%";
+#endif not lint
+
#include "dump.h"
+#include "pathnames.h"
int notify = 0; /* notify operator flag */
int blockswritten = 0; /* number of blocks written on current tape */
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 */
#ifdef RDUMP
char *host;
#endif
+int anydskipped; /* set true in mark() if any directories are skipped */
+ /* this lets us avoid map pass 2 in some cases */
main(argc, argv)
int argc;
char *argv[];
{
char *arg;
- int i;
+ int bflag = 0, i;
float fetapes;
register struct fstab *dt;
time(&(spcl.c_date));
tsize = 0; /* Default later, based on 'c' option for cart tapes */
- tape = TAPE;
- disk = DISK;
- increm = NINCREM;
- temp = TEMP;
+ tape = _PATH_DEFTAPE;
+ disk = _PATH_DEFDISK;
+ increm = _PATH_DUMPDATES;
+ temp = _PATH_DTMP;
if (TP_BSIZE / DEV_BSIZE == 0 || TP_BSIZE % DEV_BSIZE != 0) {
msg("TP_BSIZE must be a multiple of DEV_BSIZE\n");
dumpabort();
argv++;
argc--;
density = atoi(*argv) / 10;
+ if (density >= 625 && !bflag)
+ ntrec = HIGHDENSITYTREC;
}
break;
if(argc > 1) {
argv++;
argc--;
+ bflag++;
ntrec = atol(*argv);
}
break;
* 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)
+ * cartridge 8000 bpi (100 bytes/.1") 1700 ft. (450*4 - slop)
*/
if (density == 0)
density = cartridge ? 100 : 160;
if (tsize == 0)
- tsize = cartridge ? 4000L*120L : 2300L*120L;
+ tsize = cartridge ? 1700L*120L : 2300L*120L;
#ifdef RDUMP
{ char *index();
host = tape;
tape = index(host, ':');
if (tape == 0) {
- msg("need keyletter ``f'' and device ``host:tape''");
+ msg("need keyletter ``f'' and device ``host:tape''\n");
exit(1);
}
*tape++ = 0;
if (rmthost(host) == 0)
exit(X_ABORT);
}
+ setuid(getuid()); /* rmthost() is the only reason to be setuid */
#endif
if (signal(SIGHUP, sighup) == SIG_IGN)
signal(SIGHUP, SIG_IGN);
* the file system name with or without the leading '/'.
*/
dt = fstabsearch(disk);
- if (dt != 0)
+ if (dt != 0) {
disk = rawname(dt->fs_spec);
+ strncpy(spcl.c_dev, dt->fs_spec, NAMELEN);
+ strncpy(spcl.c_filesys, dt->fs_file, NAMELEN);
+ } else {
+ strncpy(spcl.c_dev, disk, NAMELEN);
+ strncpy(spcl.c_filesys, "an unlisted file system", NAMELEN);
+ }
+ strcpy(spcl.c_label, "none");
+ gethostname(spcl.c_host, NAMELEN);
+ spcl.c_level = incno - '0';
+ spcl.c_type = TS_TAPE;
getitime(); /* /etc/dumpdates snarfed */
msg("Date of this level %c dump: %s\n", incno, prdate(spcl.c_date));
esize = 0;
sblock = (struct fs *)buf;
sync();
- bread(SBLOCK, sblock, SBSIZE);
+ bread(SBOFF, sblock, SBSIZE);
if (sblock->fs_magic != FS_MAGIC) {
msg("bad sblock magic number\n");
dumpabort();
}
+ dev_bsize = sblock->fs_fsize / fsbtodb(sblock, 1);
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));
+ anydskipped = 0;
msg("mapping (Pass I) [regular files]\n");
pass(mark, (char *)NULL); /* mark updates esize */
- do {
+ if (anydskipped) {
+ do {
+ msg("mapping (Pass II) [directories]\n");
+ nadded = 0;
+ pass(add, dirmap);
+ } while(nadded);
+ } else /* keep the operators happy */
msg("mapping (Pass II) [directories]\n");
- nadded = 0;
- pass(add, dirmap);
- } while(nadded);
bmapest(clrmap);
bmapest(nodmap);
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 */
bitmap(clrmap, TS_CLRI);
msg("dumping (Pass III) [directories]\n");
- pass(dump, dirmap);
+ pass(dirdump, dirmap);
msg("dumping (Pass IV) [regular files]\n");
pass(dump, nodmap);
#ifndef RDUMP
if (!pipeout) {
close(to);
- rewind();
+ trewind();
}
#else
tflush(1);
- rewind();
+ trewind();
#endif
broadcast("DUMP IS DONE!\7\7\n");
Exit(X_FINOK);