1 .\" $NetBSD: modctl.2,v 1.8 2010/12/14 16:23:59 jruoho Exp $
3 .\" Copyright (c) 2009 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 .\" POSSIBILITY OF SUCH DAMAGE.
38 .Fn modctl "int operation" "void *argp"
41 provides control over loaded kernel modules.
56 .Bl -tag -width MODCTL_UNLOAD
61 argument should be a pointer to a
63 structure, described below.
68 should be a string containing the name of the module to be unloaded.
70 Return a list of loaded modules.
75 pointing to a suitable block of memory.
76 The kernel will fill this block with an array of
78 structures, one per loaded module.
79 If the block is not large enough, the data returned will be truncated
81 The kernel will then update the
85 to reflect the size of the complete report, regardless of whether this
86 is larger or smaller than the size passed in.
93 contains the following elements, which should be filled in by the caller:
94 .Bl -tag -width aaaaaaaa
95 .It Fa "const char *ml_filename"
96 The name/path of the module to load.
98 Zero or more of the following flag values:
99 .Bl -tag -compact -width "MODCTL_LOAD_FORCE"
100 .It Dv MODCTL_NO_PROP
101 Don't load \*[Lt]module\*[Gt].plist.
102 .It Dv MODCTL_LOAD_FORCE
103 Ignore kernel version mismatch.
105 .It Fa "const char *ml_props"
106 Externalized proplib dictionary to pass to module.
107 .It Fa "size_t ml_propslen"
108 Size of the dictionary blob.
122 contains the following elements, which are filled in by the kernel:
123 .Bl -tag -width aaaaaaaa
124 .It Fa "char ms_name[MAXMODNAME]"
125 The name of the module.
126 .It Fa "char ms_required[MAXMODNAME * MAXMODDEPS]"
127 The list of modules required by this module
128 as a comma-delimited list of module names.
129 .It Fa "modsrc_t ms_source"
130 One of the following enumerated constants:
131 .Bl -tag -compact -width "MODULE_SOURCE_FILESYS"
132 .It Dv MODULE_SOURCE_KERNEL
133 The module is compiled into the kernel.
134 .It Dv MODULE_SOURCE_BOOT
135 The module was provided by the bootstrap loader.
136 .It Dv MODULE_SOURCE_FILESYS
137 The module was loaded from the file system.
139 .It Fa "modclass_t ms_class"
140 One of the following enumerated constants:
141 .Bl -tag -compact -width "MODULE_SOURCE_FILESYS"
142 .It Dv MODULE_CLASS_SECMODEL
144 .It Dv MODULE_CLASS_VFS
146 .It Dv MODULE_CLASS_DRIVER
148 .It Dv MODULE_CLASS_EXEC
149 Executable file format.
150 .It Dv MODULE_CLASS_MISC
152 .It Dv MODULE_CLASS_ANY
154 .\" XXX: is MODULE_CLASS_ANY ever returned by this interface?
156 .It Fa "uint64_t ms_addr"
157 The load address within the kernel.
158 .It Fa "u_int ms_size"
159 Loaded size of the module.
160 .It Fa "u_int ms_refcnt"
161 Current number of live references to this module.
164 Upon successful completion, the value returned is 0.
166 Otherwise, a value of \-1 is returned and
168 is set to indicate the error.
178 and the module is in use or the module is compiled into the kernel.
184 and there is a circular dependency in the module's dependency chain.
190 and the module is already loaded.
192 A bad address was given for
199 the specified module resides in the file system, and the module's default
200 proplib file was too large.
223 The kernel is unable to internalize the plist.
224 Or, there is a problem with the module or \*[Lt]module\*[Gt].plist.
230 and the module has too many dependencies.
231 .It Bq Er ENAMETOOLONG
232 A module name/path is too long.
238 and the module or a dependency can't be found.
243 and no module by the name of
251 and the module is not a valid object for the system.
253 There was not enough memory to perform the
256 Not allowed to perform the
258 .It Bq Er EPROGMISMATCH
267 structure does not include
268 .Dv MODCTL_LOAD_FORCE ,
269 and the requested module does not match the current kernel's version
278 function call first appeared in