update man page for altflags and getmnt_silent
[unix-history] / usr / src / sbin / mount / getmntopts.3
CommitLineData
3e7f8641
KB
1.\" Copyright (c) 1994
2.\" The Regents of the University of California. All rights reserved.
3.\"
4.\" %sccs.include.redist.roff%
5.\"
583cc7c6 6.\" @(#)getmntopts.3 8.3 (Berkeley) %G%
3e7f8641
KB
7.\"
8.Dd
9.Dt GETMNTOPTS 3
10.Os BSD 4.4
11.Sh NAME
12.Nm getmntopts
13.Nd scan mount options
14.Sh SYNOPSIS
15.Fd #include <mntopts.h>
16.Ft void
76e0013a 17.Fn getmntopts "char *options" "struct mntopt *mopts" "int *flagp" "int *altflagp"
3e7f8641
KB
18.Sh DESCRIPTION
19The
20.Nm getmntopts
21function takes a comma separated option list and a list
22of valid option names, and computes the bitmask
23corresponding to the requested set of options.
24.Pp
25The string
26.Dv options
27is broken down into a sequence of comma separated tokens.
28Each token is looked up in the table described by
29.Dv mopts
30and the bits in
76e0013a 31the word referenced by either
3e7f8641 32.Dv flagp
76e0013a
KM
33or
34.Dv altflagp
35(depending on the
36.Dv m_altloc
37field of the option's table entry)
3e7f8641 38are updated.
583cc7c6 39The flag words are not initialized by
3e7f8641
KB
40.Nm getmntopt .
41The table,
42.Dv mopts ,
43has the following format:
44.Bd -literal
45struct mntopt {
46 char *m_option; /* option name */
47 int m_inverse; /* is this a negative option, eg "dev" */
48 int m_flag; /* bit to set, eg MNT_RDONLY */
76e0013a 49 int m_altloc; /* non-zero to use altflagp rather than flagp */
3e7f8641
KB
50};
51.Ed
52.Pp
53The members of this structure are:
54.Bl -tag -width m_inverse
55.It Fa m_option
56the option name,
57for example
58.Dq suid .
59.It Fa m_inverse
60tells
61.Nm getmntopts
62that the name has the inverse meaning of the
63bit.
64For example,
65.Dq suid
66is the string, whereas the
67mount flag is
68.Dv MNT_NOSUID .
69In this case, the sense of the string and the flag
70are inverted, so the
71.Dv m_inverse
72flag should be set.
73.It Fa m_flag
74the value of the bit to be set or cleared in
75the flag word when the option is recognized.
76The bit is set when the option is discovered,
77but cleared if the option name was preceded
78by the letters
79.Dq no .
80The
81.Dv m_inverse
82flag causes these two operations to be reversed.
76e0013a
KM
83.It Fa m_altloc
84the bit should be set or cleared in
85.Dv altflagp
86rather than
87.Dv flagp .
3e7f8641
KB
88.El
89.Pp
90Each of the user visible
91.Dv MNT_
92flags has a corresponding
93.Dv MOPT_
94macro which defines an appropriate
95.Li "struct mntopt"
96entry.
97To simplify the program interface and ensure consistency across all
98programs, a general purpose macro,
99.Dv MOPT_STDOPTS ,
100is defined which
101contains an entry for all the generic VFS options.
102In addition, the macros
103.Dv MOPT_FORCE
104and
105.Dv MOPT_UPDATE
106exist to enable the
107.Dv MNT_FORCE
108and
109.Dv MNT_UPDATE
110flags to be set.
111Finally, the table must be terminated by an entry with a NULL
112first element.
113.Sh EXAMPLES
114Most commands will use the standard option set.
115Local filesystems which support the
116.Dv MNT_UPDATE
117flag, would also have an
118.Dv MOPT_UPDATE
119entry.
120This can be declared and used as follows:
121.Bd -literal
122#include "mntopts.h"
123
124struct mntopt mopts[] = {
125 MOPT_STDOPTS,
126 MOPT_UPDATE,
127 { NULL }
128};
129
130 ...
583cc7c6 131 mntflags = mntaltflags = 0;
3e7f8641 132 ...
583cc7c6 133 getmntopts(options, mopts, &mntflags, &mntaltflags);
3e7f8641
KB
134 ...
135.Ed
136.Sh DIAGNOSTICS
583cc7c6
JSP
137If the external integer variable
138.Dv getmnt_silent
139is non-zero then the
3e7f8641
KB
140.Nm getmntopts
141function displays an error message and exits if an
142unrecognized option is encountered.
583cc7c6
JSP
143By default
144.Dv getmnt_silent
145is zero.
3e7f8641
KB
146.Sh SEE ALSO
147.Xr err 3 ,
148.Xr mount 8
149.Sh HISTORY
150The
151.Fn getmntopts
152function appeared in
153.Bx 4.4 .