Commit | Line | Data |
---|---|---|
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 |
19 | The | |
20 | .Nm getmntopts | |
21 | function takes a comma separated option list and a list | |
22 | of valid option names, and computes the bitmask | |
23 | corresponding to the requested set of options. | |
24 | .Pp | |
25 | The string | |
26 | .Dv options | |
27 | is broken down into a sequence of comma separated tokens. | |
28 | Each token is looked up in the table described by | |
29 | .Dv mopts | |
30 | and the bits in | |
76e0013a | 31 | the word referenced by either |
3e7f8641 | 32 | .Dv flagp |
76e0013a KM |
33 | or |
34 | .Dv altflagp | |
35 | (depending on the | |
36 | .Dv m_altloc | |
37 | field of the option's table entry) | |
3e7f8641 | 38 | are updated. |
583cc7c6 | 39 | The flag words are not initialized by |
3e7f8641 KB |
40 | .Nm getmntopt . |
41 | The table, | |
42 | .Dv mopts , | |
43 | has the following format: | |
44 | .Bd -literal | |
45 | struct 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 | |
53 | The members of this structure are: | |
54 | .Bl -tag -width m_inverse | |
55 | .It Fa m_option | |
56 | the option name, | |
57 | for example | |
58 | .Dq suid . | |
59 | .It Fa m_inverse | |
60 | tells | |
61 | .Nm getmntopts | |
62 | that the name has the inverse meaning of the | |
63 | bit. | |
64 | For example, | |
65 | .Dq suid | |
66 | is the string, whereas the | |
67 | mount flag is | |
68 | .Dv MNT_NOSUID . | |
69 | In this case, the sense of the string and the flag | |
70 | are inverted, so the | |
71 | .Dv m_inverse | |
72 | flag should be set. | |
73 | .It Fa m_flag | |
74 | the value of the bit to be set or cleared in | |
75 | the flag word when the option is recognized. | |
76 | The bit is set when the option is discovered, | |
77 | but cleared if the option name was preceded | |
78 | by the letters | |
79 | .Dq no . | |
80 | The | |
81 | .Dv m_inverse | |
82 | flag causes these two operations to be reversed. | |
76e0013a KM |
83 | .It Fa m_altloc |
84 | the bit should be set or cleared in | |
85 | .Dv altflagp | |
86 | rather than | |
87 | .Dv flagp . | |
3e7f8641 KB |
88 | .El |
89 | .Pp | |
90 | Each of the user visible | |
91 | .Dv MNT_ | |
92 | flags has a corresponding | |
93 | .Dv MOPT_ | |
94 | macro which defines an appropriate | |
95 | .Li "struct mntopt" | |
96 | entry. | |
97 | To simplify the program interface and ensure consistency across all | |
98 | programs, a general purpose macro, | |
99 | .Dv MOPT_STDOPTS , | |
100 | is defined which | |
101 | contains an entry for all the generic VFS options. | |
102 | In addition, the macros | |
103 | .Dv MOPT_FORCE | |
104 | and | |
105 | .Dv MOPT_UPDATE | |
106 | exist to enable the | |
107 | .Dv MNT_FORCE | |
108 | and | |
109 | .Dv MNT_UPDATE | |
110 | flags to be set. | |
111 | Finally, the table must be terminated by an entry with a NULL | |
112 | first element. | |
113 | .Sh EXAMPLES | |
114 | Most commands will use the standard option set. | |
115 | Local filesystems which support the | |
116 | .Dv MNT_UPDATE | |
117 | flag, would also have an | |
118 | .Dv MOPT_UPDATE | |
119 | entry. | |
120 | This can be declared and used as follows: | |
121 | .Bd -literal | |
122 | #include "mntopts.h" | |
123 | ||
124 | struct 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 |
137 | If the external integer variable |
138 | .Dv getmnt_silent | |
139 | is non-zero then the | |
3e7f8641 KB |
140 | .Nm getmntopts |
141 | function displays an error message and exits if an | |
142 | unrecognized option is encountered. | |
583cc7c6 JSP |
143 | By default |
144 | .Dv getmnt_silent | |
145 | is zero. | |
3e7f8641 KB |
146 | .Sh SEE ALSO |
147 | .Xr err 3 , | |
148 | .Xr mount 8 | |
149 | .Sh HISTORY | |
150 | The | |
151 | .Fn getmntopts | |
152 | function appeared in | |
153 | .Bx 4.4 . |