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