Deleted Added
full compact
getmntopts.3 (4065) getmntopts.3 (23678)
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.\"
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
32.\" @(#)getmntopts.3 8.3 (Berkeley) 3/30/95
33.\"
33.\"
34.Dd March 27, 1994
34.Dd March 30, 1995
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" "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
57the word referenced by either
58.Dv flagp
59or
60.Dv altflagp
61(depending on the
62.Dv m_altloc
63field of the option's table entry)
64are updated.
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" "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
57the word referenced by either
58.Dv flagp
59or
60.Dv altflagp
61(depending on the
62.Dv m_altloc
63field of the option's table entry)
64are updated.
65The flag word is not initialized by
65The flag words are 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 */
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 .
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 ...
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 */
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 .
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;
157 mntflags = mntaltflags = 0;
158 ...
158 ...
159 getmntopts(options, mopts, &mntflags)
159 getmntopts(options, mopts, &mntflags, &mntaltflags);
160 ...
161.Ed
162.Sh DIAGNOSTICS
160 ...
161.Ed
162.Sh DIAGNOSTICS
163The
163If the external integer variable
164.Dv getmnt_silent
165is non-zero then the
164.Nm getmntopts
165function displays an error message and exits if an
166unrecognized option is encountered.
166.Nm getmntopts
167function displays an error message and exits if an
168unrecognized option is encountered.
169By default
170.Dv getmnt_silent
171is zero.
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 .
172.Sh SEE ALSO
173.Xr err 3 ,
174.Xr mount 8
175.Sh HISTORY
176The
177.Fn getmntopts
178function appeared in
179.Bx 4.4 .