kernel_mount.9 (610b07d6a3c120483032a0792fb9158bfdd7c3d9) kernel_mount.9 (2865672368f1e6e24720431e23600a2ea1f3af9d)
1.\"
2.\" Copyright (c) 2004 Tom Rhodes
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright

--- 15 unchanged lines hidden (view full) ---

24.\" SUCH DAMAGE.
25.\"
26.\" $FreeBSD$
27.\"
28.Dd December 13, 2004
29.Dt KERNEL_MOUNT 9
30.Os
31.Sh NAME
1.\"
2.\" Copyright (c) 2004 Tom Rhodes
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright

--- 15 unchanged lines hidden (view full) ---

24.\" SUCH DAMAGE.
25.\"
26.\" $FreeBSD$
27.\"
28.Dd December 13, 2004
29.Dt KERNEL_MOUNT 9
30.Os
31.Sh NAME
32.Nm free_mntarg
33.Nm kernel_mount
34.Nm kernel_vmount
35.Nm mount_argb
36.Nm mount_argf
32.Nm free_mntarg ,
33.Nm kernel_mount ,
34.Nm kernel_vmount ,
35.Nm mount_arg ,
36.Nm mount_argb ,
37.Nm mount_argf ,
37.Nm mount_argsu
38.Nm mount_argsu
38.Nm mount_arg
39.Nd Functions provided as part of the kernel mount interface
39.Nd "functions provided as part of the kernel mount interface"
40.Sh SYNOPSIS
41.Ft void
42.Fn free_mntarg "struct mntarg *ma"
43.Ft int
40.Sh SYNOPSIS
41.Ft void
42.Fn free_mntarg "struct mntarg *ma"
43.Ft int
44.Fn kernel_mount "struct mntarg *ma, int flags"
44.Fn kernel_mount "struct mntarg *ma" "int flags"
45.Ft int
45.Ft int
46.Fn kernel_vmount "int flags, ..."
47.Ft struct mntarg *
48.Fn mount_arg "struct mntarg *ma, const char *name, const void *val, int len"
49.Ft struct mntarg *
50.Fn mount_argb "struct mntarg *ma, int flag, const char *name"
51.Ft struct mntarg *
52.Fn mount_argf "struct mntarg *ma, const char *name, const char *fmt, ..."
53.Ft struct mntarg *
54.Fn mount_argsu "struct mntarg *ma, const char *name, const void *val, int len"
46.Fn kernel_vmount "int flags" ...
47.Ft "struct mntarg *"
48.Fo mount_arg
49.Fa "struct mntarg *ma" "const char *name" "const void *val" "int len"
50.Fc
51.Ft "struct mntarg *"
52.Fn mount_argb "struct mntarg *ma" "int flag" "const char *name"
53.Ft "struct mntarg *"
54.Fn mount_argf "struct mntarg *ma" "const char *name" "const char *fmt" ...
55.Ft "struct mntarg *"
56.Fo mount_argsu
57.Fa "struct mntarg *ma" "const char *name" "const void *val" "int len"
58.Fc
55.Sh DESCRIPTION
56The
59.Sh DESCRIPTION
60The
57.Xr kernel_mount 9
61.Fn kernel_mount
58family of functions are provided as an API for building a list
59of mount arguments which will be used to mount file systems
60from inside the kernel.
61By accumulating a list of arguments, the API takes shape and
62provides the information necessary for the kernel to control
63the
64.Xr mount 8
65utility.
62family of functions are provided as an API for building a list
63of mount arguments which will be used to mount file systems
64from inside the kernel.
65By accumulating a list of arguments, the API takes shape and
66provides the information necessary for the kernel to control
67the
68.Xr mount 8
69utility.
66When an error occurs the process will stop.
70When an error occurs, the process will stop.
67This will not cause a
68.Xr panic 9 .
69.Pp
70The header of the structure is stored in
71.Pa src/sys/kern/vfs_mount.c
72which permits automatic structure creation to
73ease the mount process.
74Memory allocation must always be freed when the entire
75process is complete, it is an error otherwise.
76.Pp
77The
78.Fn free_mntarg
79function is used to free or clear the
71This will not cause a
72.Xr panic 9 .
73.Pp
74The header of the structure is stored in
75.Pa src/sys/kern/vfs_mount.c
76which permits automatic structure creation to
77ease the mount process.
78Memory allocation must always be freed when the entire
79process is complete, it is an error otherwise.
80.Pp
81The
82.Fn free_mntarg
83function is used to free or clear the
80.Ft mntarg
84.Vt mntarg
81structure.
82.Pp
83The
84.Fn kernel_mount
85function pulls information from the structure to perform
86the mount request on a given file system.
87Additionally, the
88.Fn kernel_mount

--- 11 unchanged lines hidden (view full) ---

100is a function similar to
101.Xr printf 9
102which is used to mount a file system.
103.Pp
104The
105.Fn mount_arg
106function takes a plain argument and crafts parts of
107the structure with regards to various mount options.
85structure.
86.Pp
87The
88.Fn kernel_mount
89function pulls information from the structure to perform
90the mount request on a given file system.
91Additionally, the
92.Fn kernel_mount

--- 11 unchanged lines hidden (view full) ---

104is a function similar to
105.Xr printf 9
106which is used to mount a file system.
107.Pp
108The
109.Fn mount_arg
110function takes a plain argument and crafts parts of
111the structure with regards to various mount options.
108If the length is a value fewer than 0,
112If the length is a value less than 0,
109.Xr strlen 3
110is used.
111This argument will be referenced until either
112.Fn free_mntarg
113or
114.Fn kernel_mount
115is called.
116.Pp
117The
118.Fn mount_argb
113.Xr strlen 3
114is used.
115This argument will be referenced until either
116.Fn free_mntarg
117or
118.Fn kernel_mount
119is called.
120.Pp
121The
122.Fn mount_argb
119function is used to add Boolean arguments to
123function is used to add boolean arguments to
120the structure.
121The
122.Fa flag
124the structure.
125The
126.Fa flag
123is the Boolean value and
127is the boolean value and
124.Fa name
125must start with
128.Fa name
129must start with
126.Em no ,
130.Qq Li no ,
127otherwise a panic will occur.
128.Pp
129The
130.Fn mount_argf
131function adds
132.Xr printf 9
133style arguments to the current structure.
134.Pp
135The
136.Fn mount_argsu
137function will add arguments to the structure from a
138userland string.
131otherwise a panic will occur.
132.Pp
133The
134.Fn mount_argf
135function adds
136.Xr printf 9
137style arguments to the current structure.
138.Pp
139The
140.Fn mount_argsu
141function will add arguments to the structure from a
142userland string.
139.Pp
140.Sh EXAMPLES
141An example of the
142.Fn *_cmount
143function:
144.Bd -literal
145static int
146msdosfs_cmount(struct mntarg *ma, void *data, int flags, struct thread *td)
147{
143.Sh EXAMPLES
144An example of the
145.Fn *_cmount
146function:
147.Bd -literal
148static int
149msdosfs_cmount(struct mntarg *ma, void *data, int flags, struct thread *td)
150{
148 struct msdosfs_args args;
149 int error;
151 struct msdosfs_args args;
152 int error;
150
153
151 if (data == NULL)
152 return (EINVAL);
153 error = copyin(data, &args, sizeof args);
154 if (error)
155 return (error);
154 if (data == NULL)
155 return (EINVAL);
156 error = copyin(data, &args, sizeof args);
157 if (error)
158 return (error);
156
159
157 ma = mount_argsu(ma, "from", args.fspec, MAXPATHLEN);
158 ma = mount_arg(ma, "export", &args.export, sizeof args.export);
159 ma = mount_argf(ma, "uid", "%d", args.uid);
160 ma = mount_argf(ma, "gid", "%d", args.gid);
161 ma = mount_argf(ma, "mask", "%d", args.mask);
162 ma = mount_argf(ma, "dirmask", "%d", args.dirmask);
160 ma = mount_argsu(ma, "from", args.fspec, MAXPATHLEN);
161 ma = mount_arg(ma, "export", &args.export, sizeof args.export);
162 ma = mount_argf(ma, "uid", "%d", args.uid);
163 ma = mount_argf(ma, "gid", "%d", args.gid);
164 ma = mount_argf(ma, "mask", "%d", args.mask);
165 ma = mount_argf(ma, "dirmask", "%d", args.dirmask);
163
166
164 ma = mount_argb(ma, args.flags & MSDOSFSMNT_SHORTNAME, "noshortname");
165 ma = mount_argb(ma, args.flags & MSDOSFSMNT_LONGNAME, "nolongname");
166 ma = mount_argb(ma, !(args.flags & MSDOSFSMNT_NOWIN95), "nowin95");
167 ma = mount_argb(ma, args.flags & MSDOSFSMNT_KICONV, "nokiconv");
167 ma = mount_argb(ma, args.flags & MSDOSFSMNT_SHORTNAME, "noshortname");
168 ma = mount_argb(ma, args.flags & MSDOSFSMNT_LONGNAME, "nolongname");
169 ma = mount_argb(ma, !(args.flags & MSDOSFSMNT_NOWIN95), "nowin95");
170 ma = mount_argb(ma, args.flags & MSDOSFSMNT_KICONV, "nokiconv");
168
171
169 ma = mount_argsu(ma, "cs_win", args.cs_win, MAXCSLEN);
170 ma = mount_argsu(ma, "cs_dos", args.cs_dos, MAXCSLEN);
171 ma = mount_argsu(ma, "cs_local", args.cs_local, MAXCSLEN);
172 ma = mount_argsu(ma, "cs_win", args.cs_win, MAXCSLEN);
173 ma = mount_argsu(ma, "cs_dos", args.cs_dos, MAXCSLEN);
174 ma = mount_argsu(ma, "cs_local", args.cs_local, MAXCSLEN);
172
175
173 error = kernel_mount(ma, flags);
176 error = kernel_mount(ma, flags);
174
177
175 return (error);
178 return (error);
176}
177.Ed
178.Pp
179When working with
180.Fn kernel_vmount ,
179}
180.Ed
181.Pp
182When working with
183.Fn kernel_vmount ,
181.Ft varargs
182must come in pairs, e.g.
183.Brq Em name , Em value .
184.Fa varargs
185must come in pairs, e.g.,
186.Brq Va name , value .
184.Bd -literal
187.Bd -literal
185 error = kernel_vmount(
186 MNT_RDONLY,
187 "fstype", vfsname,
188 "fspath", "/",
189 "from", path,
190 NULL);
188 error = kernel_vmount(
189 MNT_RDONLY,
190 "fstype", vfsname,
191 "fspath", "/",
192 "from", path,
193 NULL);
191.Ed
192.Sh SEE ALSO
193.Xr VFS 9 ,
194.Xr VFS_MOUNT 9 ,
195.Xr vfs_mount 9
196.Sh HISTORY
197The
198.Fn kernel_mount
199family of functions and this manual page first
200appeared in
201.Fx 6.0 .
202.Sh AUTHORS
194.Ed
195.Sh SEE ALSO
196.Xr VFS 9 ,
197.Xr VFS_MOUNT 9 ,
198.Xr vfs_mount 9
199.Sh HISTORY
200The
201.Fn kernel_mount
202family of functions and this manual page first
203appeared in
204.Fx 6.0 .
205.Sh AUTHORS
206.An -nosplit
203The
204.Fn kernel_mount
207The
208.Fn kernel_mount
205family functions and API was developed by
209family of functions and API was developed by
206.An Poul-Henning Kamp Aq phk@FreeBSD.org .
207This manual page was written by
208.An Tom Rhodes Aq trhodes@FreeBSD.org .
210.An Poul-Henning Kamp Aq phk@FreeBSD.org .
211This manual page was written by
212.An Tom Rhodes Aq trhodes@FreeBSD.org .