xref: /openbsd/sbin/mount/mntopts.h (revision 404b540a)
1 /*	$OpenBSD: mntopts.h,v 1.15 2005/05/26 01:37:49 pedro Exp $	*/
2 /*	$NetBSD: mntopts.h,v 1.3 1995/03/18 14:56:59 cgd Exp $	*/
3 
4 /*-
5  * Copyright (c) 1994
6  *      The Regents of the University of California.  All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. Neither the name of the University nor the names of its contributors
17  *    may be used to endorse or promote products derived from this software
18  *    without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  * SUCH DAMAGE.
31  *
32  *	@(#)mntopts.h	8.3 (Berkeley) 3/27/94
33  */
34 
35 #define MFLAG_INVERSE		0x01	/* if a negative option, eg "dev" */
36 #define MFLAG_SET		0x02	/* 1 => set bit in mntflags,
37 					   0 => return flag */
38 #define MFLAG_STRVAL		0x04	/* option needs a string value */
39 #define MFLAG_INTVAL		0x08	/* option needs an int value */
40 #define MFLAG_OPT		0x10	/* value is optional */
41 
42 struct mntopt {
43 	const char *m_option;	/* option name */
44 	int m_flag;		/* bit to set, eg. MNT_RDONLY */
45 	int m_oflags;
46 };
47 
48 union mntval {
49 	char *strval;
50 	int ival;
51 };
52 
53 /* User-visible MNT_ flags. */
54 #define MOPT_ASYNC	{ "async",	MNT_ASYNC, MFLAG_SET }
55 #define MOPT_NOACCESSTIME	{ "accesstime", MNT_NOATIME,		\
56 					MFLAG_INVERSE | MFLAG_SET }
57 #define MOPT_NOATIME	{ "atime",      MNT_NOATIME, MFLAG_INVERSE | MFLAG_SET }
58 #define MOPT_NODEV	{ "dev",	MNT_NODEV, MFLAG_INVERSE | MFLAG_SET }
59 #define MOPT_NOEXEC	{ "exec",	MNT_NOEXEC, MFLAG_INVERSE | MFLAG_SET }
60 #define MOPT_NOSUID	{ "suid",	MNT_NOSUID, MFLAG_INVERSE | MFLAG_SET }
61 #define MOPT_RDONLY	{ "rdonly",	MNT_RDONLY, MFLAG_SET }
62 #define MOPT_SYNC	{ "sync",	MNT_SYNCHRONOUS, MFLAG_SET }
63 #define MOPT_USERQUOTA	{ "userquota",	0, MFLAG_SET | MFLAG_STRVAL \
64 					    | MFLAG_OPT }
65 #define MOPT_GROUPQUOTA	{ "groupquota",	0, MFLAG_SET | MFLAG_STRVAL \
66 					    | MFLAG_OPT }
67 #define MOPT_SOFTDEP	{ "softdep",	MNT_SOFTDEP, MFLAG_SET }
68 
69 /* Control flags. */
70 #define MOPT_FORCE	{ "force",	MNT_FORCE, MFLAG_SET }
71 #define MOPT_UPDATE	{ "update",	MNT_UPDATE, MFLAG_SET }
72 #define MOPT_RELOAD	{ "reload",	MNT_RELOAD, MFLAG_SET }
73 
74 /* Support for old-style "ro", "rw" flags. */
75 #define MOPT_RO		{ "ro",		MNT_RDONLY, MFLAG_SET }
76 #define MOPT_RW		{ "rw",		MNT_RDONLY, MFLAG_INVERSE | MFLAG_SET }
77 
78 /* This is parsed by mount(8), but is ignored by specific mount_*(8)s. */
79 #define MOPT_AUTO		{ "auto",	0, MFLAG_SET }
80 
81 #define MOPT_FSTAB_COMPAT						\
82 	MOPT_RO,							\
83 	MOPT_RW,							\
84 	MOPT_AUTO
85 
86 /* Standard options which all mounts can understand. */
87 #define MOPT_STDOPTS							\
88 	MOPT_USERQUOTA,							\
89 	MOPT_GROUPQUOTA,						\
90 	MOPT_FSTAB_COMPAT,						\
91 	MOPT_NOACCESSTIME,						\
92 	MOPT_NOATIME,							\
93 	MOPT_NODEV,							\
94 	MOPT_NOEXEC,							\
95 	MOPT_NOSUID,							\
96 	MOPT_RDONLY
97 
98 int getmntopts(const char *, const struct mntopt *, int *);
99 int getmntopt(char **, union mntval *, const struct mntopt *, int *);
100