Deleted Added
full compact
getmntopts.3 (1559) getmntopts.3 (4065)
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.1 (Berkeley) 3/27/94
33.\"
34.Dd March 27, 1994
35.Dt GETMNTOPTS 3
36.Os BSD 4.4
37.Sh NAME
38.Nm getmntopts
39.Nd scan mount options
40.Sh SYNOPSIS
41.Fd #include <mntopts.h>
42.Ft void
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.1 (Berkeley) 3/27/94
33.\"
34.Dd March 27, 1994
35.Dt GETMNTOPTS 3
36.Os BSD 4.4
37.Sh NAME
38.Nm getmntopts
39.Nd scan mount options
40.Sh SYNOPSIS
41.Fd #include <mntopts.h>
42.Ft void
43.Fn getmntopts "char *options" "struct mntopt *mopts" "int *flagp"
43.Fn getmntopts "char *options" "struct mntopt *mopts" "int *flagp" "int *altflagp"
44.Sh DESCRIPTION
45The
46.Nm getmntopts
47function takes a comma separated option list and a list
48of valid option names, and computes the bitmask
49corresponding to the requested set of options.
50.Pp
51The string
52.Dv options
53is broken down into a sequence of comma separated tokens.
54Each token is looked up in the table described by
55.Dv mopts
56and the bits in
44.Sh DESCRIPTION
45The
46.Nm getmntopts
47function takes a comma separated option list and a list
48of valid option names, and computes the bitmask
49corresponding to the requested set of options.
50.Pp
51The string
52.Dv options
53is broken down into a sequence of comma separated tokens.
54Each token is looked up in the table described by
55.Dv mopts
56and the bits in
57the word referenced by
57the word referenced by either
58.Dv flagp
58.Dv flagp
59or
60.Dv altflagp
61(depending on the
62.Dv m_altloc
63field of the option's table entry)
59are updated.
60The flag word is not initialized by
61.Nm getmntopt .
62The table,
63.Dv mopts ,
64has the following format:
65.Bd -literal
66struct mntopt {
67 char *m_option; /* option name */
68 int m_inverse; /* is this a negative option, eg "dev" */
69 int m_flag; /* bit to set, eg MNT_RDONLY */
64are updated.
65The flag word is not initialized by
66.Nm getmntopt .
67The table,
68.Dv mopts ,
69has the following format:
70.Bd -literal
71struct mntopt {
72 char *m_option; /* option name */
73 int m_inverse; /* is this a negative option, eg "dev" */
74 int m_flag; /* bit to set, eg MNT_RDONLY */
75 int m_altloc; /* non-zero to use altflagp rather than flagp */
70};
71.Ed
72.Pp
73The members of this structure are:
74.Bl -tag -width m_inverse
75.It Fa m_option
76the option name,
77for example
78.Dq suid .
79.It Fa m_inverse
80tells
81.Nm getmntopts
82that the name has the inverse meaning of the
83bit.
84For example,
85.Dq suid
86is the string, whereas the
87mount flag is
88.Dv MNT_NOSUID .
89In this case, the sense of the string and the flag
90are inverted, so the
91.Dv m_inverse
92flag should be set.
93.It Fa m_flag
94the value of the bit to be set or cleared in
95the flag word when the option is recognized.
96The bit is set when the option is discovered,
97but cleared if the option name was preceded
98by the letters
99.Dq no .
100The
101.Dv m_inverse
102flag causes these two operations to be reversed.
76};
77.Ed
78.Pp
79The members of this structure are:
80.Bl -tag -width m_inverse
81.It Fa m_option
82the option name,
83for example
84.Dq suid .
85.It Fa m_inverse
86tells
87.Nm getmntopts
88that the name has the inverse meaning of the
89bit.
90For example,
91.Dq suid
92is the string, whereas the
93mount flag is
94.Dv MNT_NOSUID .
95In this case, the sense of the string and the flag
96are inverted, so the
97.Dv m_inverse
98flag should be set.
99.It Fa m_flag
100the value of the bit to be set or cleared in
101the flag word when the option is recognized.
102The bit is set when the option is discovered,
103but cleared if the option name was preceded
104by the letters
105.Dq no .
106The
107.Dv m_inverse
108flag causes these two operations to be reversed.
109.It Fa m_altloc
110the bit should be set or cleared in
111.Dv altflagp
112rather than
113.Dv flagp .
103.El
104.Pp
105Each of the user visible
106.Dv MNT_
107flags has a corresponding
108.Dv MOPT_
109macro which defines an appropriate
110.Li "struct mntopt"
111entry.
112To simplify the program interface and ensure consistency across all
113programs, a general purpose macro,
114.Dv MOPT_STDOPTS ,
115is defined which
116contains an entry for all the generic VFS options.
117In addition, the macros
118.Dv MOPT_FORCE
119and
120.Dv MOPT_UPDATE
121exist to enable the
122.Dv MNT_FORCE
123and
124.Dv MNT_UPDATE
125flags to be set.
126Finally, the table must be terminated by an entry with a NULL
127first element.
128.Sh EXAMPLES
129Most commands will use the standard option set.
130Local filesystems which support the
131.Dv MNT_UPDATE
132flag, would also have an
133.Dv MOPT_UPDATE
134entry.
135This can be declared and used as follows:
136.Bd -literal
137#include "mntopts.h"
138
139struct mntopt mopts[] = {
140 MOPT_STDOPTS,
141 MOPT_UPDATE,
142 { NULL }
143};
144
145 ...
146 mntflags = 0;
147 ...
148 getmntopts(options, mopts, &mntflags)
149 ...
150.Ed
151.Sh DIAGNOSTICS
152The
153.Nm getmntopts
154function displays an error message and exits if an
155unrecognized option is encountered.
156.Sh SEE ALSO
157.Xr err 3 ,
158.Xr mount 8
159.Sh HISTORY
160The
161.Fn getmntopts
162function appeared in
163.Bx 4.4 .
114.El
115.Pp
116Each of the user visible
117.Dv MNT_
118flags has a corresponding
119.Dv MOPT_
120macro which defines an appropriate
121.Li "struct mntopt"
122entry.
123To simplify the program interface and ensure consistency across all
124programs, a general purpose macro,
125.Dv MOPT_STDOPTS ,
126is defined which
127contains an entry for all the generic VFS options.
128In addition, the macros
129.Dv MOPT_FORCE
130and
131.Dv MOPT_UPDATE
132exist to enable the
133.Dv MNT_FORCE
134and
135.Dv MNT_UPDATE
136flags to be set.
137Finally, the table must be terminated by an entry with a NULL
138first element.
139.Sh EXAMPLES
140Most commands will use the standard option set.
141Local filesystems which support the
142.Dv MNT_UPDATE
143flag, would also have an
144.Dv MOPT_UPDATE
145entry.
146This can be declared and used as follows:
147.Bd -literal
148#include "mntopts.h"
149
150struct mntopt mopts[] = {
151 MOPT_STDOPTS,
152 MOPT_UPDATE,
153 { NULL }
154};
155
156 ...
157 mntflags = 0;
158 ...
159 getmntopts(options, mopts, &mntflags)
160 ...
161.Ed
162.Sh DIAGNOSTICS
163The
164.Nm getmntopts
165function displays an error message and exits if an
166unrecognized option is encountered.
167.Sh SEE ALSO
168.Xr err 3 ,
169.Xr mount 8
170.Sh HISTORY
171The
172.Fn getmntopts
173function appeared in
174.Bx 4.4 .