VFS_GETOPT(9)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

🌸 NAME 🌸 β€” VFS_GETOPT(9), Kernel Developer's Manual

okay so this page is VFS_GETOPT(9) from the Kernel Developer's Manual, and it's all about the mount-option besties: vfs_getopt, vfs_getopts, vfs_flagopt, vfs_scanopt, vfs_copyopt, vfs_filteropt, vfs_setopt, vfs_setopt_part, and vfs_setopts. their whole group-chat purpose is to manipulate mount options and their values, periodt πŸ’…


✨ SYNOPSIS ✨

the required includes are exactly these, no cap:

#include <sys/param.h>
#include <sys/mount.h>

and the function signatures are:

int
vfs_getopt(struct vfsoptlist *opts, const char *name, void **buf,
    int *len);

char *
vfs_getopts(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 πŸ’–

okay so here's the vibe check per function, bestie 🫢

  • vfs_getopt() β€” sets buf to point to the value of the named mount option, and sets len to the length of the value if it is not NULL. the buf argument will point to the actual value, and does not need to be freed or released (and probably should not be modified). yes, literally, that's the whole thing πŸ’…
  • vfs_getopts() β€” returns the value of the specified option if it is a string (i.e., NUL terminated). easy peasy 🌸
  • vfs_flagopt() β€” determines if an option exists. if the option does exist, and flags is not NULL, flag is added to those already set in flags. if the option does not exist, and flags is not NULL, flag is removed from those already set in flags. an example of typical usage is:
if (vfs_flagopt(mp->mnt_optnew, "wormlike", NULL, 0))
        vfs_flagopt(mp->mnt_optnew, "appendok", &(mp->flags), F_APPENDOK);
  • vfs_scanopt() β€” performs a vsscanf(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() β€” creates a copy of the option's value. the len argument must match the length of the option's value exactly (i.e., a larger buffer will still cause vfs_copyout() to fail with EINVAL). yes, the page says vfs_copyout() right there β€” iykyk πŸ™ˆ
  • vfs_filteropt() β€” ensures that no unknown options were specified. an option is valid if its name matches one of the names in the list of legal names. an option may be prefixed with 'no', and still be considered valid. iconic filtering behavior, honestly ✨
  • vfs_setopt() and vfs_setopt_part() β€” copy new data into the option's value. in vfs_setopt(), the len argument must match the length of the option's value exactly (i.e., a larger buffer will still cause vfs_copyout() to fail with EINVAL). πŸŽ€
  • vfs_setopts() β€” copies a new string into the option's value. the string, including NUL byte, must be no longer than the option's length. 🌈

🫢 RETURN VALUES 🫢

  • vfs_getopt() β€” returns 0 if the option was found; otherwise, ENOENT is returned.
  • vfs_getopts() β€” returns the specified option if it is found, and is NUL terminated. if the option was found, but is not NUL terminated, error is set to EINVAL and NULL is returned. if the option was not found, error is set to 0, and NULL is returned.
  • vfs_flagopt() β€” returns 1 if the option was found, and 0 if it was not.
  • vfs_scanopt() β€” returns 0 if the option was not found, or was not NUL terminated; otherwise, the return value of vsscanf(3) is returned. if vsscanf(3) returns 0, it will be returned unchanged; therefore, a return value of 0 does not always mean the option does not exist, or is not a valid string.
  • vfs_copyopt() and vfs_setopt() β€” return 0 if the copy was successful, EINVAL if the option was found but the lengths did not match, and ENOENT if the option was not found.
  • vfs_filteropt() β€” returns 0 if all of the options are legal; otherwise, EINVAL is returned.
  • vfs_setopts() β€” returns 0 if the copy was successful, EINVAL if the option was found but the string was too long, and ENOENT if the option was not found.

πŸ‘‘ AUTHORS πŸ‘‘

this manual page was written by Chad David <davidc@FreeBSD.org> and Ruslan Ermilov <ru@FreeBSD.org>. slay, and thank you for your service πŸ«‘πŸ’–


okay that's the whole VFS_GETOPT(9) moment from the Debian side, dated May 19, 2024 β€” bye bestie, go manipulate those mount options responsibly πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from