xref: /csrg-svn/sbin/mount/mount.c (revision 66174)
121156Sdist /*
261503Sbostic  * Copyright (c) 1980, 1989, 1993
361503Sbostic  *	The Regents of the University of California.  All rights reserved.
439322Smckusick  *
542702Sbostic  * %sccs.include.redist.c%
621156Sdist  */
721156Sdist 
810811Ssam #ifndef lint
961503Sbostic static char copyright[] =
1061503Sbostic "@(#) Copyright (c) 1980, 1989, 1993\n\
1161503Sbostic 	The Regents of the University of California.  All rights reserved.\n";
1239322Smckusick #endif /* not lint */
131057Sbill 
1421156Sdist #ifndef lint
15*66174Spendry static char sccsid[] = "@(#)mount.c	8.13 (Berkeley) 02/20/94";
1639322Smckusick #endif /* not lint */
1721156Sdist 
1866138Sbostic #include <sys/param.h>
1966138Sbostic #include <sys/wait.h>
2066138Sbostic #include <sys/mount.h>
2166131Spendry 
2266138Sbostic #include <err.h>
2366138Sbostic #include <errno.h>
2466138Sbostic #include <fstab.h>
2566138Sbostic #include <signal.h>
2666131Spendry #include <stdio.h>
2766131Spendry #include <stdlib.h>
2866138Sbostic #include <string.h>
2966131Spendry #include <unistd.h>
3066138Sbostic 
3145524Sbostic #include "pathnames.h"
321057Sbill 
3340369Smckusick 
3466138Sbostic int debug, force, verbose, mnttype, skipvfs;
3566130Spendry char *mntname;
3639131Smckusick 
3766138Sbostic int    badvfsname __P((char *, char **));
3866138Sbostic int    badvfstype __P((int, char **));
3966138Sbostic int    getexecopts __P((char *, char **));
4066138Sbostic struct statfs
4166138Sbostic       *getmntpt __P((char *));
4266138Sbostic int    getmnttype __P((char *));
4366138Sbostic void   getstdopts __P((char *, int *));
4466138Sbostic void   getufsopts __P((char *, int *));
4566138Sbostic char **makevfslist __P((char *));
4666138Sbostic int    mountfs __P((char *, char *, int, char *, char *, char *));
4766138Sbostic void   prmount __P((char *, char *, int));
4866138Sbostic void   usage __P((void));
4966138Sbostic 
5066130Spendry int
5166130Spendry main(argc, argv)
525073Sroot 	int argc;
5366138Sbostic 	char *argv[];
541057Sbill {
5566130Spendry 	struct fstab *fs;
5666130Spendry 	struct statfs *mntbuf;
5740496Smckusick 	FILE *pidfile;
5866138Sbostic 	long mntsize;
59*66174Spendry 	int all, ch, i, ret, rval, updateflg;
6066138Sbostic 	char *cp, *type, *options, **vfslist;
611057Sbill 
6266138Sbostic 	mntname = "ufs";
6338445Smckusick 	mnttype = MOUNT_UFS;
6466138Sbostic 
6566138Sbostic 	all = updateflg = 0;
6666138Sbostic 	options = type = NULL;
6766138Sbostic 	vfslist = NULL;
6866138Sbostic 	while ((ch = getopt(argc, argv, "adfo:rwt:uv")) != EOF)
6966138Sbostic 		switch(ch) {
7035339Sbostic 		case 'a':
7135339Sbostic 			all = 1;
7235339Sbostic 			break;
7356841Smckusick 		case 'd':
7456841Smckusick 			debug = 1;
7556841Smckusick 			break;
7635339Sbostic 		case 'f':
7756841Smckusick 			force = 1;
7835339Sbostic 			break;
7966138Sbostic 		case 'o':
8066138Sbostic 			options = optarg;
8166138Sbostic 			break;
8235339Sbostic 		case 'r':
8312808Ssam 			type = FSTAB_RO;
8435339Sbostic 			break;
8566138Sbostic 		case 't':
8666138Sbostic 			vfslist = makevfslist(optarg);
8766138Sbostic 			mnttype = getmnttype(optarg);
8866138Sbostic 			break;
8939333Smckusick 		case 'u':
9041403Smckusick 			updateflg = MNT_UPDATE;
9139333Smckusick 			break;
9235339Sbostic 		case 'v':
9335339Sbostic 			verbose = 1;
9435339Sbostic 			break;
9535339Sbostic 		case 'w':
9635339Sbostic 			type = FSTAB_RW;
9735339Sbostic 			break;
9835339Sbostic 		case '?':
9935339Sbostic 		default:
10035339Sbostic 			usage();
10139131Smckusick 			/* NOTREACHED */
1025073Sroot 		}
10335339Sbostic 	argc -= optind;
10435339Sbostic 	argv += optind;
10535339Sbostic 
10666138Sbostic #define	BADTYPE(type)							\
10766138Sbostic 	(strcmp(type, FSTAB_RO) &&					\
10866138Sbostic 	    strcmp(type, FSTAB_RW) && strcmp(type, FSTAB_RQ))
10935339Sbostic 
1104460Sroot 	if (all) {
11135369Sbostic 		rval = 0;
11266138Sbostic 		while ((fs = getfsent()) != NULL) {
11335372Sbostic 			if (BADTYPE(fs->fs_type))
11435372Sbostic 				continue;
11540844Smckusick 			if (badvfsname(fs->fs_vfstype, vfslist))
11640051Smckusick 				continue;
11766138Sbostic 			/* `/' is special, it's always mounted. */
11839333Smckusick 			mnttype = getmnttype(fs->fs_vfstype);
11966131Spendry 			rval |= mountfs(fs->fs_spec, fs->fs_file, updateflg,
12039333Smckusick 			    type, options, fs->fs_mntops);
12135372Sbostic 		}
12235341Sbostic 		exit(rval);
12335339Sbostic 	}
1245073Sroot 
12535339Sbostic 	if (argc == 0) {
12656841Smckusick 		if (verbose || debug || type)
12735339Sbostic 			usage();
12866139Sbostic 		if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0)
12966139Sbostic 			err(1, "getmntinfo");
13040844Smckusick 		for (i = 0; i < mntsize; i++) {
13140844Smckusick 			if (badvfstype(mntbuf[i].f_type, vfslist))
13240844Smckusick 				continue;
13366138Sbostic 			prmount(mntbuf[i].f_mntfromname,
13466138Sbostic 			     mntbuf[i].f_mntonname, mntbuf[i].f_flags);
13540844Smckusick 		}
1364460Sroot 		exit(0);
1371057Sbill 	}
13812808Ssam 
13966138Sbostic 	if (argc == 1 && vfslist != NULL)
14066131Spendry 		usage();
14166131Spendry 
14239465Smckusick 	if (argc == 1 && updateflg) {
14366138Sbostic 		if ((mntbuf = getmntpt(*argv)) == NULL)
14466138Sbostic 			errx(1,
14566138Sbostic 			    "unknown special file or file system %s.", *argv);
14639465Smckusick 		mnttype = mntbuf->f_type;
14766138Sbostic 		if ((fs = getfsfile(mntbuf->f_mntonname)) == NULL)
14866131Spendry 			errx(1, "can't find fstab entry for %s.", *argv);
14953711Smckusick 		mntname = fs->fs_vfstype;
15053711Smckusick 
15153711Smckusick 		/*
15253711Smckusick 		 * Default type to fstab version if none specified on the
15353711Smckusick 		 * command line.
15453711Smckusick 		 */
15553711Smckusick 		if (type == NULL)
15653711Smckusick 			type = fs->fs_type;
15753711Smckusick 
15853711Smckusick 		/*
15953711Smckusick 		 * Default options to fstab version if none specified on the
16053711Smckusick 		 * command line.
16153711Smckusick 		 */
16253711Smckusick 		if (options == NULL)
16353711Smckusick 			options = fs->fs_mntops;
16453711Smckusick 		else {
16553711Smckusick 			/*
16653711Smckusick 			 * Concat the two strings with the command line
16753711Smckusick 			 * options last so that they will override the
16853711Smckusick 			 * fstab options.
16953711Smckusick 			 */
17053711Smckusick 			i = strlen(fs->fs_mntops) + strlen(options) + 2;
17166138Sbostic 			if ((cp = malloc((size_t)i)) == NULL)
17266139Sbostic 				err(1, NULL);
17366138Sbostic 			(void)snprintf(cp, i, "%s,%s", fs->fs_mntops, options);
17453711Smckusick 			options = cp;
17553711Smckusick 		}
17666138Sbostic 		ret = mountfs(fs->fs_spec,
17766138Sbostic 		    mntbuf->f_mntonname, updateflg, type, options, NULL);
17840496Smckusick 	} else if (argc == 1) {
17966138Sbostic 		if ((fs = getfsfile(*argv)) == NULL &&
18066138Sbostic 		    (fs = getfsspec(*argv)) == NULL)
18166138Sbostic 			errx(1,
18266139Sbostic 			    "unknown special file or file system %s.", *argv);
18366138Sbostic 		if (BADTYPE(fs->fs_type))
18466139Sbostic 			errx(1, "%s has unknown file system type.", *argv);
18539333Smckusick 		mnttype = getmnttype(fs->fs_vfstype);
18666138Sbostic 		ret = mountfs(fs->fs_spec,
18766138Sbostic 		    fs->fs_file, updateflg, type, options, fs->fs_mntops);
18840496Smckusick 	} else if (argc != 2) {
18940496Smckusick 		usage();
19040496Smckusick 		ret = 1;
19140496Smckusick 	} else {
19242857Smckusick 		/*
19366138Sbostic 		 * If -t flag has not been specified, and spec contains either
19466138Sbostic 		 * a ':' or a '@' then assume that an NFS filesystem is being
19566138Sbostic 		 * specified ala Sun.
19642857Smckusick 		 */
19766138Sbostic 		if (vfslist == NULL &&
19866131Spendry 		    (strchr(argv[0], ':') || strchr(argv[0], '@'))) {
19942857Smckusick 			mnttype = MOUNT_NFS;
20052182Smckusick 			mntname = "nfs";
20152182Smckusick 		}
20266138Sbostic 		ret = mountfs(argv[0], argv[1], updateflg, type, options, NULL);
20312808Ssam 	}
204*66174Spendry 	/*
205*66174Spendry 	 * If the mount succeeded, and we're running as root,
206*66174Spendry 	 * then tell mountd the good news.
207*66174Spendry 	 */
208*66174Spendry 	if ((ret == 0) && (getuid() == 0)) {
209*66174Spendry 		if ((pidfile = fopen(_PATH_MOUNTDPID, "r")) != NULL) {
210*66174Spendry 			pid_t pid = 0;
211*66174Spendry 			(void)fscanf(pidfile, "%ld", &pid);
212*66174Spendry 			(void)fclose(pidfile);
213*66174Spendry 			if (pid > 0 && kill(pid, SIGHUP))
214*66174Spendry 				err(1, "signal mountd");
215*66174Spendry 		}
21640496Smckusick 	}
21766138Sbostic 
21866131Spendry 	exit(ret);
21912808Ssam }
22012808Ssam 
22166138Sbostic int
22239333Smckusick mountfs(spec, name, flags, type, options, mntopts)
22339131Smckusick 	char *spec, *name, *type, *options, *mntopts;
22439333Smckusick 	int flags;
22512808Ssam {
22666138Sbostic 	struct ufs_args args;
22742253Sbostic 	pid_t pid;
22866138Sbostic 	int argc, i, status;
22939131Smckusick 	char *argp, *argv[50];
23066138Sbostic 	char execname[MAXPATHLEN + 1], flagval[12], mntpath[MAXPATHLEN];
2311057Sbill 
23239333Smckusick 	if (mntopts)
23339333Smckusick 		getstdopts(mntopts, &flags);
23439316Smckusick 	if (options)
23539316Smckusick 		getstdopts(options, &flags);
23639333Smckusick 	if (type)
23739333Smckusick 		getstdopts(type, &flags);
23856841Smckusick 	if (force)
23956841Smckusick 		flags |= MNT_FORCE;
24066133Spendry 
24166133Spendry 	if (realpath(name, mntpath) == 0) {
24266133Spendry 		warn("%s", mntpath);
24366133Spendry 		return (1);
24466133Spendry 	}
24566133Spendry 
24666133Spendry 	name = mntpath;
24766133Spendry 
24866131Spendry 	if (strcmp(name, "/") == 0)
24966131Spendry 		flags |= MNT_UPDATE;
25066131Spendry 
25139316Smckusick 	switch (mnttype) {
25239316Smckusick 	case MOUNT_UFS:
25339333Smckusick 		if (mntopts)
25439333Smckusick 			getufsopts(mntopts, &flags);
25539316Smckusick 		if (options)
25639316Smckusick 			getufsopts(options, &flags);
25739316Smckusick 		args.fspec = spec;
25866138Sbostic #define	DEFAULT_ROOTUID	-2
25965714Shibler 		args.export.ex_root = DEFAULT_ROOTUID;
26041403Smckusick 		if (flags & MNT_RDONLY)
26165714Shibler 			args.export.ex_flags = MNT_EXRDONLY;
26240496Smckusick 		else
26365714Shibler 			args.export.ex_flags = 0;
26439316Smckusick 		argp = (caddr_t)&args;
26539316Smckusick 		break;
26652110Smckusick 	case MOUNT_MFS:
26739316Smckusick 	case MOUNT_NFS:
26839322Smckusick 	default:
26939322Smckusick 		argv[0] = mntname;
27039329Smckusick 		argc = 1;
27139322Smckusick 		if (flags) {
27239322Smckusick 			argv[argc++] = "-F";
27366138Sbostic 			(void)snprintf(flagval, sizeof(flagval), "%d", flags);
27439322Smckusick 			argv[argc++] = flagval;
27539322Smckusick 		}
27639333Smckusick 		if (mntopts)
27739333Smckusick 			argc += getexecopts(mntopts, &argv[argc]);
27839329Smckusick 		if (options)
27939329Smckusick 			argc += getexecopts(options, &argv[argc]);
28039316Smckusick 		argv[argc++] = spec;
28139316Smckusick 		argv[argc++] = name;
28239521Smckusick 		argv[argc++] = NULL;
28366138Sbostic 		snprintf(execname, sizeof(execname),
28466138Sbostic 		    "%s/mount_%s", _PATH_EXECDIR, mntname);
28539316Smckusick 		if (verbose) {
28642253Sbostic 			(void)printf("exec: %s", execname);
28742253Sbostic 			for (i = 1; i < argc - 1; i++)
28842253Sbostic 				(void)printf(" %s", argv[i]);
28942253Sbostic 			(void)printf("\n");
29039316Smckusick 		}
29156841Smckusick 		if (debug)
29239316Smckusick 			break;
29342253Sbostic 		if (pid = vfork()) {
29442253Sbostic 			if (pid == -1) {
29566131Spendry 				warn("vfork starting file system");
29639316Smckusick 				return (1);
29739131Smckusick 			}
29866130Spendry 			if (waitpid(pid, &status, 0) != -1 &&
29939316Smckusick 			    WIFEXITED(status) &&
30039316Smckusick 			    WEXITSTATUS(status) != 0)
30139316Smckusick 				return (WEXITSTATUS(status));
30239322Smckusick 			spec = mntname;
30339316Smckusick 			goto out;
30439316Smckusick 		}
30566130Spendry 		execv(execname, argv);
30666131Spendry 		err(1, "cannot exec %s for %s", execname, name);
30739316Smckusick 		/* NOTREACHED */
30838632Smckusick 
30939316Smckusick 	}
31056841Smckusick 	if (!debug && mount(mnttype, name, flags, argp)) {
31166138Sbostic 		(void)fprintf(stderr, "%s on %s: ", spec, name);
31239316Smckusick 		switch (errno) {
31339316Smckusick 		case EMFILE:
31466139Sbostic 			(void)fprintf(stderr, "Mount table full.\n");
31539316Smckusick 			break;
31639316Smckusick 		case EINVAL:
31741403Smckusick 			if (flags & MNT_UPDATE)
31866138Sbostic 				(void)fprintf(stderr, "Specified device %s\n",
31945689Smckusick 					"does not match mounted device");
32045569Skarels 			else if (mnttype == MOUNT_UFS)
32166138Sbostic 				(void)fprintf(stderr, "Bogus super block\n");
32239333Smckusick 			else
32366138Sbostic 				perror(NULL);
32439316Smckusick 			break;
32539316Smckusick 		default:
32666138Sbostic 			perror(NULL);
32739316Smckusick 			break;
3284460Sroot 		}
32966130Spendry 		return (1);
3304460Sroot 	}
33135339Sbostic 
33266138Sbostic out:	if (verbose)
33339316Smckusick 		prmount(spec, name, flags);
33466130Spendry 	return (0);
3351057Sbill }
33635339Sbostic 
33766138Sbostic void
33839316Smckusick prmount(spec, name, flags)
33939316Smckusick 	char *spec, *name;
34066130Spendry 	int flags;
34135339Sbostic {
34266130Spendry 	int first;
34338632Smckusick 
34442253Sbostic 	(void)printf("%s on %s", spec, name);
34542253Sbostic 	if (!(flags & MNT_VISFLAGMASK)) {
34642253Sbostic 		(void)printf("\n");
34742253Sbostic 		return;
34842253Sbostic 	}
34942253Sbostic 	first = 0;
35042253Sbostic #define	PR(msg)	(void)printf("%s%s", !first++ ? " (" : ", ", msg)
35141403Smckusick 	if (flags & MNT_RDONLY)
35242253Sbostic 		PR("read-only");
35341403Smckusick 	if (flags & MNT_NOEXEC)
35442253Sbostic 		PR("noexec");
35541403Smckusick 	if (flags & MNT_NOSUID)
35642253Sbostic 		PR("nosuid");
35741403Smckusick 	if (flags & MNT_NODEV)
35842253Sbostic 		PR("nodev");
35941403Smckusick 	if (flags & MNT_SYNCHRONOUS)
36042253Sbostic 		PR("synchronous");
36165609Smckusick 	if (flags & MNT_ASYNC)
36265609Smckusick 		PR("asynchronous");
36341403Smckusick 	if (flags & MNT_QUOTA)
36442253Sbostic 		PR("with quotas");
36541403Smckusick 	if (flags & MNT_LOCAL)
36642253Sbostic 		PR("local");
36766171Spendry 	if (flags & MNT_USER)
36866171Spendry 		PR("user mount");
36955394Spendry 	if (flags & MNT_UNION)
37055394Spendry 		PR("union");
37141403Smckusick 	if (flags & MNT_EXPORTED)
37252110Smckusick 		PR("NFS exported");
37342253Sbostic 	(void)printf(")\n");
37435339Sbostic }
37535339Sbostic 
37666138Sbostic int
37739133Smckusick getmnttype(fstype)
37839133Smckusick 	char *fstype;
37939133Smckusick {
38039133Smckusick 
38139322Smckusick 	mntname = fstype;
38266138Sbostic 	return (strcmp(fstype, "ufs") == 0 ? MOUNT_UFS : 0);
38339133Smckusick }
38439133Smckusick 
38566138Sbostic void
38639316Smckusick getstdopts(options, flagp)
38739316Smckusick 	char *options;
38842253Sbostic 	int *flagp;
38939316Smckusick {
39039316Smckusick 	int negative;
39166138Sbostic 	char *opt, optbuf[BUFSIZ];
39239316Smckusick 
39342253Sbostic 	(void)strcpy(optbuf, options);
39466138Sbostic 	for (opt = strtok(optbuf, ","); opt; opt = strtok(NULL, ",")) {
39565852Smckusick 		if (opt[0] == '-')
39665852Smckusick 			continue;
39739316Smckusick 		if (opt[0] == 'n' && opt[1] == 'o') {
39839316Smckusick 			negative++;
39939316Smckusick 			opt += 2;
40066138Sbostic 		} else
40139316Smckusick 			negative = 0;
40239333Smckusick 		if (!negative && !strcasecmp(opt, FSTAB_RO)) {
40341403Smckusick 			*flagp |= MNT_RDONLY;
40439333Smckusick 			continue;
40539333Smckusick 		}
40639333Smckusick 		if (!negative && !strcasecmp(opt, FSTAB_RW)) {
40741403Smckusick 			*flagp &= ~MNT_RDONLY;
40839333Smckusick 			continue;
40939333Smckusick 		}
41039316Smckusick 		if (!strcasecmp(opt, "exec")) {
41139316Smckusick 			if (negative)
41241403Smckusick 				*flagp |= MNT_NOEXEC;
41339333Smckusick 			else
41441403Smckusick 				*flagp &= ~MNT_NOEXEC;
41539316Smckusick 			continue;
41639316Smckusick 		}
41739316Smckusick 		if (!strcasecmp(opt, "suid")) {
41839316Smckusick 			if (negative)
41941403Smckusick 				*flagp |= MNT_NOSUID;
42039333Smckusick 			else
42141403Smckusick 				*flagp &= ~MNT_NOSUID;
42239316Smckusick 			continue;
42339316Smckusick 		}
42439316Smckusick 		if (!strcasecmp(opt, "dev")) {
42539316Smckusick 			if (negative)
42641403Smckusick 				*flagp |= MNT_NODEV;
42739333Smckusick 			else
42841403Smckusick 				*flagp &= ~MNT_NODEV;
42939316Smckusick 			continue;
43039316Smckusick 		}
43139316Smckusick 		if (!strcasecmp(opt, "synchronous")) {
43239316Smckusick 			if (!negative)
43341403Smckusick 				*flagp |= MNT_SYNCHRONOUS;
43439333Smckusick 			else
43541403Smckusick 				*flagp &= ~MNT_SYNCHRONOUS;
43639316Smckusick 			continue;
43739316Smckusick 		}
43865609Smckusick 		if (!strcasecmp(opt, "asynchronous")) {
43965609Smckusick 			if (!negative)
44065609Smckusick 				*flagp |= MNT_ASYNC;
44165609Smckusick 			else
44265609Smckusick 				*flagp &= ~MNT_ASYNC;
44365609Smckusick 			continue;
44465609Smckusick 		}
44555394Spendry 		if (!strcasecmp(opt, "union")) {
44655394Spendry 			if (!negative)
44755394Spendry 				*flagp |= MNT_UNION;
44855394Spendry 			else
44955394Spendry 				*flagp &= ~MNT_UNION;
45055394Spendry 			continue;
45155394Spendry 		}
45266138Sbostic 		(void)fprintf(stderr, "mount: %s: unknown option\n", opt);
45339316Smckusick 	}
45439316Smckusick }
45539316Smckusick 
45642253Sbostic /* ARGSUSED */
45766138Sbostic void
45839131Smckusick getufsopts(options, flagp)
45939131Smckusick 	char *options;
46042253Sbostic 	int *flagp;
46139131Smckusick {
46266130Spendry 
46339131Smckusick 	return;
46439131Smckusick }
46539131Smckusick 
46666138Sbostic int
46739329Smckusick getexecopts(options, argv)
46866138Sbostic 	char *options, **argv;
46939131Smckusick {
47066138Sbostic 	int argc;
47166130Spendry 	char *opt;
47239131Smckusick 
47366138Sbostic 	argc = 0;
47466138Sbostic 	for (opt = strtok(options, ","); opt; opt = strtok(NULL, ",")) {
47539131Smckusick 		if (opt[0] != '-')
47639131Smckusick 			continue;
47739131Smckusick 		argv[argc++] = opt;
47839131Smckusick 		if (opt[2] == '\0' || opt[2] != '=')
47939131Smckusick 			continue;
48039131Smckusick 		opt[2] = '\0';
48139131Smckusick 		argv[argc++] = &opt[3];
48239131Smckusick 	}
48339131Smckusick 	return (argc);
48439131Smckusick }
48539131Smckusick 
48666138Sbostic struct statfs *
48739465Smckusick getmntpt(name)
48839465Smckusick 	char *name;
48939465Smckusick {
49039465Smckusick 	struct statfs *mntbuf;
49166138Sbostic 	long i, mntsize;
49239465Smckusick 
49340337Smckusick 	mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
49439465Smckusick 	for (i = 0; i < mntsize; i++) {
49539465Smckusick 		if (!strcmp(mntbuf[i].f_mntfromname, name) ||
49639465Smckusick 		    !strcmp(mntbuf[i].f_mntonname, name))
49739465Smckusick 			return (&mntbuf[i]);
49839465Smckusick 	}
49966138Sbostic 	return (NULL);
50039465Smckusick }
50139465Smckusick 
50266138Sbostic int
50340051Smckusick badvfstype(vfstype, vfslist)
50466130Spendry 	int vfstype;
50540051Smckusick 	char **vfslist;
50640051Smckusick {
50740051Smckusick 
50866138Sbostic 	if (vfslist == NULL)
50966130Spendry 		return (0);
51066138Sbostic 	while (*vfslist != NULL) {
51140844Smckusick 		if (vfstype == getmnttype(*vfslist))
51266130Spendry 			return (skipvfs);
51340051Smckusick 		vfslist++;
51440051Smckusick 	}
51540051Smckusick 	return (!skipvfs);
51640051Smckusick }
51740051Smckusick 
51866138Sbostic int
51940844Smckusick badvfsname(vfsname, vfslist)
52040844Smckusick 	char *vfsname;
52140844Smckusick 	char **vfslist;
52240844Smckusick {
52340844Smckusick 
52466138Sbostic 	if (vfslist == NULL)
52566130Spendry 		return (0);
52666138Sbostic 	while (*vfslist != NULL) {
52740844Smckusick 		if (strcmp(vfsname, *vfslist) == 0)
52866130Spendry 			return (skipvfs);
52940844Smckusick 		vfslist++;
53040844Smckusick 	}
53140844Smckusick 	return (!skipvfs);
53240844Smckusick }
53340844Smckusick 
53466138Sbostic char **
53540051Smckusick makevfslist(fslist)
53640051Smckusick 	char *fslist;
53740051Smckusick {
53866138Sbostic 	int i;
53966130Spendry 	char **av, *nextcp;
54040051Smckusick 
54140051Smckusick 	if (fslist == NULL)
54240051Smckusick 		return (NULL);
54340051Smckusick 	if (fslist[0] == 'n' && fslist[1] == 'o') {
54440051Smckusick 		fslist += 2;
54540051Smckusick 		skipvfs = 1;
54640051Smckusick 	}
54740051Smckusick 	for (i = 0, nextcp = fslist; *nextcp; nextcp++)
54840051Smckusick 		if (*nextcp == ',')
54940051Smckusick 			i++;
55066138Sbostic 	av = malloc((size_t)(i + 2) * sizeof(char *));
55140051Smckusick 	if (av == NULL)
55240051Smckusick 		return (NULL);
55340051Smckusick 	nextcp = fslist;
55440051Smckusick 	i = 0;
55540051Smckusick 	av[i++] = nextcp;
55666138Sbostic 	while ((nextcp = index(nextcp, ',')) != NULL) {
55740051Smckusick 		*nextcp++ = '\0';
55840051Smckusick 		av[i++] = nextcp;
55940051Smckusick 	}
56066138Sbostic 	av[i++] = NULL;
56140051Smckusick 	return (av);
56240051Smckusick }
56366138Sbostic 
56466138Sbostic void
56566138Sbostic usage()
56666138Sbostic {
56766138Sbostic 
56866138Sbostic 	(void)fprintf(stderr,
56966171Spendry 		"usage: %s %s\n       %s\n       %s\n",
57066171Spendry 		"mount [-dfruvw] [-t ufs | external_type]",
57166171Spendry 			"[-o options] special node",
57266171Spendry 		"mount [-adfruvw] [-t ufs | external_type]",
57366171Spendry 		"mount [-dfruvw] special | node");
57466138Sbostic 	exit(1);
57566138Sbostic }
576