1610b07d6STom Rhodes.\" 2610b07d6STom Rhodes.\" Copyright (c) 2004 Tom Rhodes 3610b07d6STom Rhodes.\" All rights reserved. 4610b07d6STom Rhodes.\" 5610b07d6STom Rhodes.\" Redistribution and use in source and binary forms, with or without 6610b07d6STom Rhodes.\" modification, are permitted provided that the following conditions 7610b07d6STom Rhodes.\" are met: 8610b07d6STom Rhodes.\" 1. Redistributions of source code must retain the above copyright 9610b07d6STom Rhodes.\" notice, this list of conditions and the following disclaimer. 10610b07d6STom Rhodes.\" 2. Redistributions in binary form must reproduce the above copyright 11610b07d6STom Rhodes.\" notice, this list of conditions and the following disclaimer in the 12610b07d6STom Rhodes.\" documentation and/or other materials provided with the distribution. 13610b07d6STom Rhodes.\" 14610b07d6STom Rhodes.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15610b07d6STom Rhodes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16610b07d6STom Rhodes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17610b07d6STom Rhodes.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18610b07d6STom Rhodes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19610b07d6STom Rhodes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20610b07d6STom Rhodes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21610b07d6STom Rhodes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22610b07d6STom Rhodes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23610b07d6STom Rhodes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24610b07d6STom Rhodes.\" SUCH DAMAGE. 25610b07d6STom Rhodes.\" 26*8981a100SRobert Wing.Dd November 20, 2021 27610b07d6STom Rhodes.Dt KERNEL_MOUNT 9 28610b07d6STom Rhodes.Os 29610b07d6STom Rhodes.Sh NAME 3028656723STom Rhodes.Nm free_mntarg , 3128656723STom Rhodes.Nm kernel_mount , 3228656723STom Rhodes.Nm mount_arg , 3328656723STom Rhodes.Nm mount_argb , 3428656723STom Rhodes.Nm mount_argf , 35610b07d6STom Rhodes.Nm mount_argsu 3628656723STom Rhodes.Nd "functions provided as part of the kernel mount interface" 37610b07d6STom Rhodes.Sh SYNOPSIS 38610b07d6STom Rhodes.Ft void 39610b07d6STom Rhodes.Fn free_mntarg "struct mntarg *ma" 40610b07d6STom Rhodes.Ft int 4128656723STom Rhodes.Fn kernel_mount "struct mntarg *ma" "int flags" 4228656723STom Rhodes.Ft "struct mntarg *" 4328656723STom Rhodes.Fo mount_arg 4428656723STom Rhodes.Fa "struct mntarg *ma" "const char *name" "const void *val" "int len" 4528656723STom Rhodes.Fc 4628656723STom Rhodes.Ft "struct mntarg *" 4728656723STom Rhodes.Fn mount_argb "struct mntarg *ma" "int flag" "const char *name" 4828656723STom Rhodes.Ft "struct mntarg *" 4928656723STom Rhodes.Fn mount_argf "struct mntarg *ma" "const char *name" "const char *fmt" ... 5028656723STom Rhodes.Ft "struct mntarg *" 5128656723STom Rhodes.Fo mount_argsu 5228656723STom Rhodes.Fa "struct mntarg *ma" "const char *name" "const void *val" "int len" 5328656723STom Rhodes.Fc 54610b07d6STom Rhodes.Sh DESCRIPTION 55610b07d6STom RhodesThe 5628656723STom Rhodes.Fn kernel_mount 57610b07d6STom Rhodesfamily of functions are provided as an API for building a list 58610b07d6STom Rhodesof mount arguments which will be used to mount file systems 59610b07d6STom Rhodesfrom inside the kernel. 60610b07d6STom RhodesBy accumulating a list of arguments, the API takes shape and 61610b07d6STom Rhodesprovides the information necessary for the kernel to control 62610b07d6STom Rhodesthe 63610b07d6STom Rhodes.Xr mount 8 64610b07d6STom Rhodesutility. 6528656723STom RhodesWhen an error occurs, the process will stop. 66610b07d6STom RhodesThis will not cause a 67610b07d6STom Rhodes.Xr panic 9 . 68610b07d6STom Rhodes.Pp 69610b07d6STom RhodesThe header of the structure is stored in 70610b07d6STom Rhodes.Pa src/sys/kern/vfs_mount.c 71610b07d6STom Rhodeswhich permits automatic structure creation to 72610b07d6STom Rhodesease the mount process. 73610b07d6STom RhodesMemory allocation must always be freed when the entire 74610b07d6STom Rhodesprocess is complete, it is an error otherwise. 75610b07d6STom Rhodes.Pp 76610b07d6STom RhodesThe 77610b07d6STom Rhodes.Fn free_mntarg 78610b07d6STom Rhodesfunction is used to free or clear the 7928656723STom Rhodes.Vt mntarg 80610b07d6STom Rhodesstructure. 81610b07d6STom Rhodes.Pp 82610b07d6STom RhodesThe 83610b07d6STom Rhodes.Fn kernel_mount 84610b07d6STom Rhodesfunction pulls information from the structure to perform 85610b07d6STom Rhodesthe mount request on a given file system. 86610b07d6STom RhodesAdditionally, the 87610b07d6STom Rhodes.Fn kernel_mount 88610b07d6STom Rhodesfunction always calls the 89610b07d6STom Rhodes.Fn free_mntarg 90610b07d6STom Rhodesfunction. 91610b07d6STom RhodesIf 92610b07d6STom Rhodes.Fa ma 93610b07d6STom Rhodescontains any error code generated during the construction, 94610b07d6STom Rhodesthat code will be called and the file system mount will 95610b07d6STom Rhodesnot be attempted. 96610b07d6STom Rhodes.Pp 97610b07d6STom RhodesThe 98610b07d6STom Rhodes.Fn mount_arg 99610b07d6STom Rhodesfunction takes a plain argument and crafts parts of 100610b07d6STom Rhodesthe structure with regards to various mount options. 10128656723STom RhodesIf the length is a value less than 0, 102610b07d6STom Rhodes.Xr strlen 3 103610b07d6STom Rhodesis used. 104610b07d6STom RhodesThis argument will be referenced until either 105610b07d6STom Rhodes.Fn free_mntarg 106610b07d6STom Rhodesor 107610b07d6STom Rhodes.Fn kernel_mount 108610b07d6STom Rhodesis called. 109610b07d6STom Rhodes.Pp 110610b07d6STom RhodesThe 111610b07d6STom Rhodes.Fn mount_argb 11228656723STom Rhodesfunction is used to add boolean arguments to 113610b07d6STom Rhodesthe structure. 114610b07d6STom RhodesThe 115610b07d6STom Rhodes.Fa flag 11628656723STom Rhodesis the boolean value and 117610b07d6STom Rhodes.Fa name 118610b07d6STom Rhodesmust start with 11928656723STom Rhodes.Qq Li no , 120610b07d6STom Rhodesotherwise a panic will occur. 121610b07d6STom Rhodes.Pp 122610b07d6STom RhodesThe 123610b07d6STom Rhodes.Fn mount_argf 124610b07d6STom Rhodesfunction adds 125610b07d6STom Rhodes.Xr printf 9 126610b07d6STom Rhodesstyle arguments to the current structure. 127610b07d6STom Rhodes.Pp 128610b07d6STom RhodesThe 129610b07d6STom Rhodes.Fn mount_argsu 130610b07d6STom Rhodesfunction will add arguments to the structure from a 131610b07d6STom Rhodesuserland string. 132610b07d6STom Rhodes.Sh EXAMPLES 133610b07d6STom RhodesAn example of the 134610b07d6STom Rhodes.Fn *_cmount 135610b07d6STom Rhodesfunction: 136610b07d6STom Rhodes.Bd -literal 137610b07d6STom Rhodesstatic int 138610b07d6STom Rhodesmsdosfs_cmount(struct mntarg *ma, void *data, int flags, struct thread *td) 139610b07d6STom Rhodes{ 140610b07d6STom Rhodes struct msdosfs_args args; 141610b07d6STom Rhodes int error; 142610b07d6STom Rhodes 143610b07d6STom Rhodes if (data == NULL) 144610b07d6STom Rhodes return (EINVAL); 145d14fdb79SKevin Lo error = copyin(data, &args, sizeof(args)); 146610b07d6STom Rhodes if (error) 147610b07d6STom Rhodes return (error); 148610b07d6STom Rhodes 149610b07d6STom Rhodes ma = mount_argsu(ma, "from", args.fspec, MAXPATHLEN); 150d14fdb79SKevin Lo ma = mount_arg(ma, "export", &args.export, sizeof(args.export)); 151610b07d6STom Rhodes ma = mount_argf(ma, "uid", "%d", args.uid); 152610b07d6STom Rhodes ma = mount_argf(ma, "gid", "%d", args.gid); 153610b07d6STom Rhodes ma = mount_argf(ma, "mask", "%d", args.mask); 154610b07d6STom Rhodes ma = mount_argf(ma, "dirmask", "%d", args.dirmask); 155610b07d6STom Rhodes 156610b07d6STom Rhodes ma = mount_argb(ma, args.flags & MSDOSFSMNT_SHORTNAME, "noshortname"); 157610b07d6STom Rhodes ma = mount_argb(ma, args.flags & MSDOSFSMNT_LONGNAME, "nolongname"); 158610b07d6STom Rhodes ma = mount_argb(ma, !(args.flags & MSDOSFSMNT_NOWIN95), "nowin95"); 159610b07d6STom Rhodes ma = mount_argb(ma, args.flags & MSDOSFSMNT_KICONV, "nokiconv"); 160610b07d6STom Rhodes 161610b07d6STom Rhodes ma = mount_argsu(ma, "cs_win", args.cs_win, MAXCSLEN); 162610b07d6STom Rhodes ma = mount_argsu(ma, "cs_dos", args.cs_dos, MAXCSLEN); 163610b07d6STom Rhodes ma = mount_argsu(ma, "cs_local", args.cs_local, MAXCSLEN); 164610b07d6STom Rhodes 165610b07d6STom Rhodes error = kernel_mount(ma, flags); 166610b07d6STom Rhodes 167610b07d6STom Rhodes return (error); 168610b07d6STom Rhodes} 169610b07d6STom Rhodes.Ed 170610b07d6STom Rhodes.Sh SEE ALSO 171610b07d6STom Rhodes.Xr VFS 9 , 17227c095f4SGlen Barber.Xr VFS_MOUNT 9 173610b07d6STom Rhodes.Sh HISTORY 174610b07d6STom RhodesThe 175610b07d6STom Rhodes.Fn kernel_mount 176610b07d6STom Rhodesfamily of functions and this manual page first 177610b07d6STom Rhodesappeared in 178610b07d6STom Rhodes.Fx 6.0 . 179610b07d6STom Rhodes.Sh AUTHORS 18028656723STom Rhodes.An -nosplit 181610b07d6STom RhodesThe 182610b07d6STom Rhodes.Fn kernel_mount 18328656723STom Rhodesfamily of functions and API was developed by 1848a7314fcSBaptiste Daroussin.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org . 185610b07d6STom RhodesThis manual page was written by 1868a7314fcSBaptiste Daroussin.An Tom Rhodes Aq Mt trhodes@FreeBSD.org . 187