Annotation of 43BSDReno/usr.sbin/mtree/mtree.c, revision 1.1.1.1

1.1       root        1: /*-
                      2:  * Copyright (c) 1989 The Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution and use in source and binary forms are permitted provided
                      6:  * that: (1) source distributions retain this entire copyright notice and
                      7:  * comment, and (2) distributions including binaries display the following
                      8:  * acknowledgement:  ``This product includes software developed by the
                      9:  * University of California, Berkeley and its contributors'' in the
                     10:  * documentation or other materials provided with the distribution and in
                     11:  * all advertising materials mentioning features or use of this software.
                     12:  * Neither the name of the University nor the names of its contributors may
                     13:  * be used to endorse or promote products derived from this software without
                     14:  * specific prior written permission.
                     15:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
                     16:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
                     17:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     18:  */
                     19: 
                     20: #ifndef lint
                     21: char copyright[] =
                     22: "@(#) Copyright (c) 1990 The Regents of the University of California.\n\
                     23:  All rights reserved.\n";
                     24: #endif /* not lint */
                     25: 
                     26: #ifndef lint
                     27: static char sccsid[] = "@(#)mtree.c    5.8 (Berkeley) 5/25/90";
                     28: #endif /* not lint */
                     29: 
                     30: #include <sys/param.h>
                     31: #include <sys/stat.h>
                     32: #include <errno.h>
                     33: #include <stdio.h>
                     34: #include <fts.h>
                     35: #include "mtree.h"
                     36: 
                     37: NODE *root;
                     38: int exitval;
                     39: int cflag, dflag, eflag, rflag, uflag;
                     40: 
                     41: main(argc, argv)
                     42:        int argc;
                     43:        char **argv;
                     44: {
                     45:        extern int ftsoptions, optind;
                     46:        extern char *optarg;
                     47:        int ch;
                     48:        char *dir;
                     49: 
                     50:        dir = (char *)NULL;
                     51:        while ((ch = getopt(argc, argv, "cdef:p:rux")) != EOF)
                     52:                switch((char)ch) {
                     53:                case 'c':
                     54:                        cflag = 1;
                     55:                        break;
                     56:                case 'd':
                     57:                        dflag = 1;
                     58:                        break;
                     59:                case 'e':
                     60:                        eflag = 1;
                     61:                        break;
                     62:                case 'f':
                     63:                        if (!(freopen(optarg, "r", stdin))) {
                     64:                                (void)fprintf(stderr,
                     65:                                    "mtree: can't read %s.\n", optarg);
                     66:                                exit(1);
                     67:                        }
                     68:                        break;
                     69:                case 'p':
                     70:                        dir = optarg;
                     71:                        break;
                     72:                case 'r':
                     73:                        rflag = 1;
                     74:                        break;
                     75:                case 'u':
                     76:                        uflag = 1;
                     77:                        break;
                     78:                case 'x':
                     79:                        ftsoptions |= FTS_XDEV;
                     80:                        break;
                     81:                case '?':
                     82:                default:
                     83:                        usage();
                     84:                }
                     85:        argc -= optind;
                     86:        if (argc)
                     87:                usage();
                     88: 
                     89:        if (!cflag)
                     90:                spec();
                     91: 
                     92:        if (dir && chdir(dir)) {
                     93:                (void)fprintf(stderr,
                     94:                    "mtree: %s: %s\n", dir, strerror(errno));
                     95:                exit(1);
                     96:        }
                     97: 
                     98:        if (cflag)
                     99:                cwalk();
                    100:        else
                    101:                verify();
                    102:        exit(exitval);
                    103: }
                    104: 
                    105: usage()
                    106: {
                    107:        (void)fprintf(stderr,
                    108:            "usage: mtree [-cderux] [-p path] [-f spec]\n");
                    109:        exit(1);
                    110: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.