vfs_getopt.9 (92cb9e01dc24c72dd3621212f497470ce32e99c1) vfs_getopt.9 (f86bce5ed03f2a4c30a04c29b51624e69c30d8c7)
1.\"
2.\" Copyright (C) 2007 Chad David <davidc@acns.ab.ca>. 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(s), this list of conditions and the following disclaimer as

--- 12 unchanged lines hidden (view full) ---

21.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
25.\" DAMAGE.
26.\"
27.\" $FreeBSD$
28.\"
1.\"
2.\" Copyright (C) 2007 Chad David <davidc@acns.ab.ca>. 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(s), this list of conditions and the following disclaimer as

--- 12 unchanged lines hidden (view full) ---

21.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
25.\" DAMAGE.
26.\"
27.\" $FreeBSD$
28.\"
29.Dd February 28, 2007
29.Dd March 2, 2009
30.Dt VFS_GETOPT 9
31.Os
32.Sh NAME
33.Nm vfs_getopt ,
34.Nm vfs_getopts ,
35.Nm vfs_flagopt ,
36.Nm vfs_scanopt ,
37.Nm vfs_copyopt ,
30.Dt VFS_GETOPT 9
31.Os
32.Sh NAME
33.Nm vfs_getopt ,
34.Nm vfs_getopts ,
35.Nm vfs_flagopt ,
36.Nm vfs_scanopt ,
37.Nm vfs_copyopt ,
38.Nm vfs_filteropt
38.Nm vfs_filteropt ,
39.Nm vfs_setopt ,
40.Nm vfs_setopt_part ,
41.Nm vfs_setopts
39.Nd "manipulate mount options and their values"
40.Sh SYNOPSIS
41.In sys/param.h
42.In sys/mount.h
43.Ft int
44.Fo vfs_getopt
45.Fa "struct vfsoptlist *opts" "const char *name" "void **buf" "int *len"
46.Fc

--- 10 unchanged lines hidden (view full) ---

57.Ft int
58.Fo vfs_copyopt
59.Fa "struct vfsoptlist *opts" "const char *name" "void *dest" "int len"
60.Fc
61.Ft int
62.Fo vfs_filteropt
63.Fa "struct vfsoptlist *opts" "const char **legal"
64.Fc
42.Nd "manipulate mount options and their values"
43.Sh SYNOPSIS
44.In sys/param.h
45.In sys/mount.h
46.Ft int
47.Fo vfs_getopt
48.Fa "struct vfsoptlist *opts" "const char *name" "void **buf" "int *len"
49.Fc

--- 10 unchanged lines hidden (view full) ---

60.Ft int
61.Fo vfs_copyopt
62.Fa "struct vfsoptlist *opts" "const char *name" "void *dest" "int len"
63.Fc
64.Ft int
65.Fo vfs_filteropt
66.Fa "struct vfsoptlist *opts" "const char **legal"
67.Fc
68.Ft int
69.Fo vfs_setopt
70.Fa "struct vfsoptlist *opts" "const char *name" "void *value" "int len"
71.Fc
72.Ft int
73.Fo vfs_setopt_part
74.Fa "struct vfsoptlist *opts" "const char *name" "void *value" "int len"
75.Fc
76.Ft int
77.Fo vfs_setopts
78.Fa "struct vfsoptlist *opts" "const char *name" "const char *value"
79.Fc
65.Sh DESCRIPTION
66The
67.Fn vfs_getopt
68function sets
69.Fa buf
70to point to the value of the named mount option, and sets
71.Fa len
72to the length of the value if it is not

--- 33 unchanged lines hidden (view full) ---

106if (vfs_flagopt(mp->mnt_optnew, "wormlike", NULL, 0))
107 vfs_flagopt(mp->mnt_optnew, "appendok", &(mp->flags), F_APPENDOK);
108.Ed
109.Pp
110The
111.Fn vfs_scanopt
112function performs a
113.Xr vsscanf 3
80.Sh DESCRIPTION
81The
82.Fn vfs_getopt
83function sets
84.Fa buf
85to point to the value of the named mount option, and sets
86.Fa len
87to the length of the value if it is not

--- 33 unchanged lines hidden (view full) ---

121if (vfs_flagopt(mp->mnt_optnew, "wormlike", NULL, 0))
122 vfs_flagopt(mp->mnt_optnew, "appendok", &(mp->flags), F_APPENDOK);
123.Ed
124.Pp
125The
126.Fn vfs_scanopt
127function performs a
128.Xr vsscanf 3
114with the options value, using the given format,
129with the option's value, using the given format,
115into the specified variable arguments.
116The value must be a string (i.e.,
117.Dv NUL
118terminated).
119.Pp
120The
121.Fn vfs_copyopt
130into the specified variable arguments.
131The value must be a string (i.e.,
132.Dv NUL
133terminated).
134.Pp
135The
136.Fn vfs_copyopt
122function creates a copy of the options value.
137function creates a copy of the option's value.
123The
124.Fa len
138The
139.Fa len
125argument must match the length of the options value exactly
140argument must match the length of the option's value exactly
126(i.e., a larger buffer will still cause
127.Fn vfs_copyout
128to fail with
129.Er EINVAL ) .
130.Pp
131The
132.Fn vfs_filteropt
133function ensures that no unknown options were specified.
134A option is valid if its name matches one of the names in the
135list of legal names.
136An option may be prefixed with 'no', and still be considered valid.
141(i.e., a larger buffer will still cause
142.Fn vfs_copyout
143to fail with
144.Er EINVAL ) .
145.Pp
146The
147.Fn vfs_filteropt
148function ensures that no unknown options were specified.
149A option is valid if its name matches one of the names in the
150list of legal names.
151An option may be prefixed with 'no', and still be considered valid.
152.Pp
153The
154.Fn vfs_setopt
155and
156.Fn vfs_setopt_part
157functions copy new data into the option's value.
158In
159.Fn vfs_setopt ,
160the
161.Fa len
162argument must match the length of the option's value exactly
163(i.e., a larger buffer will still cause
164.Fn vfs_copyout
165to fail with
166.Er EINVAL ) .
167.Pp
168The
169.Fn vfs_setopts
170function copies a new string into the option's value.
171The string, including
172.Dv NUL
173byte, must be no longer than the option's length.
137.Sh RETURN VALUES
138The
139.Fn vfs_getopt
140function returns 0 if the option was found; otherwise,
141.Er ENOENT
142is returned.
143.Pp
144The

--- 29 unchanged lines hidden (view full) ---

174is returned.
175If
176.Xr vsscanf 3
177returns 0, it will be returned unchanged; therefore, a return value of 0 does
178not always mean the option does not exist, or is not a valid string.
179.Pp
180The
181.Fn vfs_copyopt
174.Sh RETURN VALUES
175The
176.Fn vfs_getopt
177function returns 0 if the option was found; otherwise,
178.Er ENOENT
179is returned.
180.Pp
181The

--- 29 unchanged lines hidden (view full) ---

211is returned.
212If
213.Xr vsscanf 3
214returns 0, it will be returned unchanged; therefore, a return value of 0 does
215not always mean the option does not exist, or is not a valid string.
216.Pp
217The
218.Fn vfs_copyopt
182function returns 0 if the copy was successful,
219and
220.Fn vfs_setopt
221functions return 0 if the copy was successful,
183.Er EINVAL
184if the option was found but the lengths did not match, and
185.Er ENOENT
186if the option was not found.
187.Pp
188The
189.Fn vfs_filteropt
190function returns 0 if all of the options are legal; otherwise,
191.Er EINVAL
192is returned.
222.Er EINVAL
223if the option was found but the lengths did not match, and
224.Er ENOENT
225if the option was not found.
226.Pp
227The
228.Fn vfs_filteropt
229function returns 0 if all of the options are legal; otherwise,
230.Er EINVAL
231is returned.
232.Pp
233The
234.Fn vfs_setopts
235function returns 0 if the copy was successful,
236.Er EINVAL
237if the option was found but the string was too long, and
238.Er ENOENT
239if the option was not found.
193.Sh AUTHORS
194.An -nosplit
195This manual page was written by
196.An Chad David Aq davidc@FreeBSD.org
197and
198.An Ruslan Ermilov Aq ru@FreeBSD.org .
240.Sh AUTHORS
241.An -nosplit
242This manual page was written by
243.An Chad David Aq davidc@FreeBSD.org
244and
245.An Ruslan Ermilov Aq ru@FreeBSD.org .