xref: /csrg-svn/sbin/mount/mount.c (revision 66139)
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*66139Sbostic static char sccsid[] = "@(#)mount.c	8.11 (Berkeley) 02/17/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;
5966138Sbostic 	int all, ch, i, pid, 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();
128*66139Sbostic 		if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0)
129*66139Sbostic 			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)
172*66139Sbostic 				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,
182*66139Sbostic 			    "unknown special file or file system %s.", *argv);
18366138Sbostic 		if (BADTYPE(fs->fs_type))
184*66139Sbostic 			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 	}
20440496Smckusick 	if ((pidfile = fopen(_PATH_MOUNTDPID, "r")) != NULL) {
20540496Smckusick 		pid = 0;
20666138Sbostic 		(void)fscanf(pidfile, "%ld", &pid);
20766138Sbostic 		(void)fclose(pidfile);
20866138Sbostic 		if (pid > 0 && kill(pid, SIGHUP))
20966138Sbostic 			err(1, "signal mountd");
21040496Smckusick 	}
21166138Sbostic 
21266131Spendry 	exit(ret);
21312808Ssam }
21412808Ssam 
21566138Sbostic int
21639333Smckusick mountfs(spec, name, flags, type, options, mntopts)
21739131Smckusick 	char *spec, *name, *type, *options, *mntopts;
21839333Smckusick 	int flags;
21912808Ssam {
22066138Sbostic 	struct ufs_args args;
22142253Sbostic 	pid_t pid;
22266138Sbostic 	int argc, i, status;
22339131Smckusick 	char *argp, *argv[50];
22466138Sbostic 	char execname[MAXPATHLEN + 1], flagval[12], mntpath[MAXPATHLEN];
2251057Sbill 
22639333Smckusick 	if (mntopts)
22739333Smckusick 		getstdopts(mntopts, &flags);
22839316Smckusick 	if (options)
22939316Smckusick 		getstdopts(options, &flags);
23039333Smckusick 	if (type)
23139333Smckusick 		getstdopts(type, &flags);
23256841Smckusick 	if (force)
23356841Smckusick 		flags |= MNT_FORCE;
23466133Spendry 
23566133Spendry 	if (realpath(name, mntpath) == 0) {
23666133Spendry 		warn("%s", mntpath);
23766133Spendry 		return (1);
23866133Spendry 	}
23966133Spendry 
24066133Spendry 	name = mntpath;
24166133Spendry 
24266131Spendry 	if (strcmp(name, "/") == 0)
24366131Spendry 		flags |= MNT_UPDATE;
24466131Spendry 
24539316Smckusick 	switch (mnttype) {
24639316Smckusick 	case MOUNT_UFS:
24739333Smckusick 		if (mntopts)
24839333Smckusick 			getufsopts(mntopts, &flags);
24939316Smckusick 		if (options)
25039316Smckusick 			getufsopts(options, &flags);
25139316Smckusick 		args.fspec = spec;
25266138Sbostic #define	DEFAULT_ROOTUID	-2
25365714Shibler 		args.export.ex_root = DEFAULT_ROOTUID;
25441403Smckusick 		if (flags & MNT_RDONLY)
25565714Shibler 			args.export.ex_flags = MNT_EXRDONLY;
25640496Smckusick 		else
25765714Shibler 			args.export.ex_flags = 0;
25839316Smckusick 		argp = (caddr_t)&args;
25939316Smckusick 		break;
26052110Smckusick 	case MOUNT_MFS:
26139316Smckusick 	case MOUNT_NFS:
26239322Smckusick 	default:
26339322Smckusick 		argv[0] = mntname;
26439329Smckusick 		argc = 1;
26539322Smckusick 		if (flags) {
26639322Smckusick 			argv[argc++] = "-F";
26766138Sbostic 			(void)snprintf(flagval, sizeof(flagval), "%d", flags);
26839322Smckusick 			argv[argc++] = flagval;
26939322Smckusick 		}
27039333Smckusick 		if (mntopts)
27139333Smckusick 			argc += getexecopts(mntopts, &argv[argc]);
27239329Smckusick 		if (options)
27339329Smckusick 			argc += getexecopts(options, &argv[argc]);
27439316Smckusick 		argv[argc++] = spec;
27539316Smckusick 		argv[argc++] = name;
27639521Smckusick 		argv[argc++] = NULL;
27766138Sbostic 		snprintf(execname, sizeof(execname),
27866138Sbostic 		    "%s/mount_%s", _PATH_EXECDIR, mntname);
27939316Smckusick 		if (verbose) {
28042253Sbostic 			(void)printf("exec: %s", execname);
28142253Sbostic 			for (i = 1; i < argc - 1; i++)
28242253Sbostic 				(void)printf(" %s", argv[i]);
28342253Sbostic 			(void)printf("\n");
28439316Smckusick 		}
28556841Smckusick 		if (debug)
28639316Smckusick 			break;
28742253Sbostic 		if (pid = vfork()) {
28842253Sbostic 			if (pid == -1) {
28966131Spendry 				warn("vfork starting file system");
29039316Smckusick 				return (1);
29139131Smckusick 			}
29266130Spendry 			if (waitpid(pid, &status, 0) != -1 &&
29339316Smckusick 			    WIFEXITED(status) &&
29439316Smckusick 			    WEXITSTATUS(status) != 0)
29539316Smckusick 				return (WEXITSTATUS(status));
29639322Smckusick 			spec = mntname;
29739316Smckusick 			goto out;
29839316Smckusick 		}
29966130Spendry 		execv(execname, argv);
30066131Spendry 		err(1, "cannot exec %s for %s", execname, name);
30139316Smckusick 		/* NOTREACHED */
30238632Smckusick 
30339316Smckusick 	}
30456841Smckusick 	if (!debug && mount(mnttype, name, flags, argp)) {
30566138Sbostic 		(void)fprintf(stderr, "%s on %s: ", spec, name);
30639316Smckusick 		switch (errno) {
30739316Smckusick 		case EMFILE:
308*66139Sbostic 			(void)fprintf(stderr, "Mount table full.\n");
30939316Smckusick 			break;
31039316Smckusick 		case EINVAL:
31141403Smckusick 			if (flags & MNT_UPDATE)
31266138Sbostic 				(void)fprintf(stderr, "Specified device %s\n",
31345689Smckusick 					"does not match mounted device");
31445569Skarels 			else if (mnttype == MOUNT_UFS)
31566138Sbostic 				(void)fprintf(stderr, "Bogus super block\n");
31639333Smckusick 			else
31766138Sbostic 				perror(NULL);
31839316Smckusick 			break;
31939316Smckusick 		default:
32066138Sbostic 			perror(NULL);
32139316Smckusick 			break;
3224460Sroot 		}
32366130Spendry 		return (1);
3244460Sroot 	}
32535339Sbostic 
32666138Sbostic out:	if (verbose)
32739316Smckusick 		prmount(spec, name, flags);
32866130Spendry 	return (0);
3291057Sbill }
33035339Sbostic 
33166138Sbostic void
33239316Smckusick prmount(spec, name, flags)
33339316Smckusick 	char *spec, *name;
33466130Spendry 	int flags;
33535339Sbostic {
33666130Spendry 	int first;
33738632Smckusick 
33842253Sbostic 	(void)printf("%s on %s", spec, name);
33942253Sbostic 	if (!(flags & MNT_VISFLAGMASK)) {
34042253Sbostic 		(void)printf("\n");
34142253Sbostic 		return;
34242253Sbostic 	}
34342253Sbostic 	first = 0;
34442253Sbostic #define	PR(msg)	(void)printf("%s%s", !first++ ? " (" : ", ", msg)
34541403Smckusick 	if (flags & MNT_RDONLY)
34642253Sbostic 		PR("read-only");
34741403Smckusick 	if (flags & MNT_NOEXEC)
34842253Sbostic 		PR("noexec");
34941403Smckusick 	if (flags & MNT_NOSUID)
35042253Sbostic 		PR("nosuid");
35141403Smckusick 	if (flags & MNT_NODEV)
35242253Sbostic 		PR("nodev");
35341403Smckusick 	if (flags & MNT_SYNCHRONOUS)
35442253Sbostic 		PR("synchronous");
35565609Smckusick 	if (flags & MNT_ASYNC)
35665609Smckusick 		PR("asynchronous");
35741403Smckusick 	if (flags & MNT_QUOTA)
35842253Sbostic 		PR("with quotas");
35941403Smckusick 	if (flags & MNT_LOCAL)
36042253Sbostic 		PR("local");
36155394Spendry 	if (flags & MNT_UNION)
36255394Spendry 		PR("union");
36341403Smckusick 	if (flags & MNT_EXPORTED)
36452110Smckusick 		PR("NFS exported");
36542253Sbostic 	(void)printf(")\n");
36635339Sbostic }
36735339Sbostic 
36866138Sbostic int
36939133Smckusick getmnttype(fstype)
37039133Smckusick 	char *fstype;
37139133Smckusick {
37239133Smckusick 
37339322Smckusick 	mntname = fstype;
37466138Sbostic 	return (strcmp(fstype, "ufs") == 0 ? MOUNT_UFS : 0);
37539133Smckusick }
37639133Smckusick 
37766138Sbostic void
37839316Smckusick getstdopts(options, flagp)
37939316Smckusick 	char *options;
38042253Sbostic 	int *flagp;
38139316Smckusick {
38239316Smckusick 	int negative;
38366138Sbostic 	char *opt, optbuf[BUFSIZ];
38439316Smckusick 
38542253Sbostic 	(void)strcpy(optbuf, options);
38666138Sbostic 	for (opt = strtok(optbuf, ","); opt; opt = strtok(NULL, ",")) {
38765852Smckusick 		if (opt[0] == '-')
38865852Smckusick 			continue;
38939316Smckusick 		if (opt[0] == 'n' && opt[1] == 'o') {
39039316Smckusick 			negative++;
39139316Smckusick 			opt += 2;
39266138Sbostic 		} else
39339316Smckusick 			negative = 0;
39439333Smckusick 		if (!negative && !strcasecmp(opt, FSTAB_RO)) {
39541403Smckusick 			*flagp |= MNT_RDONLY;
39639333Smckusick 			continue;
39739333Smckusick 		}
39839333Smckusick 		if (!negative && !strcasecmp(opt, FSTAB_RW)) {
39941403Smckusick 			*flagp &= ~MNT_RDONLY;
40039333Smckusick 			continue;
40139333Smckusick 		}
40239316Smckusick 		if (!strcasecmp(opt, "exec")) {
40339316Smckusick 			if (negative)
40441403Smckusick 				*flagp |= MNT_NOEXEC;
40539333Smckusick 			else
40641403Smckusick 				*flagp &= ~MNT_NOEXEC;
40739316Smckusick 			continue;
40839316Smckusick 		}
40939316Smckusick 		if (!strcasecmp(opt, "suid")) {
41039316Smckusick 			if (negative)
41141403Smckusick 				*flagp |= MNT_NOSUID;
41239333Smckusick 			else
41341403Smckusick 				*flagp &= ~MNT_NOSUID;
41439316Smckusick 			continue;
41539316Smckusick 		}
41639316Smckusick 		if (!strcasecmp(opt, "dev")) {
41739316Smckusick 			if (negative)
41841403Smckusick 				*flagp |= MNT_NODEV;
41939333Smckusick 			else
42041403Smckusick 				*flagp &= ~MNT_NODEV;
42139316Smckusick 			continue;
42239316Smckusick 		}
42339316Smckusick 		if (!strcasecmp(opt, "synchronous")) {
42439316Smckusick 			if (!negative)
42541403Smckusick 				*flagp |= MNT_SYNCHRONOUS;
42639333Smckusick 			else
42741403Smckusick 				*flagp &= ~MNT_SYNCHRONOUS;
42839316Smckusick 			continue;
42939316Smckusick 		}
43065609Smckusick 		if (!strcasecmp(opt, "asynchronous")) {
43165609Smckusick 			if (!negative)
43265609Smckusick 				*flagp |= MNT_ASYNC;
43365609Smckusick 			else
43465609Smckusick 				*flagp &= ~MNT_ASYNC;
43565609Smckusick 			continue;
43665609Smckusick 		}
43755394Spendry 		if (!strcasecmp(opt, "union")) {
43855394Spendry 			if (!negative)
43955394Spendry 				*flagp |= MNT_UNION;
44055394Spendry 			else
44155394Spendry 				*flagp &= ~MNT_UNION;
44255394Spendry 			continue;
44355394Spendry 		}
44466138Sbostic 		(void)fprintf(stderr, "mount: %s: unknown option\n", opt);
44539316Smckusick 	}
44639316Smckusick }
44739316Smckusick 
44842253Sbostic /* ARGSUSED */
44966138Sbostic void
45039131Smckusick getufsopts(options, flagp)
45139131Smckusick 	char *options;
45242253Sbostic 	int *flagp;
45339131Smckusick {
45466130Spendry 
45539131Smckusick 	return;
45639131Smckusick }
45739131Smckusick 
45866138Sbostic int
45939329Smckusick getexecopts(options, argv)
46066138Sbostic 	char *options, **argv;
46139131Smckusick {
46266138Sbostic 	int argc;
46366130Spendry 	char *opt;
46439131Smckusick 
46566138Sbostic 	argc = 0;
46666138Sbostic 	for (opt = strtok(options, ","); opt; opt = strtok(NULL, ",")) {
46739131Smckusick 		if (opt[0] != '-')
46839131Smckusick 			continue;
46939131Smckusick 		argv[argc++] = opt;
47039131Smckusick 		if (opt[2] == '\0' || opt[2] != '=')
47139131Smckusick 			continue;
47239131Smckusick 		opt[2] = '\0';
47339131Smckusick 		argv[argc++] = &opt[3];
47439131Smckusick 	}
47539131Smckusick 	return (argc);
47639131Smckusick }
47739131Smckusick 
47866138Sbostic struct statfs *
47939465Smckusick getmntpt(name)
48039465Smckusick 	char *name;
48139465Smckusick {
48239465Smckusick 	struct statfs *mntbuf;
48366138Sbostic 	long i, mntsize;
48439465Smckusick 
48540337Smckusick 	mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
48639465Smckusick 	for (i = 0; i < mntsize; i++) {
48739465Smckusick 		if (!strcmp(mntbuf[i].f_mntfromname, name) ||
48839465Smckusick 		    !strcmp(mntbuf[i].f_mntonname, name))
48939465Smckusick 			return (&mntbuf[i]);
49039465Smckusick 	}
49166138Sbostic 	return (NULL);
49239465Smckusick }
49339465Smckusick 
49466138Sbostic int
49540051Smckusick badvfstype(vfstype, vfslist)
49666130Spendry 	int vfstype;
49740051Smckusick 	char **vfslist;
49840051Smckusick {
49940051Smckusick 
50066138Sbostic 	if (vfslist == NULL)
50166130Spendry 		return (0);
50266138Sbostic 	while (*vfslist != NULL) {
50340844Smckusick 		if (vfstype == getmnttype(*vfslist))
50466130Spendry 			return (skipvfs);
50540051Smckusick 		vfslist++;
50640051Smckusick 	}
50740051Smckusick 	return (!skipvfs);
50840051Smckusick }
50940051Smckusick 
51066138Sbostic int
51140844Smckusick badvfsname(vfsname, vfslist)
51240844Smckusick 	char *vfsname;
51340844Smckusick 	char **vfslist;
51440844Smckusick {
51540844Smckusick 
51666138Sbostic 	if (vfslist == NULL)
51766130Spendry 		return (0);
51866138Sbostic 	while (*vfslist != NULL) {
51940844Smckusick 		if (strcmp(vfsname, *vfslist) == 0)
52066130Spendry 			return (skipvfs);
52140844Smckusick 		vfslist++;
52240844Smckusick 	}
52340844Smckusick 	return (!skipvfs);
52440844Smckusick }
52540844Smckusick 
52666138Sbostic char **
52740051Smckusick makevfslist(fslist)
52840051Smckusick 	char *fslist;
52940051Smckusick {
53066138Sbostic 	int i;
53166130Spendry 	char **av, *nextcp;
53240051Smckusick 
53340051Smckusick 	if (fslist == NULL)
53440051Smckusick 		return (NULL);
53540051Smckusick 	if (fslist[0] == 'n' && fslist[1] == 'o') {
53640051Smckusick 		fslist += 2;
53740051Smckusick 		skipvfs = 1;
53840051Smckusick 	}
53940051Smckusick 	for (i = 0, nextcp = fslist; *nextcp; nextcp++)
54040051Smckusick 		if (*nextcp == ',')
54140051Smckusick 			i++;
54266138Sbostic 	av = malloc((size_t)(i + 2) * sizeof(char *));
54340051Smckusick 	if (av == NULL)
54440051Smckusick 		return (NULL);
54540051Smckusick 	nextcp = fslist;
54640051Smckusick 	i = 0;
54740051Smckusick 	av[i++] = nextcp;
54866138Sbostic 	while ((nextcp = index(nextcp, ',')) != NULL) {
54940051Smckusick 		*nextcp++ = '\0';
55040051Smckusick 		av[i++] = nextcp;
55140051Smckusick 	}
55266138Sbostic 	av[i++] = NULL;
55340051Smckusick 	return (av);
55440051Smckusick }
55566138Sbostic 
55666138Sbostic void
55766138Sbostic usage()
55866138Sbostic {
55966138Sbostic 
56066138Sbostic 	(void)fprintf(stderr,
56166138Sbostic 		"usage:\n  mount %s %s\n  mount %s\n  mount %s\n",
56266138Sbostic 		"[ -frwu ] [ -t ufs | external_type ]",
56366138Sbostic 		"[ -o options ] special node",
56466138Sbostic 		"[ -afrwu ] [ -t ufs | external_type ]",
56566138Sbostic 		"[ -frwu ] special | node");
56666138Sbostic 	exit(1);
56766138Sbostic }
568