---
name: "mount_argsu"
section: "9"
platform: "linux"
package: "freebsd-manpages"
version: "6.0-5"
release: "Debian 4.0 (Etch)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/mount_argsu"
---

# mount\_argsu(9)

functions provided as part of the kernel mount interface

## 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

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)](/mount/8.md) utility. When an error occurs, the process will stop. This will not cause a [panic(9)](/panic/9.md).

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.

The **free\_mntarg**() function is used to free or clear the *mntarg* structure.

The **kernel\_mount**() function pulls information from the structure to perform the mount request on a given file system. Additionally, the **kernel\_mount**() function always calls the **free\_mntarg**() function. If *ma* contains any error code generated during the construction, that code will be called and the file system mount will not be attempted.

The **kernel\_vmount**() is a function similar to [printf(9)](/printf/9.md) which is used to mount a file system.

The **mount\_arg**() function takes a plain argument and crafts parts of the structure with regards to various mount options. If the length is a value less than 0, [strlen(3)](/strlen/3.md) is used. This argument will be referenced until either **free\_mntarg**() or **kernel\_mount**() is called.

The **mount\_argb**() function is used to add boolean arguments to the structure. The *flag* is the boolean value and *name* must start with "no", otherwise a panic will occur.

The **mount\_argf**() function adds [printf(9)](/printf/9.md) style arguments to the current structure.

The **mount\_argsu**() function will add arguments to the structure from a userland string.

## 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);
}
```

When working with **kernel\_vmount**(), *varargs* must come in pairs, e.g., {*name*, *value*}.

```
	error = kernel_vmount(
	    MNT_RDONLY,
	    "fstype", vfsname,
	    "fspath", "/",
	    "from", path,
	    NULL);
```

## SEE ALSO

[VFS(9)](/VFS/9.md), [VFS\_MOUNT(9)](/VFS_MOUNT/9.md), [vfs\_mount(9)](/vfs_mount/9.md)

## 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⟩.
