X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/31cef89cb428866f787983e68246030321893df4..4b9ccde74dc34e450ed96bcd3d044f78cf393d8d:/usr/src/cmd/dumpdir.c diff --git a/usr/src/cmd/dumpdir.c b/usr/src/cmd/dumpdir.c index d091951c2d..29f67ae056 100644 --- a/usr/src/cmd/dumpdir.c +++ b/usr/src/cmd/dumpdir.c @@ -1,4 +1,4 @@ -static char *sccsid = "@(#)dumpdir.c 4.2 (Berkeley) 11/15/80"; +static char *sccsid = "@(#)dumpdir.c 4.4 (Berkeley) 2/28/81"; #define MAXINO 2000 #define BITS 8 #define MAXXTR 60 @@ -12,6 +12,7 @@ static char *sccsid = "@(#)dumpdir.c 4.2 (Berkeley) 11/15/80"; #include #include #include +#include #define MWORD(m,i) (m[(unsigned)(i-1)/MLEN]) #define MBIT(i) (1<<((unsigned)(i-1)%MLEN)) @@ -53,38 +54,56 @@ main(argc, argv) char *argv[]; { extern char *ctime(); + int interrupt(); mktemp(dirfile); + signal(SIGINT, interrupt); argv++; if (argc>=3 && *argv[0] == 'f') magtape = *++argv; df = fopen(dirfile, "w"); if (df == NULL) { printf("dumpdir: %s - cannot create directory temporary\n", dirfile); - exit(1); + quit(); } if ((mt = open(magtape, 0)) < 0) { printf("%s: cannot open tape\n", magtape); - exit(1); + quit(); } if (readhdr(&spcl) == 0) { printf("Tape is not a dump tape\n"); - exit(1); + quit(); } printf("Dump date: %s", ctime(&spcl.c_date)); printf("Dumped from: %s", ctime(&spcl.c_ddate)); if (checkvol(&spcl, 1) == 0) { printf("Tape is not volume 1 of the dump\n"); - exit(1); + quit(); } pass1(); /* This sets the various maps on the way by */ freopen(dirfile, "r", df); strcpy(prebuf, "/"); printem(prebuf, (ino_t) 2); + quit(); +} + +/* + * Interrupt -- Quit properly + */ + +interrupt() +{ + unlink(dirfile); + exit(1); +} + +quit() +{ + unlink(dirfile); exit(0); } - i = 0; + /* * Read the tape, bulding up a directory structure for extraction * by name @@ -223,9 +242,8 @@ char *b; for (i = 0; i < NTREC; i++) ((struct spcl *)&tbf[i*BSIZE])->c_magic = 0; bct = 0; - if ((i = read(mt, tbf, NTREC*BSIZE)) < 0) { - exit(1); - } + if ((i = read(mt, tbf, NTREC*BSIZE)) < 0) + quit(); if (i == 0) { bct = NTREC + 1; volno++;