mount.c revision 118580
1/*-
2 * Copyright (c) 1980, 1989, 1993, 1994
3 *	The Regents of the University of California.  All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 *    must display the following acknowledgement:
15 *	This product includes software developed by the University of
16 *	California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 *    may be used to endorse or promote products derived from this software
19 *    without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
35static const char copyright[] =
36"@(#) Copyright (c) 1980, 1989, 1993, 1994\n\
37	The Regents of the University of California.  All rights reserved.\n";
38#endif /* not lint */
39
40#ifndef lint
41#if 0
42static char sccsid[] = "@(#)mount.c	8.25 (Berkeley) 5/8/95";
43#endif
44static const char rcsid[] =
45  "$FreeBSD: head/sbin/mount/mount.c 118580 2003-08-07 04:51:41Z imp $";
46#endif /* not lint */
47
48#include <sys/param.h>
49#include <sys/mount.h>
50#include <sys/stat.h>
51#include <sys/wait.h>
52
53#include <ctype.h>
54#include <err.h>
55#include <errno.h>
56#include <fstab.h>
57#include <paths.h>
58#include <pwd.h>
59#include <signal.h>
60#include <stdio.h>
61#include <stdlib.h>
62#include <string.h>
63#include <unistd.h>
64
65#include "extern.h"
66#include "mntopts.h"
67#include "pathnames.h"
68
69/* `meta' options */
70#define MOUNT_META_OPTION_FSTAB		"fstab"
71#define MOUNT_META_OPTION_CURRENT	"current"
72
73int debug, fstab_style, verbose;
74
75char   *catopt(char *, const char *);
76struct statfs *getmntpt(const char *);
77int	hasopt(const char *, const char *);
78int	ismounted(struct fstab *, struct statfs *, int);
79int	isremountable(const char *);
80void	mangle(char *, int *, const char **);
81char   *update_options(char *, char *, int);
82int	mountfs(const char *, const char *, const char *,
83			int, const char *, const char *);
84void	remopt(char *, const char *);
85void	prmount(struct statfs *);
86void	putfsent(const struct statfs *);
87void	usage(void);
88char   *flags2opts(int);
89
90/* Map from mount options to printable formats. */
91static struct opt {
92	int o_opt;
93	const char *o_name;
94} optnames[] = {
95	{ MNT_ASYNC,		"asynchronous" },
96	{ MNT_EXPORTED,		"NFS exported" },
97	{ MNT_LOCAL,		"local" },
98	{ MNT_NOATIME,		"noatime" },
99	{ MNT_NODEV,		"nodev" },
100	{ MNT_NOEXEC,		"noexec" },
101	{ MNT_NOSUID,		"nosuid" },
102	{ MNT_NOSYMFOLLOW,	"nosymfollow" },
103	{ MNT_QUOTA,		"with quotas" },
104	{ MNT_RDONLY,		"read-only" },
105	{ MNT_SYNCHRONOUS,	"synchronous" },
106	{ MNT_UNION,		"union" },
107	{ MNT_NOCLUSTERR,	"noclusterr" },
108	{ MNT_NOCLUSTERW,	"noclusterw" },
109	{ MNT_SUIDDIR,		"suiddir" },
110	{ MNT_SOFTDEP,		"soft-updates" },
111	{ MNT_MULTILABEL,	"multilabel" },
112	{ MNT_ACLS,		"acls" },
113	{ 0, NULL }
114};
115
116/*
117 * List of VFS types that can be remounted without becoming mounted on top
118 * of each other.
119 * XXX Is this list correct?
120 */
121static const char *
122remountable_fs_names[] = {
123	"ufs", "ffs", "ext2fs",
124	0
125};
126
127int
128main(argc, argv)
129	int argc;
130	char * const argv[];
131{
132	const char *mntfromname, **vfslist, *vfstype;
133	struct fstab *fs;
134	struct statfs *mntbuf;
135	FILE *mountdfp;
136	pid_t pid;
137	int all, ch, i, init_flags, mntsize, rval, have_fstab;
138	char *cp, *ep, *options;
139
140	all = init_flags = 0;
141	options = NULL;
142	vfslist = NULL;
143	vfstype = "ufs";
144	while ((ch = getopt(argc, argv, "adF:fo:prwt:uv")) != -1)
145		switch (ch) {
146		case 'a':
147			all = 1;
148			break;
149		case 'd':
150			debug = 1;
151			break;
152		case 'F':
153			setfstab(optarg);
154			break;
155		case 'f':
156			init_flags |= MNT_FORCE;
157			break;
158		case 'o':
159			if (*optarg)
160				options = catopt(options, optarg);
161			break;
162		case 'p':
163			fstab_style = 1;
164			verbose = 1;
165			break;
166		case 'r':
167			options = catopt(options, "ro");
168			break;
169		case 't':
170			if (vfslist != NULL)
171				errx(1, "only one -t option may be specified");
172			vfslist = makevfslist(optarg);
173			vfstype = optarg;
174			break;
175		case 'u':
176			init_flags |= MNT_UPDATE;
177			break;
178		case 'v':
179			verbose = 1;
180			break;
181		case 'w':
182			options = catopt(options, "noro");
183			break;
184		case '?':
185		default:
186			usage();
187			/* NOTREACHED */
188		}
189	argc -= optind;
190	argv += optind;
191
192#define	BADTYPE(type)							\
193	(strcmp(type, FSTAB_RO) &&					\
194	    strcmp(type, FSTAB_RW) && strcmp(type, FSTAB_RQ))
195
196	rval = 0;
197	switch (argc) {
198	case 0:
199		if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0)
200			err(1, "getmntinfo");
201		if (all) {
202			while ((fs = getfsent()) != NULL) {
203				if (BADTYPE(fs->fs_type))
204					continue;
205				if (checkvfsname(fs->fs_vfstype, vfslist))
206					continue;
207				if (hasopt(fs->fs_mntops, "noauto"))
208					continue;
209				if (!(init_flags & MNT_UPDATE) &&
210				    ismounted(fs, mntbuf, mntsize))
211					continue;
212				if (mountfs(fs->fs_vfstype, fs->fs_spec,
213				    fs->fs_file, init_flags, options,
214				    fs->fs_mntops))
215					rval = 1;
216			}
217		} else if (fstab_style) {
218			for (i = 0; i < mntsize; i++) {
219				if (checkvfsname(mntbuf[i].f_fstypename, vfslist))
220					continue;
221				putfsent(&mntbuf[i]);
222			}
223		} else {
224			for (i = 0; i < mntsize; i++) {
225				if (checkvfsname(mntbuf[i].f_fstypename,
226				    vfslist))
227					continue;
228				prmount(&mntbuf[i]);
229			}
230		}
231		exit(rval);
232	case 1:
233		if (vfslist != NULL)
234			usage();
235
236		if (init_flags & MNT_UPDATE) {
237			mntfromname = NULL;
238			have_fstab = 0;
239			if ((mntbuf = getmntpt(*argv)) == NULL)
240				errx(1, "not currently mounted %s", *argv);
241			/*
242			 * Only get the mntflags from fstab if both mntpoint
243			 * and mntspec are identical. Also handle the special
244			 * case where just '/' is mounted and 'spec' is not
245			 * identical with the one from fstab ('/dev' is missing
246			 * in the spec-string at boot-time).
247			 */
248			if ((fs = getfsfile(mntbuf->f_mntonname)) != NULL) {
249				if (strcmp(fs->fs_spec,
250				    mntbuf->f_mntfromname) == 0 &&
251				    strcmp(fs->fs_file,
252				    mntbuf->f_mntonname) == 0) {
253					have_fstab = 1;
254					mntfromname = mntbuf->f_mntfromname;
255				} else if (argv[0][0] == '/' &&
256				    argv[0][1] == '\0') {
257					fs = getfsfile("/");
258					have_fstab = 1;
259					mntfromname = fs->fs_spec;
260				}
261			}
262			if (have_fstab) {
263				options = update_options(options, fs->fs_mntops,
264				    mntbuf->f_flags);
265			} else {
266				mntfromname = mntbuf->f_mntfromname;
267				options = update_options(options, NULL,
268				    mntbuf->f_flags);
269			}
270			rval = mountfs(mntbuf->f_fstypename, mntfromname,
271			    mntbuf->f_mntonname, init_flags, options, 0);
272			break;
273		}
274		rmslashes(*argv, *argv);
275		if ((fs = getfsfile(*argv)) == NULL &&
276		    (fs = getfsspec(*argv)) == NULL)
277			errx(1, "%s: unknown special file or file system",
278			    *argv);
279		if (BADTYPE(fs->fs_type))
280			errx(1, "%s has unknown file system type",
281			    *argv);
282		rval = mountfs(fs->fs_vfstype, fs->fs_spec, fs->fs_file,
283		    init_flags, options, fs->fs_mntops);
284		break;
285	case 2:
286		/*
287		 * If -t flag has not been specified, the path cannot be
288		 * found, spec contains either a ':' or a '@', then assume
289		 * that an NFS file system is being specified ala Sun.
290		 * Check if the hostname contains only allowed characters
291		 * to reduce false positives.  IPv6 addresses containing
292		 * ':' will be correctly parsed only if the separator is '@'.
293		 * The definition of a valid hostname is taken from RFC 1034.
294		 */
295		if (vfslist == NULL && ((ep = strchr(argv[0], '@')) != NULL) ||
296		    ((ep = strchr(argv[0], ':')) != NULL)) {
297			if (*ep == '@') {
298				cp = ep + 1;
299				ep = cp + strlen(cp);
300			} else
301				cp = argv[0];
302			while (cp != ep) {
303				if (!isdigit(*cp) && !isalpha(*cp) &&
304				    *cp != '.' && *cp != '-' && *cp != ':')
305					break;
306				cp++;
307			}
308			if (cp == ep)
309				vfstype = "nfs";
310		}
311		rval = mountfs(vfstype,
312		    argv[0], argv[1], init_flags, options, NULL);
313		break;
314	default:
315		usage();
316		/* NOTREACHED */
317	}
318
319	/*
320	 * If the mount was successfully, and done by root, tell mountd the
321	 * good news.  Pid checks are probably unnecessary, but don't hurt.
322	 */
323	if (rval == 0 && getuid() == 0 &&
324	    (mountdfp = fopen(_PATH_MOUNTDPID, "r")) != NULL) {
325		if (fscanf(mountdfp, "%d", &pid) == 1 &&
326		     pid > 0 && kill(pid, SIGHUP) == -1 && errno != ESRCH)
327			err(1, "signal mountd");
328		(void)fclose(mountdfp);
329	}
330
331	exit(rval);
332}
333
334int
335ismounted(fs, mntbuf, mntsize)
336	struct fstab *fs;
337	struct statfs *mntbuf;
338	int mntsize;
339{
340	int i;
341
342	if (fs->fs_file[0] == '/' && fs->fs_file[1] == '\0')
343		/* the root file system can always be remounted */
344		return (0);
345
346	for (i = mntsize - 1; i >= 0; --i)
347		if (strcmp(fs->fs_file, mntbuf[i].f_mntonname) == 0 &&
348		    (!isremountable(fs->fs_vfstype) ||
349		     strcmp(fs->fs_spec, mntbuf[i].f_mntfromname) == 0))
350			return (1);
351	return (0);
352}
353
354int
355isremountable(vfsname)
356	const char *vfsname;
357{
358	const char **cp;
359
360	for (cp = remountable_fs_names; *cp; cp++)
361		if (strcmp(*cp, vfsname) == 0)
362			return (1);
363	return (0);
364}
365
366int
367hasopt(mntopts, option)
368	const char *mntopts, *option;
369{
370	int negative, found;
371	char *opt, *optbuf;
372
373	if (option[0] == 'n' && option[1] == 'o') {
374		negative = 1;
375		option += 2;
376	} else
377		negative = 0;
378	optbuf = strdup(mntopts);
379	found = 0;
380	for (opt = optbuf; (opt = strtok(opt, ",")) != NULL; opt = NULL) {
381		if (opt[0] == 'n' && opt[1] == 'o') {
382			if (!strcasecmp(opt + 2, option))
383				found = negative;
384		} else if (!strcasecmp(opt, option))
385			found = !negative;
386	}
387	free(optbuf);
388	return (found);
389}
390
391int
392mountfs(vfstype, spec, name, flags, options, mntopts)
393	const char *vfstype, *spec, *name, *options, *mntopts;
394	int flags;
395{
396	const char *argv[100], **edir;
397	char *path, *cur;
398	struct statfs sf;
399	pid_t pid;
400	int argc, i, status;
401	char *optbuf, execname[PATH_MAX], mntpath[PATH_MAX];
402
403#if __GNUC__
404	(void)&optbuf;
405	(void)&name;
406#endif
407
408	/* resolve the mountpoint with realpath(3) */
409	(void)checkpath(name, mntpath);
410	name = mntpath;
411
412	if (mntopts == NULL)
413		mntopts = "";
414	if (options == NULL) {
415		if (*mntopts == '\0') {
416			options = "rw";
417		} else {
418			options = mntopts;
419			mntopts = "";
420		}
421	}
422	optbuf = catopt(strdup(mntopts), options);
423
424	if (strcmp(name, "/") == 0)
425		flags |= MNT_UPDATE;
426	if (flags & MNT_FORCE)
427		optbuf = catopt(optbuf, "force");
428	if (flags & MNT_RDONLY)
429		optbuf = catopt(optbuf, "ro");
430	/*
431	 * XXX
432	 * The mount_mfs (newfs) command uses -o to select the
433	 * optimization mode.  We don't pass the default "-o rw"
434	 * for that reason.
435	 */
436	if (flags & MNT_UPDATE)
437		optbuf = catopt(optbuf, "update");
438
439	/* Compatibility glue. */
440	if (strcmp(vfstype, "msdos") == 0)
441		vfstype = "msdosfs";
442
443	argc = 0;
444	argv[argc++] = vfstype;
445	mangle(optbuf, &argc, argv);
446	argv[argc++] = spec;
447	argv[argc++] = name;
448	argv[argc] = NULL;
449
450	if (debug) {
451		(void)printf("exec: mount_%s", vfstype);
452		for (i = 1; i < argc; i++)
453			(void)printf(" %s", argv[i]);
454		(void)printf("\n");
455		return (0);
456	}
457
458	switch (pid = fork()) {
459	case -1:				/* Error. */
460		warn("fork");
461		free(optbuf);
462		return (1);
463	case 0:					/* Child. */
464		if (strcmp(vfstype, "ufs") == 0)
465			exit(mount_ufs(argc, (char * const *) argv));
466
467		/* Go find an executable. */
468		(void)snprintf(execname, sizeof(execname), "mount_%s", vfstype);
469		execvP(execname, _PATH_SYSPATH, (char * const *)argv);
470		if (errno == ENOENT) {
471			warn("exec mount_%s not found in %s", vfstype, path);
472		}
473		exit(1);
474		/* NOTREACHED */
475	default:				/* Parent. */
476		free(optbuf);
477
478		if (waitpid(pid, &status, 0) < 0) {
479			warn("waitpid");
480			return (1);
481		}
482
483		if (WIFEXITED(status)) {
484			if (WEXITSTATUS(status) != 0)
485				return (WEXITSTATUS(status));
486		} else if (WIFSIGNALED(status)) {
487			warnx("%s: %s", name, sys_siglist[WTERMSIG(status)]);
488			return (1);
489		}
490
491		if (verbose) {
492			if (statfs(name, &sf) < 0) {
493				warn("statfs %s", name);
494				return (1);
495			}
496			if (fstab_style)
497				putfsent(&sf);
498			else
499				prmount(&sf);
500		}
501		break;
502	}
503
504	return (0);
505}
506
507void
508prmount(sfp)
509	struct statfs *sfp;
510{
511	int flags, i;
512	struct opt *o;
513	struct passwd *pw;
514
515	(void)printf("%s on %s (%s", sfp->f_mntfromname, sfp->f_mntonname,
516	    sfp->f_fstypename);
517
518	flags = sfp->f_flags & MNT_VISFLAGMASK;
519	for (o = optnames; flags && o->o_opt; o++)
520		if (flags & o->o_opt) {
521			(void)printf(", %s", o->o_name);
522			flags &= ~o->o_opt;
523		}
524	if (sfp->f_owner) {
525		(void)printf(", mounted by ");
526		if ((pw = getpwuid(sfp->f_owner)) != NULL)
527			(void)printf("%s", pw->pw_name);
528		else
529			(void)printf("%d", sfp->f_owner);
530	}
531	if (verbose) {
532		if (sfp->f_syncwrites != 0 || sfp->f_asyncwrites != 0)
533			(void)printf(", writes: sync %ld async %ld",
534			    sfp->f_syncwrites, sfp->f_asyncwrites);
535		if (sfp->f_syncreads != 0 || sfp->f_asyncreads != 0)
536			(void)printf(", reads: sync %ld async %ld",
537			    sfp->f_syncreads, sfp->f_asyncreads);
538		printf(", fsid ");
539		for (i = 0; i < sizeof(sfp->f_fsid); i++)
540			printf("%02x", ((u_char *)&sfp->f_fsid)[i]);
541	}
542	(void)printf(")\n");
543}
544
545struct statfs *
546getmntpt(name)
547	const char *name;
548{
549	struct statfs *mntbuf;
550	int i, mntsize;
551
552	mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
553	for (i = mntsize - 1; i >= 0; i--) {
554		if (strcmp(mntbuf[i].f_mntfromname, name) == 0 ||
555		    strcmp(mntbuf[i].f_mntonname, name) == 0)
556			return (&mntbuf[i]);
557	}
558	return (NULL);
559}
560
561char *
562catopt(s0, s1)
563	char *s0;
564	const char *s1;
565{
566	size_t i;
567	char *cp;
568
569	if (s1 == NULL || *s1 == '\0')
570		return s0;
571
572	if (s0 && *s0) {
573		i = strlen(s0) + strlen(s1) + 1 + 1;
574		if ((cp = malloc(i)) == NULL)
575			errx(1, "malloc failed");
576		(void)snprintf(cp, i, "%s,%s", s0, s1);
577	} else
578		cp = strdup(s1);
579
580	if (s0)
581		free(s0);
582	return (cp);
583}
584
585void
586mangle(options, argcp, argv)
587	char *options;
588	int *argcp;
589	const char **argv;
590{
591	char *p, *s;
592	int argc;
593
594	argc = *argcp;
595	for (s = options; (p = strsep(&s, ",")) != NULL;)
596		if (*p != '\0') {
597			if (*p == '-') {
598				argv[argc++] = p;
599				p = strchr(p, '=');
600				if (p) {
601					*p = '\0';
602					argv[argc++] = p+1;
603				}
604			} else if (strcmp(p, "rw") != 0) {
605				argv[argc++] = "-o";
606				argv[argc++] = p;
607			}
608		}
609
610	*argcp = argc;
611}
612
613
614char *
615update_options(opts, fstab, curflags)
616	char *opts;
617	char *fstab;
618	int curflags;
619{
620	char *o, *p;
621	char *cur;
622	char *expopt, *newopt, *tmpopt;
623
624	if (opts == NULL)
625		return strdup("");
626
627	/* remove meta options from list */
628	remopt(fstab, MOUNT_META_OPTION_FSTAB);
629	remopt(fstab, MOUNT_META_OPTION_CURRENT);
630	cur = flags2opts(curflags);
631
632	/*
633	 * Expand all meta-options passed to us first.
634	 */
635	expopt = NULL;
636	for (p = opts; (o = strsep(&p, ",")) != NULL;) {
637		if (strcmp(MOUNT_META_OPTION_FSTAB, o) == 0)
638			expopt = catopt(expopt, fstab);
639		else if (strcmp(MOUNT_META_OPTION_CURRENT, o) == 0)
640			expopt = catopt(expopt, cur);
641		else
642			expopt = catopt(expopt, o);
643	}
644	free(cur);
645	free(opts);
646
647	/*
648	 * Remove previous contradictory arguments. Given option "foo" we
649	 * remove all the "nofoo" options. Given "nofoo" we remove "nonofoo"
650	 * and "foo" - so we can deal with possible options like "notice".
651	 */
652	newopt = NULL;
653	for (p = expopt; (o = strsep(&p, ",")) != NULL;) {
654		if ((tmpopt = malloc( strlen(o) + 2 + 1 )) == NULL)
655			errx(1, "malloc failed");
656
657		strcpy(tmpopt, "no");
658		strcat(tmpopt, o);
659		remopt(newopt, tmpopt);
660		free(tmpopt);
661
662		if (strncmp("no", o, 2) == 0)
663			remopt(newopt, o+2);
664
665		newopt = catopt(newopt, o);
666	}
667	free(expopt);
668
669	return newopt;
670}
671
672void
673remopt(string, opt)
674	char *string;
675 	const char *opt;
676{
677	char *o, *p, *r;
678
679	if (string == NULL || *string == '\0' || opt == NULL || *opt == '\0')
680		return;
681
682	r = string;
683
684	for (p = string; (o = strsep(&p, ",")) != NULL;) {
685		if (strcmp(opt, o) != 0) {
686			if (*r == ',' && *o != '\0')
687				r++;
688			while ((*r++ = *o++) != '\0')
689			    ;
690			*--r = ',';
691		}
692	}
693	*r = '\0';
694}
695
696void
697usage()
698{
699
700	(void)fprintf(stderr, "%s\n%s\n%s\n",
701"usage: mount [-dfpruvw] [-o options] [-t ufs | external_type] special node",
702"       mount [-adfpruvw] [ -F fstab] [-t ufs | external_type]",
703"       mount [-dfpruvw] special | node");
704	exit(1);
705}
706
707void
708putfsent(ent)
709	const struct statfs *ent;
710{
711	struct fstab *fst;
712	char *opts;
713
714	opts = flags2opts(ent->f_flags);
715	printf("%s\t%s\t%s %s", ent->f_mntfromname, ent->f_mntonname,
716	    ent->f_fstypename, opts);
717	free(opts);
718
719	if ((fst = getfsspec(ent->f_mntfromname)))
720		printf("\t%u %u\n", fst->fs_freq, fst->fs_passno);
721	else if ((fst = getfsfile(ent->f_mntonname)))
722		printf("\t%u %u\n", fst->fs_freq, fst->fs_passno);
723	else if (strcmp(ent->f_fstypename, "ufs") == 0) {
724		if (strcmp(ent->f_mntonname, "/") == 0)
725			printf("\t1 1\n");
726		else
727			printf("\t2 2\n");
728	} else
729		printf("\t0 0\n");
730}
731
732
733char *
734flags2opts(flags)
735	int flags;
736{
737	char *res;
738
739	res = NULL;
740
741	res = catopt(res, (flags & MNT_RDONLY) ? "ro" : "rw");
742
743	if (flags & MNT_SYNCHRONOUS)	res = catopt(res, "sync");
744	if (flags & MNT_NOEXEC)		res = catopt(res, "noexec");
745	if (flags & MNT_NOSUID)		res = catopt(res, "nosuid");
746	if (flags & MNT_NODEV)		res = catopt(res, "nodev");
747	if (flags & MNT_UNION)		res = catopt(res, "union");
748	if (flags & MNT_ASYNC)		res = catopt(res, "async");
749	if (flags & MNT_NOATIME)	res = catopt(res, "noatime");
750	if (flags & MNT_NOCLUSTERR)	res = catopt(res, "noclusterr");
751	if (flags & MNT_NOCLUSTERW)	res = catopt(res, "noclusterw");
752	if (flags & MNT_NOSYMFOLLOW)	res = catopt(res, "nosymfollow");
753	if (flags & MNT_SUIDDIR)	res = catopt(res, "suiddir");
754	if (flags & MNT_MULTILABEL)	res = catopt(res, "multilabel");
755	if (flags & MNT_ACLS)		res = catopt(res, "acls");
756
757	return res;
758}
759