dirs.c revision 1.11 1 /*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 */
38
39 #ifndef lint
40 /*static char sccsid[] = "from: @(#)dirs.c 8.5 (Berkeley) 8/31/94";*/
41 static char *rcsid = "$Id: dirs.c,v 1.11 1994/12/28 02:21:43 mycroft Exp $";
42 #endif /* not lint */
43
44 #include <sys/param.h>
45 #include <sys/file.h>
46 #include <sys/stat.h>
47 #include <sys/time.h>
48
49 #include <ufs/ffs/fs.h>
50 #include <ufs/ufs/dinode.h>
51 #include <ufs/ufs/dir.h>
52 #include <protocols/dumprestore.h>
53
54 #include <errno.h>
55 #include <stdio.h>
56 #include <stdlib.h>
57 #include <string.h>
58 #include <unistd.h>
59
60 #include <machine/endian.h>
61
62 #include "pathnames.h"
63 #include "restore.h"
64 #include "extern.h"
65
66 /*
67 * Symbol table of directories read from tape.
68 */
69 #define HASHSIZE 1000
70 #define INOHASH(val) (val % HASHSIZE)
71 struct inotab {
72 struct inotab *t_next;
73 ino_t t_ino;
74 long t_seekpt;
75 long t_size;
76 };
77 static struct inotab *inotab[HASHSIZE];
78
79 /*
80 * Information retained about directories.
81 */
82 struct modeinfo {
83 ino_t ino;
84 struct timeval timep[2];
85 mode_t mode;
86 uid_t uid;
87 gid_t gid;
88 int flags;
89 };
90
91 /*
92 * Definitions for library routines operating on directories.
93 */
94 #undef DIRBLKSIZ
95 #define DIRBLKSIZ 1024
96 struct rstdirdesc {
97 int dd_fd;
98 long dd_loc;
99 long dd_size;
100 char dd_buf[DIRBLKSIZ];
101 };
102
103 /*
104 * Global variables for this file.
105 */
106 static long seekpt;
107 static FILE *df, *mf;
108 static RST_DIR *dirp;
109 static char dirfile[32] = "#"; /* No file */
110 static char modefile[32] = "#"; /* No file */
111 static char dot[2] = "."; /* So it can be modified */
112
113 /*
114 * Format of old style directories.
115 */
116 #define ODIRSIZ 14
117 struct odirect {
118 u_short d_ino;
119 char d_name[ODIRSIZ];
120 };
121
122 static struct inotab *allocinotab __P((ino_t, struct dinode *, long));
123 static void dcvt __P((struct odirect *, struct direct *));
124 static void flushent __P((void));
125 static struct inotab *inotablookup __P((ino_t));
126 static RST_DIR *opendirfile __P((const char *));
127 static void putdir __P((char *, long));
128 static void putent __P((struct direct *));
129 static void rst_seekdir __P((RST_DIR *, long, long));
130 static long rst_telldir __P((RST_DIR *));
131 static struct direct *searchdir __P((ino_t, char *));
132
133 /*
134 * Extract directory contents, building up a directory structure
135 * on disk for extraction by name.
136 * If genmode is requested, save mode, owner, and times for all
137 * directories on the tape.
138 */
139 void
140 extractdirs(genmode)
141 int genmode;
142 {
143 register int i;
144 register struct dinode *ip;
145 struct inotab *itp;
146 struct direct nulldir;
147
148 vprintf(stdout, "Extract directories from tape\n");
149 (void) sprintf(dirfile, "%s/rstdir%d", _PATH_TMP, dumpdate);
150 df = fopen(dirfile, "w");
151 if (df == NULL) {
152 fprintf(stderr,
153 "restore: %s - cannot create directory temporary\n",
154 dirfile);
155 fprintf(stderr, "fopen: %s\n", strerror(errno));
156 done(1);
157 }
158 if (genmode != 0) {
159 (void) sprintf(modefile, "%s/rstmode%d", _PATH_TMP, dumpdate);
160 mf = fopen(modefile, "w");
161 if (mf == NULL) {
162 fprintf(stderr,
163 "restore: %s - cannot create modefile \n",
164 modefile);
165 fprintf(stderr, "fopen: %s\n", strerror(errno));
166 done(1);
167 }
168 }
169 nulldir.d_ino = 0;
170 nulldir.d_type = DT_DIR;
171 nulldir.d_namlen = 1;
172 (void) strcpy(nulldir.d_name, "/");
173 nulldir.d_reclen = DIRSIZ(0, &nulldir);
174 for (;;) {
175 curfile.name = "<directory file - name unknown>";
176 curfile.action = USING;
177 ip = curfile.dip;
178 if (ip == NULL || (ip->di_mode & IFMT) != IFDIR) {
179 (void) fclose(df);
180 dirp = opendirfile(dirfile);
181 if (dirp == NULL)
182 fprintf(stderr, "opendirfile: %s\n",
183 strerror(errno));
184 if (mf != NULL)
185 (void) fclose(mf);
186 i = dirlookup(dot);
187 if (i == 0)
188 panic("Root directory is not on tape\n");
189 return;
190 }
191 itp = allocinotab(curfile.ino, ip, seekpt);
192 getfile(putdir, xtrnull);
193 putent(&nulldir);
194 flushent();
195 itp->t_size = seekpt - itp->t_seekpt;
196 }
197 }
198
199 /*
200 * skip over all the directories on the tape
201 */
202 void
203 skipdirs()
204 {
205
206 while ((curfile.dip->di_mode & IFMT) == IFDIR) {
207 skipfile();
208 }
209 }
210
211 /*
212 * Recursively find names and inumbers of all files in subtree
213 * pname and pass them off to be processed.
214 */
215 void
216 treescan(pname, ino, todo)
217 char *pname;
218 ino_t ino;
219 long (*todo) __P((char *, ino_t, int));
220 {
221 register struct inotab *itp;
222 register struct direct *dp;
223 int namelen;
224 long bpt;
225 char locname[MAXPATHLEN + 1];
226
227 itp = inotablookup(ino);
228 if (itp == NULL) {
229 /*
230 * Pname is name of a simple file or an unchanged directory.
231 */
232 (void) (*todo)(pname, ino, LEAF);
233 return;
234 }
235 /*
236 * Pname is a dumped directory name.
237 */
238 if ((*todo)(pname, ino, NODE) == FAIL)
239 return;
240 /*
241 * begin search through the directory
242 * skipping over "." and ".."
243 */
244 (void) strncpy(locname, pname, MAXPATHLEN);
245 (void) strncat(locname, "/", MAXPATHLEN);
246 namelen = strlen(locname);
247 rst_seekdir(dirp, itp->t_seekpt, itp->t_seekpt);
248 dp = rst_readdir(dirp); /* "." */
249 if (dp != NULL && strcmp(dp->d_name, ".") == 0)
250 dp = rst_readdir(dirp); /* ".." */
251 else
252 fprintf(stderr, "Warning: `.' missing from directory %s\n",
253 pname);
254 if (dp != NULL && strcmp(dp->d_name, "..") == 0)
255 dp = rst_readdir(dirp); /* first real entry */
256 else
257 fprintf(stderr, "Warning: `..' missing from directory %s\n",
258 pname);
259 bpt = rst_telldir(dirp);
260 /*
261 * a zero inode signals end of directory
262 */
263 while (dp != NULL) {
264 locname[namelen] = '\0';
265 if (namelen + dp->d_namlen >= MAXPATHLEN) {
266 fprintf(stderr, "%s%s: name exceeds %d char\n",
267 locname, dp->d_name, MAXPATHLEN);
268 } else {
269 (void) strncat(locname, dp->d_name, (int)dp->d_namlen);
270 treescan(locname, dp->d_ino, todo);
271 rst_seekdir(dirp, bpt, itp->t_seekpt);
272 }
273 dp = rst_readdir(dirp);
274 bpt = rst_telldir(dirp);
275 }
276 }
277
278 /*
279 * Lookup a pathname which is always assumed to start from the ROOTINO.
280 */
281 struct direct *
282 pathsearch(pathname)
283 const char *pathname;
284 {
285 ino_t ino;
286 struct direct *dp;
287 char *path, *name, buffer[MAXPATHLEN];
288
289 strcpy(buffer, pathname);
290 path = buffer;
291 ino = ROOTINO;
292 while (*path == '/')
293 path++;
294 dp = NULL;
295 while ((name = strsep(&path, "/")) != NULL && *name != NULL) {
296 if ((dp = searchdir(ino, name)) == NULL)
297 return (NULL);
298 ino = dp->d_ino;
299 }
300 return (dp);
301 }
302
303 /*
304 * Lookup the requested name in directory inum.
305 * Return its inode number if found, zero if it does not exist.
306 */
307 static struct direct *
308 searchdir(inum, name)
309 ino_t inum;
310 char *name;
311 {
312 register struct direct *dp;
313 register struct inotab *itp;
314 int len;
315
316 itp = inotablookup(inum);
317 if (itp == NULL)
318 return (NULL);
319 rst_seekdir(dirp, itp->t_seekpt, itp->t_seekpt);
320 len = strlen(name);
321 do {
322 dp = rst_readdir(dirp);
323 if (dp == NULL)
324 return (NULL);
325 } while (dp->d_namlen != len || strncmp(dp->d_name, name, len) != 0);
326 return (dp);
327 }
328
329 /*
330 * Put the directory entries in the directory file
331 */
332 static void
333 putdir(buf, size)
334 char *buf;
335 long size;
336 {
337 struct direct cvtbuf;
338 register struct odirect *odp;
339 struct odirect *eodp;
340 register struct direct *dp;
341 long loc, i;
342
343 if (cvtflag) {
344 eodp = (struct odirect *)&buf[size];
345 for (odp = (struct odirect *)buf; odp < eodp; odp++)
346 if (odp->d_ino != 0) {
347 dcvt(odp, &cvtbuf);
348 putent(&cvtbuf);
349 }
350 } else {
351 for (loc = 0; loc < size; ) {
352 dp = (struct direct *)(buf + loc);
353 if (Bcvt)
354 swabst((u_char *)"ls", (u_char *) dp);
355 if (oldinofmt && dp->d_ino != 0) {
356 # if BYTE_ORDER == BIG_ENDIAN
357 if (Bcvt)
358 dp->d_namlen = dp->d_type;
359 # else
360 if (!Bcvt)
361 dp->d_namlen = dp->d_type;
362 # endif
363 dp->d_type = DT_UNKNOWN;
364 }
365 i = DIRBLKSIZ - (loc & (DIRBLKSIZ - 1));
366 if ((dp->d_reclen & 0x3) != 0 ||
367 dp->d_reclen > i ||
368 dp->d_reclen < DIRSIZ(0, dp) ||
369 dp->d_namlen > NAME_MAX) {
370 vprintf(stdout, "Mangled directory: ");
371 if ((dp->d_reclen & 0x3) != 0)
372 vprintf(stdout,
373 "reclen not multiple of 4 ");
374 if (dp->d_reclen < DIRSIZ(0, dp))
375 vprintf(stdout,
376 "reclen less than DIRSIZ (%d < %d) ",
377 dp->d_reclen, DIRSIZ(0, dp));
378 if (dp->d_namlen > NAME_MAX)
379 vprintf(stdout,
380 "reclen name too big (%d > %d) ",
381 dp->d_namlen, NAME_MAX);
382 vprintf(stdout, "\n");
383 loc += i;
384 continue;
385 }
386 loc += dp->d_reclen;
387 if (dp->d_ino != 0) {
388 putent(dp);
389 }
390 }
391 }
392 }
393
394 /*
395 * These variables are "local" to the following two functions.
396 */
397 char dirbuf[DIRBLKSIZ];
398 long dirloc = 0;
399 long prev = 0;
400
401 /*
402 * add a new directory entry to a file.
403 */
404 static void
405 putent(dp)
406 struct direct *dp;
407 {
408 dp->d_reclen = DIRSIZ(0, dp);
409 if (dirloc + dp->d_reclen > DIRBLKSIZ) {
410 ((struct direct *)(dirbuf + prev))->d_reclen =
411 DIRBLKSIZ - prev;
412 (void) fwrite(dirbuf, 1, DIRBLKSIZ, df);
413 dirloc = 0;
414 }
415 memcpy(dirbuf + dirloc, dp, (long)dp->d_reclen);
416 prev = dirloc;
417 dirloc += dp->d_reclen;
418 }
419
420 /*
421 * flush out a directory that is finished.
422 */
423 static void
424 flushent()
425 {
426 ((struct direct *)(dirbuf + prev))->d_reclen = DIRBLKSIZ - prev;
427 (void) fwrite(dirbuf, (int)dirloc, 1, df);
428 seekpt = ftell(df);
429 dirloc = 0;
430 }
431
432 static void
433 dcvt(odp, ndp)
434 register struct odirect *odp;
435 register struct direct *ndp;
436 {
437
438 memset(ndp, 0, (long)(sizeof *ndp));
439 ndp->d_ino = odp->d_ino;
440 ndp->d_type = DT_UNKNOWN;
441 (void) strncpy(ndp->d_name, odp->d_name, ODIRSIZ);
442 ndp->d_namlen = strlen(ndp->d_name);
443 ndp->d_reclen = DIRSIZ(0, ndp);
444 }
445
446 /*
447 * Seek to an entry in a directory.
448 * Only values returned by rst_telldir should be passed to rst_seekdir.
449 * This routine handles many directories in a single file.
450 * It takes the base of the directory in the file, plus
451 * the desired seek offset into it.
452 */
453 static void
454 rst_seekdir(dirp, loc, base)
455 register RST_DIR *dirp;
456 long loc, base;
457 {
458
459 if (loc == rst_telldir(dirp))
460 return;
461 loc -= base;
462 if (loc < 0)
463 fprintf(stderr, "bad seek pointer to rst_seekdir %d\n", loc);
464 (void) lseek(dirp->dd_fd, base + (loc & ~(DIRBLKSIZ - 1)), SEEK_SET);
465 dirp->dd_loc = loc & (DIRBLKSIZ - 1);
466 if (dirp->dd_loc != 0)
467 dirp->dd_size = read(dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ);
468 }
469
470 /*
471 * get next entry in a directory.
472 */
473 struct direct *
474 rst_readdir(dirp)
475 register RST_DIR *dirp;
476 {
477 register struct direct *dp;
478
479 for (;;) {
480 if (dirp->dd_loc == 0) {
481 dirp->dd_size = read(dirp->dd_fd, dirp->dd_buf,
482 DIRBLKSIZ);
483 if (dirp->dd_size <= 0) {
484 dprintf(stderr, "error reading directory\n");
485 return (NULL);
486 }
487 }
488 if (dirp->dd_loc >= dirp->dd_size) {
489 dirp->dd_loc = 0;
490 continue;
491 }
492 dp = (struct direct *)(dirp->dd_buf + dirp->dd_loc);
493 if (dp->d_reclen == 0 ||
494 dp->d_reclen > DIRBLKSIZ + 1 - dirp->dd_loc) {
495 dprintf(stderr, "corrupted directory: bad reclen %d\n",
496 dp->d_reclen);
497 return (NULL);
498 }
499 dirp->dd_loc += dp->d_reclen;
500 if (dp->d_ino == 0 && strcmp(dp->d_name, "/") == 0)
501 return (NULL);
502 if (dp->d_ino >= maxino) {
503 dprintf(stderr, "corrupted directory: bad inum %d\n",
504 dp->d_ino);
505 continue;
506 }
507 return (dp);
508 }
509 }
510
511 /*
512 * Simulate the opening of a directory
513 */
514 RST_DIR *
515 rst_opendir(name)
516 const char *name;
517 {
518 struct inotab *itp;
519 RST_DIR *dirp;
520 ino_t ino;
521
522 if ((ino = dirlookup(name)) > 0 &&
523 (itp = inotablookup(ino)) != NULL) {
524 dirp = opendirfile(dirfile);
525 rst_seekdir(dirp, itp->t_seekpt, itp->t_seekpt);
526 return (dirp);
527 }
528 return (NULL);
529 }
530
531 /*
532 * In our case, there is nothing to do when closing a directory.
533 */
534 void
535 rst_closedir(dirp)
536 RST_DIR *dirp;
537 {
538
539 (void)close(dirp->dd_fd);
540 free(dirp);
541 return;
542 }
543
544 /*
545 * Simulate finding the current offset in the directory.
546 */
547 static long
548 rst_telldir(dirp)
549 RST_DIR *dirp;
550 {
551 return ((long)lseek(dirp->dd_fd,
552 (off_t)0, SEEK_CUR) - dirp->dd_size + dirp->dd_loc);
553 }
554
555 /*
556 * Open a directory file.
557 */
558 static RST_DIR *
559 opendirfile(name)
560 const char *name;
561 {
562 register RST_DIR *dirp;
563 register int fd;
564
565 if ((fd = open(name, O_RDONLY)) == -1)
566 return (NULL);
567 if ((dirp = malloc(sizeof(RST_DIR))) == NULL) {
568 (void)close(fd);
569 return (NULL);
570 }
571 dirp->dd_fd = fd;
572 dirp->dd_loc = 0;
573 return (dirp);
574 }
575
576 /*
577 * Set the mode, owner, and times for all new or changed directories
578 */
579 void
580 setdirmodes(flags)
581 int flags;
582 {
583 FILE *mf;
584 struct modeinfo node;
585 struct entry *ep;
586 char *cp;
587
588 vprintf(stdout, "Set directory mode, owner, and times.\n");
589 (void) sprintf(modefile, "%s/rstmode%d", _PATH_TMP, dumpdate);
590 mf = fopen(modefile, "r");
591 if (mf == NULL) {
592 fprintf(stderr, "fopen: %s\n", strerror(errno));
593 fprintf(stderr, "cannot open mode file %s\n", modefile);
594 fprintf(stderr, "directory mode, owner, and times not set\n");
595 return;
596 }
597 clearerr(mf);
598 for (;;) {
599 (void) fread((char *)&node, 1, sizeof(struct modeinfo), mf);
600 if (feof(mf))
601 break;
602 ep = lookupino(node.ino);
603 if (command == 'i' || command == 'x') {
604 if (ep == NULL)
605 continue;
606 if ((flags & FORCE) == 0 && ep->e_flags & EXISTED) {
607 ep->e_flags &= ~NEW;
608 continue;
609 }
610 if (node.ino == ROOTINO &&
611 reply("set owner/mode for '.'") == FAIL)
612 continue;
613 }
614 if (ep == NULL) {
615 panic("cannot find directory inode %d\n", node.ino);
616 } else {
617 cp = myname(ep);
618 (void) chown(cp, node.uid, node.gid);
619 (void) chmod(cp, node.mode);
620 (void) chflags(cp, node.flags);
621 utimes(cp, node.timep);
622 ep->e_flags &= ~NEW;
623 }
624 }
625 if (ferror(mf))
626 panic("error setting directory modes\n");
627 (void) fclose(mf);
628 }
629
630 /*
631 * Generate a literal copy of a directory.
632 */
633 int
634 genliteraldir(name, ino)
635 char *name;
636 ino_t ino;
637 {
638 register struct inotab *itp;
639 int ofile, dp, i, size;
640 char buf[BUFSIZ];
641
642 itp = inotablookup(ino);
643 if (itp == NULL)
644 panic("Cannot find directory inode %d named %s\n", ino, name);
645 if ((ofile = open(name, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) {
646 fprintf(stderr, "%s: ", name);
647 (void) fflush(stderr);
648 fprintf(stderr, "cannot create file: %s\n", strerror(errno));
649 return (FAIL);
650 }
651 rst_seekdir(dirp, itp->t_seekpt, itp->t_seekpt);
652 dp = dup(dirp->dd_fd);
653 for (i = itp->t_size; i > 0; i -= BUFSIZ) {
654 size = i < BUFSIZ ? i : BUFSIZ;
655 if (read(dp, buf, (int) size) == -1) {
656 fprintf(stderr,
657 "write error extracting inode %d, name %s\n",
658 curfile.ino, curfile.name);
659 fprintf(stderr, "read: %s\n", strerror(errno));
660 done(1);
661 }
662 if (!Nflag && write(ofile, buf, (int) size) == -1) {
663 fprintf(stderr,
664 "write error extracting inode %d, name %s\n",
665 curfile.ino, curfile.name);
666 fprintf(stderr, "write: %s\n", strerror(errno));
667 done(1);
668 }
669 }
670 (void) close(dp);
671 (void) close(ofile);
672 return (GOOD);
673 }
674
675 /*
676 * Determine the type of an inode
677 */
678 int
679 inodetype(ino)
680 ino_t ino;
681 {
682 struct inotab *itp;
683
684 itp = inotablookup(ino);
685 if (itp == NULL)
686 return (LEAF);
687 return (NODE);
688 }
689
690 /*
691 * Allocate and initialize a directory inode entry.
692 * If requested, save its pertinent mode, owner, and time info.
693 */
694 static struct inotab *
695 allocinotab(ino, dip, seekpt)
696 ino_t ino;
697 struct dinode *dip;
698 long seekpt;
699 {
700 register struct inotab *itp;
701 struct modeinfo node;
702
703 itp = calloc(1, sizeof(struct inotab));
704 if (itp == NULL)
705 panic("no memory directory table\n");
706 itp->t_next = inotab[INOHASH(ino)];
707 inotab[INOHASH(ino)] = itp;
708 itp->t_ino = ino;
709 itp->t_seekpt = seekpt;
710 if (mf == NULL)
711 return (itp);
712 node.ino = ino;
713 node.timep[0].tv_sec = dip->di_atime.ts_sec;
714 node.timep[0].tv_usec = dip->di_atime.ts_nsec / 1000;
715 node.timep[1].tv_sec = dip->di_mtime.ts_sec;
716 node.timep[1].tv_usec = dip->di_mtime.ts_nsec / 1000;
717 node.mode = dip->di_mode;
718 node.flags = dip->di_flags;
719 node.uid = dip->di_uid;
720 node.gid = dip->di_gid;
721 (void) fwrite((char *)&node, 1, sizeof(struct modeinfo), mf);
722 return (itp);
723 }
724
725 /*
726 * Look up an inode in the table of directories
727 */
728 static struct inotab *
729 inotablookup(ino)
730 ino_t ino;
731 {
732 register struct inotab *itp;
733
734 for (itp = inotab[INOHASH(ino)]; itp != NULL; itp = itp->t_next)
735 if (itp->t_ino == ino)
736 return (itp);
737 return (NULL);
738 }
739
740 /*
741 * Clean up and exit
742 */
743 __dead void
744 done(exitcode)
745 int exitcode;
746 {
747
748 closemt();
749 if (modefile[0] != '#')
750 (void) unlink(modefile);
751 if (dirfile[0] != '#')
752 (void) unlink(dirfile);
753 exit(exitcode);
754 }
755