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