VFS_GETOPT(9)
β¨ VFS_GETOPT(9) β¨ β the Kernel Developer's Manual girlies' edition π
okay bestie, sit DOWN, because today we're talking about vfs_getopt and its entire friend group π«Ά this is a Kernel Developer's Manual page, so grab a strawberry drink and let's get into it πΈ
π NAME π
vfs_getopt, vfs_getopts, vfs_flagopt, vfs_scanopt, vfs_copyopt, vfs_filteropt, vfs_setopt, vfs_setopt_part, vfs_setopts β manipulate mount options and their values
like. the whole squad. mount options and the values that come with them. that's the job π
π SYNOPSIS π
#include <sys/param.h>
#include <sys/mount.h>
int
vfs_getopt(struct vfsoptlist *opts, const char *name, void **buf,
int *len);
char *
vfs_getops(struct vfsoptlist *opts, const char *name, int *error);
int
vfs_flagopt(struct vfsoptlist *opts, const char *name, uint64_t *flags,
uint64_t flag);
int
vfs_scanopt(struct vfsoptlist *opts, const char *name, const char *fmt,
...);
int
vfs_copyopt(struct vfsoptlist *opts, const char *name, void *dest,
int len);
int
vfs_filteropt(struct vfsoptlist *opts, const char **legal);
int
vfs_setopt(struct vfsoptlist *opts, const char *name, void *value,
int len);
int
vfs_setopt_part(struct vfsoptlist *opts, const char *name, void *value,
int len);
int
vfs_setopts(struct vfsoptlist *opts, const char *name,
const char *value);
π DESCRIPTION π
the way that this whole page is just nine little functions handling mount options like the icons they are π let's go one by one, no skipping, fr fr.
vfs_getopt()β this one setsbufto point at the value of the named mount option, and setslento the length of that value if it's notNULL. and listen,bufpoints to the actual value β you do not need to free or release it (and honestly? you probably should not be modifying it either π).vfs_getopts()β returns the value of the specified option, but only if it's a string (i.e., NUL terminated).vfs_flagopt()β checks whether an option exists. if the option does exist, andflagsis notNULL, thenflaggets added to the ones already set inflags. if the option does not exist, andflagsis notNULL, thenflaggets removed from the ones already set inflags. classic usage looks like this, and it's giving very much "set the flag only if the vibes are right":
if (vfs_flagopt(mp->mnt_optnew, "wormlike", NULL, 0))
vfs_flagopt(mp->mnt_optnew, "appendok", &(mp->flags), F_APPENDOK);
vfs_scanopt()β performs avsscanf(3)with the option's value, using the given format, into the specified variable arguments. the value must be a string (i.e., NUL terminated).vfs_copyopt()β makes a copy of the option's value. thelenargument has to match the length of the option's value exactly β like, a larger buffer will still causevfs_copyout()to fail withEINVAL. no cap, exact match or nothing πvfs_filteropt()β makes sure no unknown options were specified. an option is valid if its name matches one of the names in the list of legal names. and yes, an option may be prefixed with'no'and still be considered valid. lenient queen πvfs_setopt()andvfs_setopt_part()β these two copy new data into the option's value. invfs_setopt(), thelenargument must match the length of the option's value exactly (i.e., a larger buffer will still causevfs_copyout()to fail withEINVAL). same energy asvfs_copyopt(), same exact-match drama.vfs_setopts()β copies a new string into the option's value. the string, including the NUL byte, must be no longer than the option's length. count that byte bestie, it counts πΈ
β RETURN VALUES β
the receipts, function by function:
vfs_getopt()returns0if the option was found; otherwise,ENOENTis returned.vfs_getops()returns the specified option if it is found, and is NUL terminated. if the option was found but is not NUL terminated,erroris set toEINVALandNULLis returned. if the option was not found,erroris set to0, andNULLis returned.vfs_flagopt()returns1if the option was found, and0if it was not.vfs_scanopt()returns0if the option was not found, or was not NUL terminated; otherwise, the return value ofvsscanf(3)is returned. and ifvsscanf(3)returns0, it will be returned unchanged β so a return value of0does not always mean the option does not exist, or is not a valid string. sneaky little0, we love an ambiguous queen πvfs_copyopt()andvfs_setopt()return0if the copy was successful,EINVALif the option was found but the lengths did not match, andENOENTif the option was not found.vfs_filteropt()returns0if all of the options are legal; otherwise,EINVALis returned.vfs_setopts()returns0if the copy was successful,EINVALif the option was found but the string was too long, andENOENTif the option was not found.
π¦ AUTHORS π¦
this manual page was written by Chad David <davidc@FreeBSD.org> and Ruslan Ermilov <ru@FreeBSD.org>. absolute legends, thank you for your service π«Ά
and that's the page!! Debian, July 31, 2011, VFS_GETOPT(9) β mwah, iconic, periodt πβ¨π
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (C) 2007 Chad David <davidc@acns.ab.ca>. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms