xref: /freebsd/share/man/man9/vfs_getopt.9 (revision 3cc1b35bc1bdcdee279b3ee7d0e0946b684df898)
1cbd01db4SChad David.\"
2cbd01db4SChad David.\" Copyright (C) 2007 Chad David <davidc@acns.ab.ca>. All rights reserved.
3cbd01db4SChad David.\"
4cbd01db4SChad David.\" Redistribution and use in source and binary forms, with or without
5cbd01db4SChad David.\" modification, are permitted provided that the following conditions
6cbd01db4SChad David.\" are met:
7cbd01db4SChad David.\" 1. Redistributions of source code must retain the above copyright
8cbd01db4SChad David.\"    notice(s), this list of conditions and the following disclaimer as
9cbd01db4SChad David.\"    the first lines of this file unmodified other than the possible
10cbd01db4SChad David.\"    addition of one or more copyright notices.
11cbd01db4SChad David.\" 2. Redistributions in binary form must reproduce the above copyright
12cbd01db4SChad David.\"    notice(s), this list of conditions and the following disclaimer in the
13cbd01db4SChad David.\"    documentation and/or other materials provided with the distribution.
14cbd01db4SChad David.\"
15cbd01db4SChad David.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
16cbd01db4SChad David.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17cbd01db4SChad David.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18cbd01db4SChad David.\" DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
19cbd01db4SChad David.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20cbd01db4SChad David.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21cbd01db4SChad David.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22cbd01db4SChad David.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23cbd01db4SChad David.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24cbd01db4SChad David.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
25cbd01db4SChad David.\" DAMAGE.
26cbd01db4SChad David.\"
27*3cc1b35bSAlan Somers.Dd May 19, 2024
28cbd01db4SChad David.Dt VFS_GETOPT 9
29cbd01db4SChad David.Os
30cbd01db4SChad David.Sh NAME
31cbd01db4SChad David.Nm vfs_getopt ,
32cbd01db4SChad David.Nm vfs_getopts ,
33cbd01db4SChad David.Nm vfs_flagopt ,
34cbd01db4SChad David.Nm vfs_scanopt ,
35cbd01db4SChad David.Nm vfs_copyopt ,
36f86bce5eSJamie Gritton.Nm vfs_filteropt ,
37f86bce5eSJamie Gritton.Nm vfs_setopt ,
38f86bce5eSJamie Gritton.Nm vfs_setopt_part ,
39f86bce5eSJamie Gritton.Nm vfs_setopts
40cbd01db4SChad David.Nd "manipulate mount options and their values"
41cbd01db4SChad David.Sh SYNOPSIS
42cbd01db4SChad David.In sys/param.h
43cbd01db4SChad David.In sys/mount.h
44cbd01db4SChad David.Ft int
45cbd01db4SChad David.Fo vfs_getopt
46cbd01db4SChad David.Fa "struct vfsoptlist *opts" "const char *name" "void **buf" "int *len"
47cbd01db4SChad David.Fc
48cbd01db4SChad David.Ft "char *"
49*3cc1b35bSAlan Somers.Fn vfs_getopts "struct vfsoptlist *opts" "const char *name" "int *error"
50cbd01db4SChad David.Ft int
51cbd01db4SChad David.Fo vfs_flagopt
52fa53ff88SGlen Barber.Fa "struct vfsoptlist *opts" "const char *name" "uint64_t *flags" "uint64_t flag"
53cbd01db4SChad David.Fc
54cbd01db4SChad David.Ft int
55cbd01db4SChad David.Fo vfs_scanopt
56cbd01db4SChad David.Fa "struct vfsoptlist *opts" "const char *name" "const char *fmt" ...
57cbd01db4SChad David.Fc
58cbd01db4SChad David.Ft int
59cbd01db4SChad David.Fo vfs_copyopt
60cbd01db4SChad David.Fa "struct vfsoptlist *opts" "const char *name" "void *dest" "int len"
61cbd01db4SChad David.Fc
62cbd01db4SChad David.Ft int
63cbd01db4SChad David.Fo vfs_filteropt
64cbd01db4SChad David.Fa "struct vfsoptlist *opts" "const char **legal"
65cbd01db4SChad David.Fc
66f86bce5eSJamie Gritton.Ft int
67f86bce5eSJamie Gritton.Fo vfs_setopt
68f86bce5eSJamie Gritton.Fa "struct vfsoptlist *opts" "const char *name" "void *value" "int len"
69f86bce5eSJamie Gritton.Fc
70f86bce5eSJamie Gritton.Ft int
71f86bce5eSJamie Gritton.Fo vfs_setopt_part
72f86bce5eSJamie Gritton.Fa "struct vfsoptlist *opts" "const char *name" "void *value" "int len"
73f86bce5eSJamie Gritton.Fc
74f86bce5eSJamie Gritton.Ft int
75f86bce5eSJamie Gritton.Fo vfs_setopts
76f86bce5eSJamie Gritton.Fa "struct vfsoptlist *opts" "const char *name" "const char *value"
77f86bce5eSJamie Gritton.Fc
78cbd01db4SChad David.Sh DESCRIPTION
79cbd01db4SChad DavidThe
80cbd01db4SChad David.Fn vfs_getopt
81cbd01db4SChad Davidfunction sets
82cbd01db4SChad David.Fa buf
83cbd01db4SChad Davidto point to the value of the named mount option, and sets
84cbd01db4SChad David.Fa len
85cbd01db4SChad Davidto the length of the value if it is not
86cbd01db4SChad David.Dv NULL .
87cbd01db4SChad DavidThe
88cbd01db4SChad David.Fa buf
89cbd01db4SChad Davidargument
90cbd01db4SChad Davidwill point to the actual value, and does not need to be freed or released
91cbd01db4SChad David(and probably should not be modified).
92cbd01db4SChad David.Pp
93cbd01db4SChad DavidThe
94cbd01db4SChad David.Fn vfs_getopts
95cbd01db4SChad Davidfunction
96cbd01db4SChad Davidreturns the value of the specified option if it is a string (i.e.,
97cbd01db4SChad David.Dv NUL
98cbd01db4SChad Davidterminated).
99cbd01db4SChad David.Pp
100cbd01db4SChad DavidThe
101cbd01db4SChad David.Fn vfs_flagopt
102cbd01db4SChad Davidfunction determines if an option exists.
103cbd01db4SChad DavidIf the option does exist, and
104cbd01db4SChad David.Fa flags
105cbd01db4SChad Davidis not
106cbd01db4SChad David.Dv NULL ,
107cbd01db4SChad David.Fa flag
108cbd01db4SChad Davidis added to those already set in
109cbd01db4SChad David.Fa flags .
110cbd01db4SChad DavidIf the option does not exist, and
111cbd01db4SChad David.Fa flags
112cbd01db4SChad Davidis not
113cbd01db4SChad David.Dv NULL ,
114cbd01db4SChad David.Fa flag
115cbd01db4SChad Davidis removed from those already set in
116cbd01db4SChad David.Fa flags .
117cbd01db4SChad DavidAn example of typical usage is:
118cbd01db4SChad David.Bd -literal
119cbd01db4SChad Davidif (vfs_flagopt(mp->mnt_optnew, "wormlike", NULL, 0))
120cbd01db4SChad David	vfs_flagopt(mp->mnt_optnew, "appendok", &(mp->flags), F_APPENDOK);
121cbd01db4SChad David.Ed
122cbd01db4SChad David.Pp
123cbd01db4SChad DavidThe
124cbd01db4SChad David.Fn vfs_scanopt
125cbd01db4SChad Davidfunction performs a
126cbd01db4SChad David.Xr vsscanf 3
127f86bce5eSJamie Grittonwith the option's value, using the given format,
128cbd01db4SChad Davidinto the specified variable arguments.
129cbd01db4SChad DavidThe value must be a string (i.e.,
130cbd01db4SChad David.Dv NUL
131cbd01db4SChad Davidterminated).
132cbd01db4SChad David.Pp
133cbd01db4SChad DavidThe
134cbd01db4SChad David.Fn vfs_copyopt
135f86bce5eSJamie Grittonfunction creates a copy of the option's value.
136cbd01db4SChad DavidThe
137cbd01db4SChad David.Fa len
138f86bce5eSJamie Grittonargument must match the length of the option's value exactly
139cbd01db4SChad David(i.e., a larger buffer will still cause
140cbd01db4SChad David.Fn vfs_copyout
141cbd01db4SChad Davidto fail with
142cbd01db4SChad David.Er EINVAL ) .
143cbd01db4SChad David.Pp
144cbd01db4SChad DavidThe
145cbd01db4SChad David.Fn vfs_filteropt
146cbd01db4SChad Davidfunction ensures that no unknown options were specified.
147cbd01db4SChad DavidA option is valid if its name matches one of the names in the
148cbd01db4SChad Davidlist of legal names.
149cbd01db4SChad DavidAn option may be prefixed with 'no', and still be considered valid.
150f86bce5eSJamie Gritton.Pp
151f86bce5eSJamie GrittonThe
152f86bce5eSJamie Gritton.Fn vfs_setopt
153f86bce5eSJamie Grittonand
154f86bce5eSJamie Gritton.Fn vfs_setopt_part
155f86bce5eSJamie Grittonfunctions copy new data into the option's value.
156f86bce5eSJamie GrittonIn
157f86bce5eSJamie Gritton.Fn vfs_setopt ,
158f86bce5eSJamie Grittonthe
159f86bce5eSJamie Gritton.Fa len
160f86bce5eSJamie Grittonargument must match the length of the option's value exactly
161f86bce5eSJamie Gritton(i.e., a larger buffer will still cause
162f86bce5eSJamie Gritton.Fn vfs_copyout
163f86bce5eSJamie Grittonto fail with
164f86bce5eSJamie Gritton.Er EINVAL ) .
165f86bce5eSJamie Gritton.Pp
166f86bce5eSJamie GrittonThe
167f86bce5eSJamie Gritton.Fn vfs_setopts
168f86bce5eSJamie Grittonfunction copies a new string into the option's value.
169f86bce5eSJamie GrittonThe string, including
170f86bce5eSJamie Gritton.Dv NUL
171f86bce5eSJamie Grittonbyte, must be no longer than the option's length.
172cbd01db4SChad David.Sh RETURN VALUES
173cbd01db4SChad DavidThe
174cbd01db4SChad David.Fn vfs_getopt
175cbd01db4SChad Davidfunction returns 0 if the option was found; otherwise,
176cbd01db4SChad David.Er ENOENT
177cbd01db4SChad Davidis returned.
178cbd01db4SChad David.Pp
179cbd01db4SChad DavidThe
180*3cc1b35bSAlan Somers.Fn vfs_getopts
181cbd01db4SChad Davidfunction returns the specified option if it is found, and is
182cbd01db4SChad David.Dv NUL
183cbd01db4SChad Davidterminated.
184cbd01db4SChad DavidIf the option was found, but is not
185cbd01db4SChad David.Dv NUL
186cbd01db4SChad Davidterminated,
187cbd01db4SChad David.Fa error
188cbd01db4SChad Davidis set to
189cbd01db4SChad David.Er EINVAL
190cbd01db4SChad Davidand
191cbd01db4SChad David.Dv NULL
192cbd01db4SChad Davidis returned.
193cbd01db4SChad DavidIf the option was not found,
194cbd01db4SChad David.Fa error
195cbd01db4SChad Davidis set to 0, and
196cbd01db4SChad David.Dv NULL
197cbd01db4SChad Davidis returned.
198cbd01db4SChad David.Pp
199cbd01db4SChad DavidThe
200cbd01db4SChad David.Fn vfs_flagopt
201cbd01db4SChad Davidfunction returns 1 if the option was found, and 0 if it was not.
202cbd01db4SChad David.Pp
203cbd01db4SChad DavidThe
204cbd01db4SChad David.Fn vfs_scanopt
205cbd01db4SChad Davidfunction returns 0 if the option was not found, or was not
206cbd01db4SChad David.Dv NUL
207cbd01db4SChad Davidterminated; otherwise, the return value of
208cbd01db4SChad David.Xr vsscanf 3
209cbd01db4SChad Davidis returned.
210cbd01db4SChad DavidIf
211cbd01db4SChad David.Xr vsscanf 3
212cbd01db4SChad Davidreturns 0, it will be returned unchanged; therefore, a return value of 0 does
213cbd01db4SChad Davidnot always mean the option does not exist, or is not a valid string.
214cbd01db4SChad David.Pp
215cbd01db4SChad DavidThe
216cbd01db4SChad David.Fn vfs_copyopt
217f86bce5eSJamie Grittonand
218f86bce5eSJamie Gritton.Fn vfs_setopt
219f86bce5eSJamie Grittonfunctions return 0 if the copy was successful,
220cbd01db4SChad David.Er EINVAL
221cbd01db4SChad Davidif the option was found but the lengths did not match, and
222cbd01db4SChad David.Er ENOENT
223cbd01db4SChad Davidif the option was not found.
224cbd01db4SChad David.Pp
225cbd01db4SChad DavidThe
226cbd01db4SChad David.Fn vfs_filteropt
227cbd01db4SChad Davidfunction returns 0 if all of the options are legal; otherwise,
228cbd01db4SChad David.Er EINVAL
229cbd01db4SChad Davidis returned.
230f86bce5eSJamie Gritton.Pp
231f86bce5eSJamie GrittonThe
232f86bce5eSJamie Gritton.Fn vfs_setopts
233f86bce5eSJamie Grittonfunction returns 0 if the copy was successful,
234f86bce5eSJamie Gritton.Er EINVAL
235f86bce5eSJamie Grittonif the option was found but the string was too long, and
236f86bce5eSJamie Gritton.Er ENOENT
237f86bce5eSJamie Grittonif the option was not found.
238cbd01db4SChad David.Sh AUTHORS
23992cb9e01SRuslan Ermilov.An -nosplit
240cbd01db4SChad DavidThis manual page was written by
2418a7314fcSBaptiste Daroussin.An Chad David Aq Mt davidc@FreeBSD.org
242cbd01db4SChad Davidand
2438a7314fcSBaptiste Daroussin.An Ruslan Ermilov Aq Mt ru@FreeBSD.org .
244