xref: /csrg-svn/sbin/mount/mount.c (revision 66138)
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*66138Sbostic static char sccsid[] = "@(#)mount.c	8.10 (Berkeley) 02/17/94";
1639322Smckusick #endif /* not lint */
1721156Sdist 
18*66138Sbostic #include <sys/param.h>
19*66138Sbostic #include <sys/wait.h>
20*66138Sbostic #include <sys/mount.h>
2166131Spendry 
22*66138Sbostic #include <err.h>
23*66138Sbostic #include <errno.h>
24*66138Sbostic #include <fstab.h>
25*66138Sbostic #include <signal.h>
2666131Spendry #include <stdio.h>
2766131Spendry #include <stdlib.h>
28*66138Sbostic #include <string.h>
2966131Spendry #include <unistd.h>
30*66138Sbostic 
3145524Sbostic #include "pathnames.h"
321057Sbill 
3340369Smckusick 
34*66138Sbostic int debug, force, verbose, mnttype, skipvfs;
3566130Spendry char *mntname;
3639131Smckusick 
37*66138Sbostic int    badvfsname __P((char *, char **));
38*66138Sbostic int    badvfstype __P((int, char **));
39*66138Sbostic int    getexecopts __P((char *, char **));
40*66138Sbostic struct statfs
41*66138Sbostic       *getmntpt __P((char *));
42*66138Sbostic int    getmnttype __P((char *));
43*66138Sbostic void   getstdopts __P((char *, int *));
44*66138Sbostic void   getufsopts __P((char *, int *));
45*66138Sbostic char **makevfslist __P((char *));
46*66138Sbostic int    mountfs __P((char *, char *, int, char *, char *, char *));
47*66138Sbostic void   prmount __P((char *, char *, int));
48*66138Sbostic void   usage __P((void));
49*66138Sbostic 
5066130Spendry int
5166130Spendry main(argc, argv)
525073Sroot 	int argc;
53*66138Sbostic 	char *argv[];
541057Sbill {
5566130Spendry 	struct fstab *fs;
5666130Spendry 	struct statfs *mntbuf;
5740496Smckusick 	FILE *pidfile;
58*66138Sbostic 	long mntsize;
59*66138Sbostic 	int all, ch, i, pid, ret, rval, updateflg;
60*66138Sbostic 	char *cp, *type, *options, **vfslist;
611057Sbill 
62*66138Sbostic 	mntname = "ufs";
6338445Smckusick 	mnttype = MOUNT_UFS;
64*66138Sbostic 
65*66138Sbostic 	all = updateflg = 0;
66*66138Sbostic 	options = type = NULL;
67*66138Sbostic 	vfslist = NULL;
68*66138Sbostic 	while ((ch = getopt(argc, argv, "adfo:rwt:uv")) != EOF)
69*66138Sbostic 		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;
79*66138Sbostic 		case 'o':
80*66138Sbostic 			options = optarg;
81*66138Sbostic 			break;
8235339Sbostic 		case 'r':
8312808Ssam 			type = FSTAB_RO;
8435339Sbostic 			break;
85*66138Sbostic 		case 't':
86*66138Sbostic 			vfslist = makevfslist(optarg);
87*66138Sbostic 			mnttype = getmnttype(optarg);
88*66138Sbostic 			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 
106*66138Sbostic #define	BADTYPE(type)							\
107*66138Sbostic 	(strcmp(type, FSTAB_RO) &&					\
108*66138Sbostic 	    strcmp(type, FSTAB_RW) && strcmp(type, FSTAB_RQ))
10935339Sbostic 
1104460Sroot 	if (all) {
11135369Sbostic 		rval = 0;
112*66138Sbostic 		while ((fs = getfsent()) != NULL) {
11335372Sbostic 			if (BADTYPE(fs->fs_type))
11435372Sbostic 				continue;
11540844Smckusick 			if (badvfsname(fs->fs_vfstype, vfslist))
11640051Smckusick 				continue;
117*66138Sbostic 			/* `/' 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();
12840337Smckusick 		if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0) {
12966131Spendry 			errx(1, "cannot get mount information");
13038632Smckusick 		}
13140844Smckusick 		for (i = 0; i < mntsize; i++) {
13240844Smckusick 			if (badvfstype(mntbuf[i].f_type, vfslist))
13340844Smckusick 				continue;
134*66138Sbostic 			prmount(mntbuf[i].f_mntfromname,
135*66138Sbostic 			     mntbuf[i].f_mntonname, mntbuf[i].f_flags);
13640844Smckusick 		}
1374460Sroot 		exit(0);
1381057Sbill 	}
13912808Ssam 
140*66138Sbostic 	if (argc == 1 && vfslist != NULL)
14166131Spendry 		usage();
14266131Spendry 
14339465Smckusick 	if (argc == 1 && updateflg) {
144*66138Sbostic 		if ((mntbuf = getmntpt(*argv)) == NULL)
145*66138Sbostic 			errx(1,
146*66138Sbostic 			    "unknown special file or file system %s.", *argv);
14739465Smckusick 		mnttype = mntbuf->f_type;
148*66138Sbostic 		if ((fs = getfsfile(mntbuf->f_mntonname)) == NULL)
14966131Spendry 			errx(1, "can't find fstab entry for %s.", *argv);
15053711Smckusick 		mntname = fs->fs_vfstype;
15153711Smckusick 
15253711Smckusick 		/*
15353711Smckusick 		 * Default type to fstab version if none specified on the
15453711Smckusick 		 * command line.
15553711Smckusick 		 */
15653711Smckusick 		if (type == NULL)
15753711Smckusick 			type = fs->fs_type;
15853711Smckusick 
15953711Smckusick 		/*
16053711Smckusick 		 * Default options to fstab version if none specified on the
16153711Smckusick 		 * command line.
16253711Smckusick 		 */
16353711Smckusick 		if (options == NULL)
16453711Smckusick 			options = fs->fs_mntops;
16553711Smckusick 		else {
16653711Smckusick 			/*
16753711Smckusick 			 * Concat the two strings with the command line
16853711Smckusick 			 * options last so that they will override the
16953711Smckusick 			 * fstab options.
17053711Smckusick 			 */
17153711Smckusick 			i = strlen(fs->fs_mntops) + strlen(options) + 2;
172*66138Sbostic 			if ((cp = malloc((size_t)i)) == NULL)
17366131Spendry 				errx(1, "-u malloc failed");
174*66138Sbostic 			(void)snprintf(cp, i, "%s,%s", fs->fs_mntops, options);
17553711Smckusick 			options = cp;
17653711Smckusick 		}
177*66138Sbostic 		ret = mountfs(fs->fs_spec,
178*66138Sbostic 		    mntbuf->f_mntonname, updateflg, type, options, NULL);
17940496Smckusick 	} else if (argc == 1) {
180*66138Sbostic 		if ((fs = getfsfile(*argv)) == NULL &&
181*66138Sbostic 		    (fs = getfsspec(*argv)) == NULL)
182*66138Sbostic 			errx(1,
183*66138Sbostic 			    "unknown special file or file system %s.\n", *argv);
184*66138Sbostic 		if (BADTYPE(fs->fs_type))
18566131Spendry 			errx(1, "%s has unknown file system type.\n", *argv);
18639333Smckusick 		mnttype = getmnttype(fs->fs_vfstype);
187*66138Sbostic 		ret = mountfs(fs->fs_spec,
188*66138Sbostic 		    fs->fs_file, updateflg, type, options, fs->fs_mntops);
18940496Smckusick 	} else if (argc != 2) {
19040496Smckusick 		usage();
19140496Smckusick 		ret = 1;
19240496Smckusick 	} else {
19342857Smckusick 		/*
194*66138Sbostic 		 * If -t flag has not been specified, and spec contains either
195*66138Sbostic 		 * a ':' or a '@' then assume that an NFS filesystem is being
196*66138Sbostic 		 * specified ala Sun.
19742857Smckusick 		 */
198*66138Sbostic 		if (vfslist == NULL &&
19966131Spendry 		    (strchr(argv[0], ':') || strchr(argv[0], '@'))) {
20042857Smckusick 			mnttype = MOUNT_NFS;
20152182Smckusick 			mntname = "nfs";
20252182Smckusick 		}
203*66138Sbostic 		ret = mountfs(argv[0], argv[1], updateflg, type, options, NULL);
20412808Ssam 	}
20540496Smckusick 	if ((pidfile = fopen(_PATH_MOUNTDPID, "r")) != NULL) {
20640496Smckusick 		pid = 0;
207*66138Sbostic 		(void)fscanf(pidfile, "%ld", &pid);
208*66138Sbostic 		(void)fclose(pidfile);
209*66138Sbostic 		if (pid > 0 && kill(pid, SIGHUP))
210*66138Sbostic 			err(1, "signal mountd");
21140496Smckusick 	}
212*66138Sbostic 
21366131Spendry 	exit(ret);
21412808Ssam }
21512808Ssam 
216*66138Sbostic int
21739333Smckusick mountfs(spec, name, flags, type, options, mntopts)
21839131Smckusick 	char *spec, *name, *type, *options, *mntopts;
21939333Smckusick 	int flags;
22012808Ssam {
221*66138Sbostic 	struct ufs_args args;
22242253Sbostic 	pid_t pid;
223*66138Sbostic 	int argc, i, status;
22439131Smckusick 	char *argp, *argv[50];
225*66138Sbostic 	char execname[MAXPATHLEN + 1], flagval[12], mntpath[MAXPATHLEN];
2261057Sbill 
22739333Smckusick 	if (mntopts)
22839333Smckusick 		getstdopts(mntopts, &flags);
22939316Smckusick 	if (options)
23039316Smckusick 		getstdopts(options, &flags);
23139333Smckusick 	if (type)
23239333Smckusick 		getstdopts(type, &flags);
23356841Smckusick 	if (force)
23456841Smckusick 		flags |= MNT_FORCE;
23566133Spendry 
23666133Spendry 	if (realpath(name, mntpath) == 0) {
23766133Spendry 		warn("%s", mntpath);
23866133Spendry 		return (1);
23966133Spendry 	}
24066133Spendry 
24166133Spendry 	name = mntpath;
24266133Spendry 
24366131Spendry 	if (strcmp(name, "/") == 0)
24466131Spendry 		flags |= MNT_UPDATE;
24566131Spendry 
24639316Smckusick 	switch (mnttype) {
24739316Smckusick 	case MOUNT_UFS:
24839333Smckusick 		if (mntopts)
24939333Smckusick 			getufsopts(mntopts, &flags);
25039316Smckusick 		if (options)
25139316Smckusick 			getufsopts(options, &flags);
25239316Smckusick 		args.fspec = spec;
253*66138Sbostic #define	DEFAULT_ROOTUID	-2
25465714Shibler 		args.export.ex_root = DEFAULT_ROOTUID;
25541403Smckusick 		if (flags & MNT_RDONLY)
25665714Shibler 			args.export.ex_flags = MNT_EXRDONLY;
25740496Smckusick 		else
25865714Shibler 			args.export.ex_flags = 0;
25939316Smckusick 		argp = (caddr_t)&args;
26039316Smckusick 		break;
26152110Smckusick 	case MOUNT_MFS:
26239316Smckusick 	case MOUNT_NFS:
26339322Smckusick 	default:
26439322Smckusick 		argv[0] = mntname;
26539329Smckusick 		argc = 1;
26639322Smckusick 		if (flags) {
26739322Smckusick 			argv[argc++] = "-F";
268*66138Sbostic 			(void)snprintf(flagval, sizeof(flagval), "%d", flags);
26939322Smckusick 			argv[argc++] = flagval;
27039322Smckusick 		}
27139333Smckusick 		if (mntopts)
27239333Smckusick 			argc += getexecopts(mntopts, &argv[argc]);
27339329Smckusick 		if (options)
27439329Smckusick 			argc += getexecopts(options, &argv[argc]);
27539316Smckusick 		argv[argc++] = spec;
27639316Smckusick 		argv[argc++] = name;
27739521Smckusick 		argv[argc++] = NULL;
278*66138Sbostic 		snprintf(execname, sizeof(execname),
279*66138Sbostic 		    "%s/mount_%s", _PATH_EXECDIR, mntname);
28039316Smckusick 		if (verbose) {
28142253Sbostic 			(void)printf("exec: %s", execname);
28242253Sbostic 			for (i = 1; i < argc - 1; i++)
28342253Sbostic 				(void)printf(" %s", argv[i]);
28442253Sbostic 			(void)printf("\n");
28539316Smckusick 		}
28656841Smckusick 		if (debug)
28739316Smckusick 			break;
28842253Sbostic 		if (pid = vfork()) {
28942253Sbostic 			if (pid == -1) {
29066131Spendry 				warn("vfork starting file system");
29139316Smckusick 				return (1);
29239131Smckusick 			}
29366130Spendry 			if (waitpid(pid, &status, 0) != -1 &&
29439316Smckusick 			    WIFEXITED(status) &&
29539316Smckusick 			    WEXITSTATUS(status) != 0)
29639316Smckusick 				return (WEXITSTATUS(status));
29739322Smckusick 			spec = mntname;
29839316Smckusick 			goto out;
29939316Smckusick 		}
30066130Spendry 		execv(execname, argv);
30166131Spendry 		err(1, "cannot exec %s for %s", execname, name);
30239316Smckusick 		/* NOTREACHED */
30338632Smckusick 
30439316Smckusick 	}
30556841Smckusick 	if (!debug && mount(mnttype, name, flags, argp)) {
306*66138Sbostic 		(void)fprintf(stderr, "%s on %s: ", spec, name);
30739316Smckusick 		switch (errno) {
30839316Smckusick 		case EMFILE:
309*66138Sbostic 			(void)fprintf(stderr, "Mount table full\n");
31039316Smckusick 			break;
31139316Smckusick 		case EINVAL:
31241403Smckusick 			if (flags & MNT_UPDATE)
313*66138Sbostic 				(void)fprintf(stderr, "Specified device %s\n",
31445689Smckusick 					"does not match mounted device");
31545569Skarels 			else if (mnttype == MOUNT_UFS)
316*66138Sbostic 				(void)fprintf(stderr, "Bogus super block\n");
31739333Smckusick 			else
318*66138Sbostic 				perror(NULL);
31939316Smckusick 			break;
32039316Smckusick 		default:
321*66138Sbostic 			perror(NULL);
32239316Smckusick 			break;
3234460Sroot 		}
32466130Spendry 		return (1);
3254460Sroot 	}
32635339Sbostic 
327*66138Sbostic out:	if (verbose)
32839316Smckusick 		prmount(spec, name, flags);
32966130Spendry 	return (0);
3301057Sbill }
33135339Sbostic 
332*66138Sbostic void
33339316Smckusick prmount(spec, name, flags)
33439316Smckusick 	char *spec, *name;
33566130Spendry 	int flags;
33635339Sbostic {
33766130Spendry 	int first;
33838632Smckusick 
33942253Sbostic 	(void)printf("%s on %s", spec, name);
34042253Sbostic 	if (!(flags & MNT_VISFLAGMASK)) {
34142253Sbostic 		(void)printf("\n");
34242253Sbostic 		return;
34342253Sbostic 	}
34442253Sbostic 	first = 0;
34542253Sbostic #define	PR(msg)	(void)printf("%s%s", !first++ ? " (" : ", ", msg)
34641403Smckusick 	if (flags & MNT_RDONLY)
34742253Sbostic 		PR("read-only");
34841403Smckusick 	if (flags & MNT_NOEXEC)
34942253Sbostic 		PR("noexec");
35041403Smckusick 	if (flags & MNT_NOSUID)
35142253Sbostic 		PR("nosuid");
35241403Smckusick 	if (flags & MNT_NODEV)
35342253Sbostic 		PR("nodev");
35441403Smckusick 	if (flags & MNT_SYNCHRONOUS)
35542253Sbostic 		PR("synchronous");
35665609Smckusick 	if (flags & MNT_ASYNC)
35765609Smckusick 		PR("asynchronous");
35841403Smckusick 	if (flags & MNT_QUOTA)
35942253Sbostic 		PR("with quotas");
36041403Smckusick 	if (flags & MNT_LOCAL)
36142253Sbostic 		PR("local");
36255394Spendry 	if (flags & MNT_UNION)
36355394Spendry 		PR("union");
36441403Smckusick 	if (flags & MNT_EXPORTED)
36552110Smckusick 		PR("NFS exported");
36642253Sbostic 	(void)printf(")\n");
36735339Sbostic }
36835339Sbostic 
369*66138Sbostic int
37039133Smckusick getmnttype(fstype)
37139133Smckusick 	char *fstype;
37239133Smckusick {
37339133Smckusick 
37439322Smckusick 	mntname = fstype;
375*66138Sbostic 	return (strcmp(fstype, "ufs") == 0 ? MOUNT_UFS : 0);
37639133Smckusick }
37739133Smckusick 
378*66138Sbostic void
37939316Smckusick getstdopts(options, flagp)
38039316Smckusick 	char *options;
38142253Sbostic 	int *flagp;
38239316Smckusick {
38339316Smckusick 	int negative;
384*66138Sbostic 	char *opt, optbuf[BUFSIZ];
38539316Smckusick 
38642253Sbostic 	(void)strcpy(optbuf, options);
387*66138Sbostic 	for (opt = strtok(optbuf, ","); opt; opt = strtok(NULL, ",")) {
38865852Smckusick 		if (opt[0] == '-')
38965852Smckusick 			continue;
39039316Smckusick 		if (opt[0] == 'n' && opt[1] == 'o') {
39139316Smckusick 			negative++;
39239316Smckusick 			opt += 2;
393*66138Sbostic 		} else
39439316Smckusick 			negative = 0;
39539333Smckusick 		if (!negative && !strcasecmp(opt, FSTAB_RO)) {
39641403Smckusick 			*flagp |= MNT_RDONLY;
39739333Smckusick 			continue;
39839333Smckusick 		}
39939333Smckusick 		if (!negative && !strcasecmp(opt, FSTAB_RW)) {
40041403Smckusick 			*flagp &= ~MNT_RDONLY;
40139333Smckusick 			continue;
40239333Smckusick 		}
40339316Smckusick 		if (!strcasecmp(opt, "exec")) {
40439316Smckusick 			if (negative)
40541403Smckusick 				*flagp |= MNT_NOEXEC;
40639333Smckusick 			else
40741403Smckusick 				*flagp &= ~MNT_NOEXEC;
40839316Smckusick 			continue;
40939316Smckusick 		}
41039316Smckusick 		if (!strcasecmp(opt, "suid")) {
41139316Smckusick 			if (negative)
41241403Smckusick 				*flagp |= MNT_NOSUID;
41339333Smckusick 			else
41441403Smckusick 				*flagp &= ~MNT_NOSUID;
41539316Smckusick 			continue;
41639316Smckusick 		}
41739316Smckusick 		if (!strcasecmp(opt, "dev")) {
41839316Smckusick 			if (negative)
41941403Smckusick 				*flagp |= MNT_NODEV;
42039333Smckusick 			else
42141403Smckusick 				*flagp &= ~MNT_NODEV;
42239316Smckusick 			continue;
42339316Smckusick 		}
42439316Smckusick 		if (!strcasecmp(opt, "synchronous")) {
42539316Smckusick 			if (!negative)
42641403Smckusick 				*flagp |= MNT_SYNCHRONOUS;
42739333Smckusick 			else
42841403Smckusick 				*flagp &= ~MNT_SYNCHRONOUS;
42939316Smckusick 			continue;
43039316Smckusick 		}
43165609Smckusick 		if (!strcasecmp(opt, "asynchronous")) {
43265609Smckusick 			if (!negative)
43365609Smckusick 				*flagp |= MNT_ASYNC;
43465609Smckusick 			else
43565609Smckusick 				*flagp &= ~MNT_ASYNC;
43665609Smckusick 			continue;
43765609Smckusick 		}
43855394Spendry 		if (!strcasecmp(opt, "union")) {
43955394Spendry 			if (!negative)
44055394Spendry 				*flagp |= MNT_UNION;
44155394Spendry 			else
44255394Spendry 				*flagp &= ~MNT_UNION;
44355394Spendry 			continue;
44455394Spendry 		}
445*66138Sbostic 		(void)fprintf(stderr, "mount: %s: unknown option\n", opt);
44639316Smckusick 	}
44739316Smckusick }
44839316Smckusick 
44942253Sbostic /* ARGSUSED */
450*66138Sbostic void
45139131Smckusick getufsopts(options, flagp)
45239131Smckusick 	char *options;
45342253Sbostic 	int *flagp;
45439131Smckusick {
45566130Spendry 
45639131Smckusick 	return;
45739131Smckusick }
45839131Smckusick 
459*66138Sbostic int
46039329Smckusick getexecopts(options, argv)
461*66138Sbostic 	char *options, **argv;
46239131Smckusick {
463*66138Sbostic 	int argc;
46466130Spendry 	char *opt;
46539131Smckusick 
466*66138Sbostic 	argc = 0;
467*66138Sbostic 	for (opt = strtok(options, ","); opt; opt = strtok(NULL, ",")) {
46839131Smckusick 		if (opt[0] != '-')
46939131Smckusick 			continue;
47039131Smckusick 		argv[argc++] = opt;
47139131Smckusick 		if (opt[2] == '\0' || opt[2] != '=')
47239131Smckusick 			continue;
47339131Smckusick 		opt[2] = '\0';
47439131Smckusick 		argv[argc++] = &opt[3];
47539131Smckusick 	}
47639131Smckusick 	return (argc);
47739131Smckusick }
47839131Smckusick 
479*66138Sbostic struct statfs *
48039465Smckusick getmntpt(name)
48139465Smckusick 	char *name;
48239465Smckusick {
48339465Smckusick 	struct statfs *mntbuf;
484*66138Sbostic 	long i, mntsize;
48539465Smckusick 
48640337Smckusick 	mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
48739465Smckusick 	for (i = 0; i < mntsize; i++) {
48839465Smckusick 		if (!strcmp(mntbuf[i].f_mntfromname, name) ||
48939465Smckusick 		    !strcmp(mntbuf[i].f_mntonname, name))
49039465Smckusick 			return (&mntbuf[i]);
49139465Smckusick 	}
492*66138Sbostic 	return (NULL);
49339465Smckusick }
49439465Smckusick 
495*66138Sbostic int
49640051Smckusick badvfstype(vfstype, vfslist)
49766130Spendry 	int vfstype;
49840051Smckusick 	char **vfslist;
49940051Smckusick {
50040051Smckusick 
501*66138Sbostic 	if (vfslist == NULL)
50266130Spendry 		return (0);
503*66138Sbostic 	while (*vfslist != NULL) {
50440844Smckusick 		if (vfstype == getmnttype(*vfslist))
50566130Spendry 			return (skipvfs);
50640051Smckusick 		vfslist++;
50740051Smckusick 	}
50840051Smckusick 	return (!skipvfs);
50940051Smckusick }
51040051Smckusick 
511*66138Sbostic int
51240844Smckusick badvfsname(vfsname, vfslist)
51340844Smckusick 	char *vfsname;
51440844Smckusick 	char **vfslist;
51540844Smckusick {
51640844Smckusick 
517*66138Sbostic 	if (vfslist == NULL)
51866130Spendry 		return (0);
519*66138Sbostic 	while (*vfslist != NULL) {
52040844Smckusick 		if (strcmp(vfsname, *vfslist) == 0)
52166130Spendry 			return (skipvfs);
52240844Smckusick 		vfslist++;
52340844Smckusick 	}
52440844Smckusick 	return (!skipvfs);
52540844Smckusick }
52640844Smckusick 
527*66138Sbostic char **
52840051Smckusick makevfslist(fslist)
52940051Smckusick 	char *fslist;
53040051Smckusick {
531*66138Sbostic 	int i;
53266130Spendry 	char **av, *nextcp;
53340051Smckusick 
53440051Smckusick 	if (fslist == NULL)
53540051Smckusick 		return (NULL);
53640051Smckusick 	if (fslist[0] == 'n' && fslist[1] == 'o') {
53740051Smckusick 		fslist += 2;
53840051Smckusick 		skipvfs = 1;
53940051Smckusick 	}
54040051Smckusick 	for (i = 0, nextcp = fslist; *nextcp; nextcp++)
54140051Smckusick 		if (*nextcp == ',')
54240051Smckusick 			i++;
543*66138Sbostic 	av = malloc((size_t)(i + 2) * sizeof(char *));
54440051Smckusick 	if (av == NULL)
54540051Smckusick 		return (NULL);
54640051Smckusick 	nextcp = fslist;
54740051Smckusick 	i = 0;
54840051Smckusick 	av[i++] = nextcp;
549*66138Sbostic 	while ((nextcp = index(nextcp, ',')) != NULL) {
55040051Smckusick 		*nextcp++ = '\0';
55140051Smckusick 		av[i++] = nextcp;
55240051Smckusick 	}
553*66138Sbostic 	av[i++] = NULL;
55440051Smckusick 	return (av);
55540051Smckusick }
556*66138Sbostic 
557*66138Sbostic void
558*66138Sbostic usage()
559*66138Sbostic {
560*66138Sbostic 
561*66138Sbostic 	(void)fprintf(stderr,
562*66138Sbostic 		"usage:\n  mount %s %s\n  mount %s\n  mount %s\n",
563*66138Sbostic 		"[ -frwu ] [ -t ufs | external_type ]",
564*66138Sbostic 		"[ -o options ] special node",
565*66138Sbostic 		"[ -afrwu ] [ -t ufs | external_type ]",
566*66138Sbostic 		"[ -frwu ] special | node");
567*66138Sbostic 	exit(1);
568*66138Sbostic }
569