1 .\" $NetBSD: modctl.2,v 1.9 2012/08/07 01:19:05 jnemeth 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.
57 .Bl -tag -width MODCTL_UNLOAD
62 argument should be a pointer to a
64 structure, described below.
69 should be a string containing the name of the module to be unloaded.
71 Return a list of loaded modules.
76 pointing to a suitable block of memory.
77 The kernel will fill this block with an array of
79 structures, one per loaded module.
80 If the block is not large enough, the data returned will be truncated
82 The kernel will then update the
86 to reflect the size of the complete report, regardless of whether this
87 is larger or smaller than the size passed in.
89 Test to see if the kernel was compiled with
92 not modules may be loaded at the moment.
98 to test if a user can load a module via
102 to test if the system can autoload modules.
104 test does not consider the sysctl
105 .Li kern.module.autoload .
112 contains the following elements, which should be filled in by the caller:
113 .Bl -tag -width aaaaaaaa
114 .It Fa "const char *ml_filename"
115 The name/path of the module to load.
116 .It Fa "int ml_flags"
117 Zero or more of the following flag values:
118 .Bl -tag -compact -width "MODCTL_LOAD_FORCE"
119 .It Dv MODCTL_NO_PROP
121 .Ao module Ac Ns Pa .plist .
122 .It Dv MODCTL_LOAD_FORCE
123 Ignore kernel version mismatch.
125 .It Fa "const char *ml_props"
126 Externalized proplib dictionary to pass to module.
127 .It Fa "size_t ml_propslen"
128 Size of the dictionary blob.
142 contains the following elements, which are filled in by the kernel:
143 .Bl -tag -width aaaaaaaa
144 .It Fa "char ms_name[MAXMODNAME]"
145 The name of the module.
146 .It Fa "char ms_required[MAXMODNAME * MAXMODDEPS]"
147 The list of modules required by this module
148 as a comma-delimited list of module names.
149 .It Fa "modsrc_t ms_source"
150 One of the following enumerated constants:
151 .Bl -tag -compact -width "MODULE_SOURCE_FILESYS"
152 .It Dv MODULE_SOURCE_KERNEL
153 The module is compiled into the kernel.
154 .It Dv MODULE_SOURCE_BOOT
155 The module was provided by the bootstrap loader.
156 .It Dv MODULE_SOURCE_FILESYS
157 The module was loaded from the file system.
159 .It Fa "modclass_t ms_class"
160 One of the following enumerated constants:
161 .Bl -tag -compact -width "MODULE_SOURCE_FILESYS"
162 .It Dv MODULE_CLASS_SECMODEL
164 .It Dv MODULE_CLASS_VFS
166 .It Dv MODULE_CLASS_DRIVER
168 .It Dv MODULE_CLASS_EXEC
169 Executable file format.
170 .It Dv MODULE_CLASS_MISC
172 .It Dv MODULE_CLASS_ANY
174 .\" XXX: is MODULE_CLASS_ANY ever returned by this interface?
176 .It Fa "uint64_t ms_addr"
177 The load address within the kernel.
178 .It Fa "u_int ms_size"
179 Loaded size of the module.
180 .It Fa "u_int ms_refcnt"
181 Current number of live references to this module.
184 Upon successful completion, the value returned is 0.
186 Otherwise, a value of \-1 is returned and
188 is set to indicate the error.
198 and the module is in use or the module is compiled into the kernel.
204 and there is a circular dependency in the module's dependency chain.
210 and the module is already loaded.
212 A bad address was given for
219 the specified module resides in the file system, and the module's default
220 proplib file was too large.
243 The kernel is unable to internalize the plist.
244 Or, there is a problem with the module or \*[Lt]module\*[Gt].plist.
250 and the module has too many dependencies.
251 .It Bq Er ENAMETOOLONG
252 A module name/path is too long.
258 and the module or a dependency can't be found.
263 and no module by the name of
271 and the module is not a valid object for the system.
273 There was not enough memory to perform the
276 Not allowed to perform the
278 .It Bq Er EPROGMISMATCH
287 structure does not include
288 .Dv MODCTL_LOAD_FORCE ,
289 and the requested module does not match the current kernel's version
299 function call first appeared in