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