2004-12-13 19:25:30 +00:00
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 2004 Tom Rhodes
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" $FreeBSD$
|
|
|
|
.\"
|
2021-11-20 19:22:28 +00:00
|
|
|
.Dd November 20, 2021
|
2004-12-13 19:25:30 +00:00
|
|
|
.Dt KERNEL_MOUNT 9
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
2004-12-14 18:07:46 +00:00
|
|
|
.Nm free_mntarg ,
|
|
|
|
.Nm kernel_mount ,
|
|
|
|
.Nm mount_arg ,
|
|
|
|
.Nm mount_argb ,
|
|
|
|
.Nm mount_argf ,
|
2004-12-13 19:25:30 +00:00
|
|
|
.Nm mount_argsu
|
2004-12-14 18:07:46 +00:00
|
|
|
.Nd "functions provided as part of the kernel mount interface"
|
2004-12-13 19:25:30 +00:00
|
|
|
.Sh SYNOPSIS
|
|
|
|
.Ft void
|
|
|
|
.Fn free_mntarg "struct mntarg *ma"
|
|
|
|
.Ft int
|
2004-12-14 18:07:46 +00:00
|
|
|
.Fn kernel_mount "struct mntarg *ma" "int flags"
|
|
|
|
.Ft "struct mntarg *"
|
|
|
|
.Fo mount_arg
|
|
|
|
.Fa "struct mntarg *ma" "const char *name" "const void *val" "int len"
|
|
|
|
.Fc
|
|
|
|
.Ft "struct mntarg *"
|
|
|
|
.Fn mount_argb "struct mntarg *ma" "int flag" "const char *name"
|
|
|
|
.Ft "struct mntarg *"
|
|
|
|
.Fn mount_argf "struct mntarg *ma" "const char *name" "const char *fmt" ...
|
|
|
|
.Ft "struct mntarg *"
|
|
|
|
.Fo mount_argsu
|
|
|
|
.Fa "struct mntarg *ma" "const char *name" "const void *val" "int len"
|
|
|
|
.Fc
|
2004-12-13 19:25:30 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
2004-12-14 18:07:46 +00:00
|
|
|
.Fn kernel_mount
|
2004-12-13 19:25:30 +00:00
|
|
|
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
|
|
|
|
.Xr mount 8
|
|
|
|
utility.
|
2004-12-14 18:07:46 +00:00
|
|
|
When an error occurs, the process will stop.
|
2004-12-13 19:25:30 +00:00
|
|
|
This will not cause a
|
|
|
|
.Xr panic 9 .
|
|
|
|
.Pp
|
|
|
|
The header of the structure is stored in
|
|
|
|
.Pa 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.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn free_mntarg
|
|
|
|
function is used to free or clear the
|
2004-12-14 18:07:46 +00:00
|
|
|
.Vt mntarg
|
2004-12-13 19:25:30 +00:00
|
|
|
structure.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn kernel_mount
|
|
|
|
function pulls information from the structure to perform
|
|
|
|
the mount request on a given file system.
|
|
|
|
Additionally, the
|
|
|
|
.Fn kernel_mount
|
|
|
|
function always calls the
|
|
|
|
.Fn free_mntarg
|
|
|
|
function.
|
|
|
|
If
|
|
|
|
.Fa ma
|
|
|
|
contains any error code generated during the construction,
|
|
|
|
that code will be called and the file system mount will
|
|
|
|
not be attempted.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn mount_arg
|
|
|
|
function takes a plain argument and crafts parts of
|
|
|
|
the structure with regards to various mount options.
|
2004-12-14 18:07:46 +00:00
|
|
|
If the length is a value less than 0,
|
2004-12-13 19:25:30 +00:00
|
|
|
.Xr strlen 3
|
|
|
|
is used.
|
|
|
|
This argument will be referenced until either
|
|
|
|
.Fn free_mntarg
|
|
|
|
or
|
|
|
|
.Fn kernel_mount
|
|
|
|
is called.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn mount_argb
|
2004-12-14 18:07:46 +00:00
|
|
|
function is used to add boolean arguments to
|
2004-12-13 19:25:30 +00:00
|
|
|
the structure.
|
|
|
|
The
|
|
|
|
.Fa flag
|
2004-12-14 18:07:46 +00:00
|
|
|
is the boolean value and
|
2004-12-13 19:25:30 +00:00
|
|
|
.Fa name
|
|
|
|
must start with
|
2004-12-14 18:07:46 +00:00
|
|
|
.Qq Li no ,
|
2004-12-13 19:25:30 +00:00
|
|
|
otherwise a panic will occur.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn mount_argf
|
|
|
|
function adds
|
|
|
|
.Xr printf 9
|
|
|
|
style arguments to the current structure.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn mount_argsu
|
|
|
|
function will add arguments to the structure from a
|
|
|
|
userland string.
|
|
|
|
.Sh EXAMPLES
|
|
|
|
An example of the
|
|
|
|
.Fn *_cmount
|
|
|
|
function:
|
|
|
|
.Bd -literal
|
|
|
|
static int
|
|
|
|
msdosfs_cmount(struct mntarg *ma, void *data, int flags, struct thread *td)
|
|
|
|
{
|
2004-12-14 18:07:46 +00:00
|
|
|
struct msdosfs_args args;
|
|
|
|
int error;
|
2004-12-13 19:25:30 +00:00
|
|
|
|
2004-12-14 18:07:46 +00:00
|
|
|
if (data == NULL)
|
|
|
|
return (EINVAL);
|
2012-07-17 02:05:39 +00:00
|
|
|
error = copyin(data, &args, sizeof(args));
|
2004-12-14 18:07:46 +00:00
|
|
|
if (error)
|
|
|
|
return (error);
|
2004-12-13 19:25:30 +00:00
|
|
|
|
2004-12-14 18:07:46 +00:00
|
|
|
ma = mount_argsu(ma, "from", args.fspec, MAXPATHLEN);
|
2012-07-17 02:05:39 +00:00
|
|
|
ma = mount_arg(ma, "export", &args.export, sizeof(args.export));
|
2004-12-14 18:07:46 +00:00
|
|
|
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);
|
2004-12-13 19:25:30 +00:00
|
|
|
|
2004-12-14 18:07:46 +00:00
|
|
|
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");
|
2004-12-13 19:25:30 +00:00
|
|
|
|
2004-12-14 18:07:46 +00:00
|
|
|
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);
|
2004-12-13 19:25:30 +00:00
|
|
|
|
2004-12-14 18:07:46 +00:00
|
|
|
error = kernel_mount(ma, flags);
|
2004-12-13 19:25:30 +00:00
|
|
|
|
2004-12-14 18:07:46 +00:00
|
|
|
return (error);
|
2004-12-13 19:25:30 +00:00
|
|
|
}
|
|
|
|
.Ed
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr VFS 9 ,
|
2014-07-30 04:48:56 +00:00
|
|
|
.Xr VFS_MOUNT 9
|
2004-12-13 19:25:30 +00:00
|
|
|
.Sh HISTORY
|
|
|
|
The
|
|
|
|
.Fn kernel_mount
|
|
|
|
family of functions and this manual page first
|
|
|
|
appeared in
|
|
|
|
.Fx 6.0 .
|
|
|
|
.Sh AUTHORS
|
2004-12-14 18:07:46 +00:00
|
|
|
.An -nosplit
|
2004-12-13 19:25:30 +00:00
|
|
|
The
|
|
|
|
.Fn kernel_mount
|
2004-12-14 18:07:46 +00:00
|
|
|
family of functions and API was developed by
|
2014-06-26 21:44:30 +00:00
|
|
|
.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org .
|
2004-12-13 19:25:30 +00:00
|
|
|
This manual page was written by
|
2014-06-26 21:44:30 +00:00
|
|
|
.An Tom Rhodes Aq Mt trhodes@FreeBSD.org .
|