KERNEL_MOUNT(9)
π KERNEL_MOUNT(9) β the kernel dev manual, but make it cute π
okay bestie, so this is the page for KERNEL_MOUNT(9) β it lives in the Kernel Developer's Manual, and it's literally the whole ~vibe~ of how you build mount arguments from inside the kernel. no cap. π
β¨ NAME β¨
free_mntarg, kernel_mount, kernel_vmount, mount_arg, mount_argb, mount_argf, mount_argsu β functions provided as part of the kernel mount interface π«Ά
πΈ SYNOPSIS πΈ
void
free_mntarg(struct mntarg *ma);
int
kernel_mount(struct mntarg *ma, int flags);
int
kernel_vmount(int flags, ...);
struct mntarg *
mount_arg(struct mntarg *ma, const char *name, const void *val,
int len);
struct mntarg *
mount_argb(struct mntarg *ma, int flag, const char *name);
struct mntarg *
mount_argf(struct mntarg *ma, const char *name, const char *fmt, ...);
struct mntarg *
mount_argsu(struct mntarg *ma, const char *name, const void *val,
int len);
π DESCRIPTION π
so the kernel_mount() family is the API you get handed when you wanna build up a lil list of mount arguments and then mount file systems from inside the kernel, bestie. that's the whole thing. it's giving "let me assemble a to-do list for the kernel". by accumulating a list of arguments, the API takes shape and hands over the info the kernel needs to control the mount(8) utility. iconic behavior honestly. π§
and like β when an error occurs, the process will stop. it will not cause a panic(9). so breathe. π
the header of the structure is stored in src/sys/kern/vfs_mount.c, which permits automatic structure creation so the mount process is easier. memory allocation must always be freed when the entire process is complete β it is an error otherwise. yes, always. i don't make the rules (i do not make the rules). π
free_mntarg()β frees or clears themntargstructure. bye bestie πkernel_mount()β pulls information from the structure to perform the mount request on a given file system. and plot twist: it always calls thefree_mntarg()function too. ifmacontains any error code generated during the construction, that code will be called and the file system mount will not be attempted. slay at cleaning up after itself fr fr.kernel_vmount()β a function similar toprintf(9), used to mount a file system. β¨mount_arg()β takes a plain argument and crafts parts of the structure with regards to various mount options. if the length is a value less than0,strlen(3)is used. and heads up: this argument will be referenced until eitherfree_mntarg()orkernel_mount()is called. keep it alive, okay? π«Άmount_argb()β adds boolean arguments to the structure. theflagis the boolean value, andnamemust start with"no", otherwise a panic will occur. NOT a drill. πmount_argf()β addsprintf(9)style arguments to the current structure. πmount_argsu()β adds arguments to the structure from a userland string. π¦
π EXAMPLES π
an example of the *_cmount() function, serving absolute main character energy:
static int
msdosfs_cmount(struct mntarg *ma, void *data, int flags, struct thread *td)
{
struct msdosfs_args args;
int error;
if (data == NULL)
return (EINVAL);
error = copyin(data, &args, sizeof(args));
if (error)
return (error);
ma = mount_argsu(ma, "from", args.fspec, MAXPATHLEN);
ma = mount_arg(ma, "export", &args.export, sizeof(args.export));
ma = mount_argf(ma, "uid", "%d", args.uid);
ma = mount_argf(ma, "gid", "%d", args.gid);
ma = mount_argf(ma, "mask", "%d", args.mask);
ma = mount_argf(ma, "dirmask", "%d", args.dirmask);
ma = mount_argb(ma, args.flags & MSDOSFSMNT_SHORTNAME, "noshortname");
ma = mount_argb(ma, args.flags & MSDOSFSMNT_LONGNAME, "nolongname");
ma = mount_argb(ma, !(args.flags & MSDOSFSMNT_NOWIN95), "nowin95");
ma = mount_argb(ma, args.flags & MSDOSFSMNT_KICONV, "nokiconv");
ma = mount_argsu(ma, "cs_win", args.cs_win, MAXCSLEN);
ma = mount_argsu(ma, "cs_dos", args.cs_dos, MAXCSLEN);
ma = mount_argsu(ma, "cs_local", args.cs_local, MAXCSLEN);
error = kernel_mount(ma, flags);
return (error);
}
and when you're working with kernel_vmount(), the varargs must come in pairs, e.g., {name, value}. no solo acts allowed, it's a duo situation. π
error = kernel_vmount(
MNT_RDONLY,
"fstype", vfsname,
"fspath", "/",
"from", path,
NULL);
π SEE ALSO π
β HISTORY β
the kernel_mount() family of functions and this manual page first appeared in FreeBSD 6.0. throwback era fr. π°οΈ
π«Ά AUTHORS π«Ά
the kernel_mount() family of functions and API was developed by Poul-Henning Kamp <phk@FreeBSD.org>. and this manual page was written by Tom Rhodes <trhodes@FreeBSD.org>. legends, honestly, we stan. π
and that's the whole page bestie β this one came from Debian, dated December 13, 2004, and it's filed under KERNEL_MOUNT(9). go mount something (from inside the kernel, responsibly). bye ily πβ¨
π¦ 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) 2004 Tom Rhodes
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms