Bring in a transport-independent RPC (TI-RPC).
[dragonfly.git] / sbin / mount / getmntopts.3
CommitLineData
984263bc
MD
1.\" Copyright (c) 1994
2.\" The Regents of the University of California. All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\" notice, this list of conditions and the following disclaimer in the
11.\" documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\" must display the following acknowledgement:
14.\" This product includes software developed by the University of
15.\" California, Berkeley and its contributors.
16.\" 4. 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.\" @(#)getmntopts.3 8.3 (Berkeley) 3/30/95
33.\" $FreeBSD: src/sbin/mount/getmntopts.3,v 1.6.2.4 2003/02/23 20:17:15 trhodes Exp $
1de703da 34.\" $DragonFly: src/sbin/mount/getmntopts.3,v 1.2 2003/06/17 04:27:33 dillon Exp $
984263bc
MD
35.\"
36.Dd March 30, 1995
37.Dt GETMNTOPTS 3
38.Os
39.Sh NAME
40.Nm getmntopts
41.Nd scan mount options
42.Sh SYNOPSIS
43.Fd #include \&"mntopts.h"
44.Ft void
45.Fn getmntopts "char *options" "struct mntopt *mopts" "int *flagp" "int *altflagp"
46.Sh DESCRIPTION
47The
48.Fn getmntopts
49function takes a comma separated option list and a list
50of valid option names, and computes the bitmask
51corresponding to the requested set of options.
52.Pp
53The string
54.Fa options
55is broken down into a sequence of comma separated tokens.
56Each token is looked up in the table described by
57.Fa mopts
58and the bits in
59the word referenced by either
60.Fa flagp
61or
62.Fa altflagp
63(depending on the
64.Va m_altloc
65field of the option's table entry)
66are updated.
67The flag words are not initialized by
68.Fn getmntopts .
69The table,
70.Fa mopts ,
71has the following format:
72.Bd -literal
73struct mntopt {
74 char *m_option; /* option name */
75 int m_inverse; /* is this a negative option, e.g. "dev" */
76 int m_flag; /* bit to set, e.g. MNT_RDONLY */
77 int m_altloc; /* non-zero to use altflagp rather than flagp */
78};
79.Ed
80.Pp
81The members of this structure are:
82.Bl -tag -width m_inverse
83.It Va m_option
84the option name,
85for example
86.Dq Li suid .
87.It Va m_inverse
88tells
89.Fn getmntopts
90that the name has the inverse meaning of the
91bit.
92For example,
93.Dq Li suid
94is the string, whereas the
95mount flag is
96.Dv MNT_NOSUID .
97In this case, the sense of the string and the flag
98are inverted, so the
99.Va m_inverse
100flag should be set.
101.It Va m_flag
102the value of the bit to be set or cleared in
103the flag word when the option is recognized.
104The bit is set when the option is discovered,
105but cleared if the option name was preceded
106by the letters
107.Dq Li no .
108The
109.Va m_inverse
110flag causes these two operations to be reversed.
111.It Va m_altloc
112the bit should be set or cleared in
113.Fa altflagp
114rather than
115.Fa flagp .
116.El
117.Pp
118Each of the user visible
119.Dv MNT_
120flags has a corresponding
121.Dv MOPT_
122macro which defines an appropriate
123.Vt "struct mntopt"
124entry.
125To simplify the program interface and ensure consistency across all
126programs, a general purpose macro,
127.Dv MOPT_STDOPTS ,
128is defined which
129contains an entry for all the generic VFS options.
130In addition, the macros
131.Dv MOPT_FORCE
132and
133.Dv MOPT_UPDATE
134exist to enable the
135.Dv MNT_FORCE
136and
137.Dv MNT_UPDATE
138flags to be set.
139Finally, the table must be terminated by an entry with a
140.Dv NULL
141first element.
142.Sh EXAMPLES
143Most commands will use the standard option set.
144Local file systems which support the
145.Dv MNT_UPDATE
146flag, would also have an
147.Dv MOPT_UPDATE
148entry.
149This can be declared and used as follows:
150.Bd -literal
151#include "mntopts.h"
152
153struct mntopt mopts[] = {
154 MOPT_STDOPTS,
155 MOPT_UPDATE,
156 { NULL }
157};
158
159 ...
160 mntflags = mntaltflags = 0;
161 ...
162 getmntopts(options, mopts, &mntflags, &mntaltflags);
163 ...
164.Ed
165.Sh DIAGNOSTICS
166If the external integer variable
167.Va getmnt_silent
168is non-zero then the
169.Fn getmntopts
170function displays an error message and exits if an
171unrecognized option is encountered.
172By default
173.Va getmnt_silent
174is zero.
175.Sh SEE ALSO
176.Xr err 3 ,
177.Xr mount 8
178.Sh HISTORY
179The
180.Fn getmntopts
181function appeared in
182.Bx 4.4 .