|
|
1.1 ! root 1: static char *sccsid = "@(#)dumpmain.c 1.2 (Berkeley) 10/16/80"; ! 2: #include "dump.h" ! 3: #include <string.h> ! 4: ! 5: int notify = 0; /* notify operator flag */ ! 6: int blockswritten = 0; /* number of blocks written on current tape */ ! 7: int tapeno = 0; /* current tape number */ ! 8: int density = 625; /* density in 0.1" units */ ! 9: ! 10: main(argc, argv) ! 11: int argc; ! 12: char *argv[]; ! 13: { ! 14: char *arg; ! 15: register i; ! 16: float fetapes; ! 17: register struct fstab *dt; ! 18: ! 19: time(&(spcl.c_date)); ! 20: ! 21: tsize = 2300L*12L*10L; ! 22: tape = TAPE; ! 23: disk = DISK; ! 24: increm = NINCREM; ! 25: ! 26: incno = '9'; ! 27: uflag = 0; ! 28: arg = "u"; ! 29: if(argc > 1) { ! 30: argv++; ! 31: argc--; ! 32: arg = *argv; ! 33: if (*arg == '-') ! 34: argc++; ! 35: } ! 36: while(*arg) ! 37: switch (*arg++) { ! 38: case 'w': ! 39: lastdump('w'); /* tell us only what has to be done */ ! 40: exit(0); ! 41: break; ! 42: case 'W': /* what to do */ ! 43: lastdump('W'); /* tell us the current state of what has been done */ ! 44: exit(0); /* do nothing else */ ! 45: break; ! 46: ! 47: case 'J': /* update old to new */ ! 48: o_nconvert(); ! 49: exit(0); /* do nothing else */ ! 50: break; ! 51: ! 52: case 'f': /* output file */ ! 53: if(argc > 1) { ! 54: argv++; ! 55: argc--; ! 56: tape = *argv; ! 57: } ! 58: break; ! 59: ! 60: case 'd': /* density, in bits per inch */ ! 61: if (argc > 1) { ! 62: argv++; ! 63: argc--; ! 64: density = atoi(*argv) / 10; ! 65: } ! 66: break; ! 67: ! 68: case 's': /* tape size, feet */ ! 69: if(argc > 1) { ! 70: argv++; ! 71: argc--; ! 72: tsize = atol(*argv); ! 73: tsize *= 12L*10L; ! 74: } ! 75: break; ! 76: ! 77: case '0': /* dump level */ ! 78: case '1': ! 79: case '2': ! 80: case '3': ! 81: case '4': ! 82: case '5': ! 83: case '6': ! 84: case '7': ! 85: case '8': ! 86: case '9': ! 87: incno = arg[-1]; ! 88: break; ! 89: ! 90: case 'u': /* update /etc/dumpdates */ ! 91: uflag++; ! 92: break; ! 93: ! 94: case 'n': /* notify operators */ ! 95: notify++; ! 96: break; ! 97: ! 98: default: ! 99: printf("bad key '%c%'\n", arg[-1]); ! 100: Exit(X_ABORT); ! 101: } ! 102: if(argc > 1) { ! 103: argv++; ! 104: argc--; ! 105: disk = *argv; ! 106: } ! 107: ! 108: if (signal(SIGHUP, sighup) == SIG_IGN) ! 109: signal(SIGHUP, SIG_IGN); ! 110: if (signal(SIGTRAP, sigtrap) == SIG_IGN) ! 111: signal(SIGTRAP, SIG_IGN); ! 112: if (signal(SIGFPE, sigfpe) == SIG_IGN) ! 113: signal(SIGFPE, SIG_IGN); ! 114: if (signal(SIGBUS, sigbus) == SIG_IGN) ! 115: signal(SIGBUS, SIG_IGN); ! 116: if (signal(SIGSEGV, sigsegv) == SIG_IGN) ! 117: signal(SIGSEGV, SIG_IGN); ! 118: if (signal(SIGTERM, sigterm) == SIG_IGN) ! 119: signal(SIGTERM, SIG_IGN); ! 120: ! 121: ! 122: if (signal(SIGINT, interrupt) == SIG_IGN) ! 123: signal(SIGINT, SIG_IGN); ! 124: ! 125: set_operators(); /* /etc/group snarfed */ ! 126: getfstab(); /* /etc/fstab snarfed */ ! 127: /* ! 128: * disk can be either the full special file name, ! 129: * the suffix of the special file name, ! 130: * the special name missing the leading '/', ! 131: * the file system name with or without the leading '/'. ! 132: */ ! 133: dt = fstabsearch(disk); ! 134: if (dt != 0) ! 135: disk = rawname(dt->fs_spec); ! 136: getitime(); /* /etc/dumpdates snarfed */ ! 137: ! 138: msg("Date of this level %c dump: %s\n", incno, prdate(spcl.c_date)); ! 139: msg("Date of last level %c dump: %s\n", incno, prdate(spcl.c_ddate)); ! 140: msg("Dumping %s ", disk); ! 141: if (dt != 0) ! 142: msgtail("(%s) ", dt->fs_file); ! 143: msgtail("to %s\n", tape); ! 144: ! 145: fi = open(disk, 0); ! 146: if (fi < 0) { ! 147: msg("Cannot open %s\n", disk); ! 148: Exit(X_ABORT); ! 149: } ! 150: CLR(clrmap); ! 151: CLR(dirmap); ! 152: CLR(nodmap); ! 153: esize = 0; ! 154: ! 155: msg("mapping (Pass I) [regular files]\n"); ! 156: pass(mark, (short *)NULL); /* mark updates esize */ ! 157: ! 158: do { ! 159: msg("mapping (Pass II) [directories]\n"); ! 160: nadded = 0; ! 161: pass(add, dirmap); ! 162: } while(nadded); ! 163: ! 164: bmapest(clrmap); ! 165: bmapest(nodmap); ! 166: ! 167: fetapes = ! 168: ( esize /* blocks */ ! 169: *BSIZE(0) /* bytes / block */ ! 170: *(1.0/density) /* 0.1" / byte */ ! 171: + ! 172: esize /* blocks */ ! 173: *(1.0/NTREC) /* IRG's / block */ ! 174: *7 /* 0.1" / IRG */ ! 175: ) * (1.0 / tsize ) /* tape / 0.1" */ ! 176: ; ! 177: etapes = fetapes; /* truncating assignment */ ! 178: etapes++; ! 179: /* ! 180: * esize is typically about 5% too low; we frob it here ! 181: */ ! 182: esize += ((5*esize)/100); ! 183: msg("estimated %ld tape blocks on %3.2f tape(s).\n", esize, fetapes); ! 184: ! 185: otape(); /* bitmap is the first to tape write */ ! 186: time(&(tstart_writing)); ! 187: bitmap(clrmap, TS_CLRI); ! 188: ! 189: msg("dumping (Pass III) [directories]\n"); ! 190: pass(dump, dirmap); ! 191: ! 192: msg("dumping (Pass IV) [regular files]\n"); ! 193: pass(dump, nodmap); ! 194: ! 195: spcl.c_type = TS_END; ! 196: for(i=0; i<NTREC; i++) ! 197: spclrec(); ! 198: msg("DUMP: %ld tape blocks on %d tape(s)\n",spcl.c_tapea,spcl.c_volume); ! 199: msg("DUMP IS DONE\n"); ! 200: ! 201: putitime(); ! 202: close(to); ! 203: rewind(); ! 204: broadcast("DUMP IS DONE!\7\7\n"); ! 205: Exit(X_FINOK); ! 206: } ! 207: ! 208: int sighup(){ msg("SIGHUP() try rewriting\n"); sigAbort();} ! 209: int sigtrap(){ msg("SIGTRAP() try rewriting\n"); sigAbort();} ! 210: int sigfpe(){ msg("SIGFPE() try rewriting\n"); sigAbort();} ! 211: int sigbus(){ msg("SIGBUS() try rewriting\n"); sigAbort();} ! 212: int sigsegv(){ msg("SIGSEGV() ABORTING!\n"); abort();} ! 213: int sigalrm(){ msg("SIGALRM() try rewriting\n"); sigAbort();} ! 214: int sigterm(){ msg("SIGTERM() try rewriting\n"); sigAbort();} ! 215: ! 216: sigAbort() ! 217: { ! 218: msg("Rewriting attempted as response to unknown signal.\n"); ! 219: fflush(stderr); ! 220: fflush(stdout); ! 221: close_rewind(); ! 222: exit(X_REWRITE); ! 223: } ! 224: ! 225: char *rawname(cp) ! 226: char *cp; ! 227: { ! 228: static char rawbuf[32]; ! 229: char *dp = strrchr(cp, '/'); ! 230: ! 231: if (dp == 0) ! 232: return (0); ! 233: *dp = 0; ! 234: strcpy(rawbuf, cp); ! 235: *dp = '/'; ! 236: strcat(rawbuf, "/r"); ! 237: strcat(rawbuf, dp+1); ! 238: return (rawbuf); ! 239: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.