KERNEL_MOUNT(9)
π KERNEL_MOUNT(9) π
okay so this is the KERNEL_MOUNT(9) page from the Kernel Developer's Manual, and it's lowkey iconic: it's the kernel-side API for building mount arguments. every single detail is staying, no cap. π«Ά
πΈ NAME πΈ
free_mntarg, kernel_mount, 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);
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 π¦
Okay so the kernel_mount() family of functions are provided as an API for building a list of mount arguments which will be used to mount file systems from inside the kernel. By accumulating a list of arguments, the API takes shape and provides the information necessary for the kernel to control the mount(8) utility. When an error occurs, the process will stop. This will not cause a panic(9). π
The header of the structure is stored in src/sys/kern/vfs_mount.c which permits automatic structure creation to ease the mount process. Memory allocation must always be freed when the entire process is complete, it is an error otherwise. π§
free_mntarg()β used to free or clear themntargstructure. π§Ήkernel_mount()β pulls information from the structure to perform the mount request on a given file system. Additionally, thekernel_mount()function always calls thefree_mntarg()function. Ifmacontains any error code generated during the construction, that code will be called and the file system mount will not be attempted. π«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. This argument will be referenced until eitherfree_mntarg()orkernel_mount()is called. πmount_argb()β used to add boolean arguments to the structure. Theflagis the boolean value andnamemust start with"no", otherwise a panic will occur. π±mount_argf()β addsprintf(9)style arguments to the current structure. π¨οΈmount_argsu()β will add arguments to the structure from a userland string. π
β οΈ fr fr:mount_argb()is not playing around β ifnamedoes not start with"no", a panic will occur. that's not a vibe, it's a rule. π
π EXAMPLES π
An example of the *_cmount() function:
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);
}
π SEE ALSO π
β HISTORY β
The kernel_mount() family of functions and this manual page first appeared in FreeBSD 6.0.
π AUTHORS π
The kernel_mount() family of functions and API was developed by Poul-Henning Kamp <phk@FreeBSD.org>. This manual page was written by Tom Rhodes <trhodes@FreeBSD.org>.
xoxo, your Debian girly π β this KERNEL_MOUNT(9) page is dated November 20, 2021, and we are signing off. πβ¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2004 Tom Rhodes
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms