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 9.\" the first lines of this file unmodified other than the possible 10.\" addition of one or more copyright notices. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice(s), this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 15.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY 16.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18.\" DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY 19.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 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 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 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 47.Ft "char *" 48.Fn vfs_getops "struct vfsoptlist *opts" "const char *name" "int *error" 49.Ft int 50.Fo vfs_flagopt 51.Fa "struct vfsoptlist *opts" "const char *name" "u_int *flags" "u_int flag" 52.Fc 53.Ft int 54.Fo vfs_scanopt 55.Fa "struct vfsoptlist *opts" "const char *name" "const char *fmt" ... 56.Fc 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 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 73.Dv NULL . 74The 75.Fa buf 76argument 77will point to the actual value, and does not need to be freed or released 78(and probably should not be modified). 79.Pp 80The 81.Fn vfs_getopts 82function 83returns the value of the specified option if it is a string (i.e., 84.Dv NUL 85terminated). 86.Pp 87The 88.Fn vfs_flagopt 89function determines if an option exists. 90If the option does exist, and 91.Fa flags 92is not 93.Dv NULL , 94.Fa flag 95is added to those already set in 96.Fa flags . 97If the option does not exist, and 98.Fa flags 99is not 100.Dv NULL , 101.Fa flag 102is removed from those already set in 103.Fa flags . 104An example of typical usage is: 105.Bd -literal 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 114with the options 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 122function creates a copy of the options value. 123The 124.Fa len 125argument must match the length of the options 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. 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 145.Fn vfs_getops 146function returns the specified option if it is found, and is 147.Dv NUL 148terminated. 149If the option was found, but is not 150.Dv NUL 151terminated, 152.Fa error 153is set to 154.Er EINVAL 155and 156.Dv NULL 157is returned. 158If the option was not found, 159.Fa error 160is set to 0, and 161.Dv NULL 162is returned. 163.Pp 164The 165.Fn vfs_flagopt 166function returns 1 if the option was found, and 0 if it was not. 167.Pp 168The 169.Fn vfs_scanopt 170function returns 0 if the option was not found, or was not 171.Dv NUL 172terminated; otherwise, the return value of 173.Xr vsscanf 3 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 182function returns 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. 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 . 199