1999-04-13 13:23:11 +00:00
|
|
|
.\" Copyright (c) 1993 Christopher G. Demetriou
|
|
|
|
.\" 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.
|
|
|
|
.\" 3. The name of the author may not be used to endorse or promote products
|
|
|
|
.\" derived from this software without specific prior written permission
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
|
|
|
.\"
|
1999-08-28 00:22:10 +00:00
|
|
|
.\" $FreeBSD$
|
1999-04-13 13:23:11 +00:00
|
|
|
.\"
|
2000-12-11 15:47:53 +00:00
|
|
|
.Dd November 8, 1998
|
1999-04-13 13:23:11 +00:00
|
|
|
.Dt KLD 4
|
2001-07-10 15:31:11 +00:00
|
|
|
.Os
|
1999-04-13 13:23:11 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm kld
|
|
|
|
.Nd dynamic kernel linker facility
|
|
|
|
.Sh DESCRIPTION
|
2000-11-14 11:20:58 +00:00
|
|
|
The LKM (Loadable Kernel Modules) facility has been deprecated in
|
|
|
|
.Fx 3.0
|
2001-07-14 19:41:16 +00:00
|
|
|
and above in favor of the
|
1999-04-13 13:23:11 +00:00
|
|
|
.Nm
|
2000-03-01 14:50:24 +00:00
|
|
|
interface.
|
|
|
|
This interface, like its
|
1999-04-13 13:23:11 +00:00
|
|
|
predecessor, allows the system administrator to dynamically add and remove
|
2003-06-28 23:53:39 +00:00
|
|
|
functionality from a running system.
|
|
|
|
This ability also helps software
|
1999-04-13 13:23:11 +00:00
|
|
|
developers to develop new parts of the kernel without constantly rebooting
|
|
|
|
to test their changes.
|
|
|
|
.Pp
|
|
|
|
Various types of modules can be loaded into the system.
|
|
|
|
There are several defined module types, listed below, which can
|
2003-06-28 23:53:39 +00:00
|
|
|
be added to the system in a predefined way.
|
|
|
|
In addition, there
|
1999-04-13 13:23:11 +00:00
|
|
|
is a generic type, for which the module itself handles loading and
|
|
|
|
unloading.
|
|
|
|
.Pp
|
|
|
|
The
|
2000-11-14 11:20:58 +00:00
|
|
|
.Fx
|
1999-04-13 13:23:11 +00:00
|
|
|
system makes extensive use of loadable kernel modules, and provides loadable
|
2002-12-12 17:26:04 +00:00
|
|
|
versions of most file systems, the
|
1999-04-13 13:23:11 +00:00
|
|
|
.Tn NFS
|
|
|
|
client and server, all the screen-savers, and the
|
|
|
|
.Tn iBCS2
|
|
|
|
and
|
|
|
|
.Tn Linux
|
|
|
|
emulators.
|
|
|
|
.Nm
|
|
|
|
modules are placed by default in the
|
2001-03-16 02:26:48 +00:00
|
|
|
.Pa /boot/kernel
|
|
|
|
directory along with their matching kernel.
|
1999-04-13 13:23:11 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
interface is used through the
|
|
|
|
.Xr kldload 8 ,
|
|
|
|
.Xr kldunload 8
|
|
|
|
and
|
|
|
|
.Xr kldstat 8
|
|
|
|
programs.
|
|
|
|
.Pp
|
2001-07-14 19:41:16 +00:00
|
|
|
The
|
1999-04-13 13:23:11 +00:00
|
|
|
.Xr kldload 8
|
|
|
|
program can load either
|
|
|
|
.Xr a.out 5
|
|
|
|
or ELF formatted loadable modules.
|
2001-07-14 19:41:16 +00:00
|
|
|
The
|
1999-04-13 13:23:11 +00:00
|
|
|
.Xr kldunload 8
|
|
|
|
program unloads any given loaded module, if no other module is dependent
|
|
|
|
upon the given module.
|
|
|
|
The
|
|
|
|
.Xr kldstat 8
|
|
|
|
program is used to check the status of the modules currently loaded into the
|
|
|
|
system.
|
2003-10-26 14:21:30 +00:00
|
|
|
.Pp
|
|
|
|
Kernel modules may only be loaded or unloaded if the system security level
|
|
|
|
.Va kern.securelevel
|
|
|
|
is less than one.
|
1999-04-13 13:23:11 +00:00
|
|
|
.Sh "MODULE TYPES"
|
|
|
|
.Bl -ohang
|
|
|
|
.It Em "Device Driver modules"
|
|
|
|
New block and character device
|
|
|
|
drivers may be loaded into the system with
|
2000-11-20 18:41:33 +00:00
|
|
|
.Nm .
|
2003-03-25 14:35:27 +00:00
|
|
|
Device nodes for the loaded drivers are automatically created when a
|
|
|
|
module is loaded and destroyed when it is unloaded by
|
|
|
|
.Xr devfs 5 .
|
|
|
|
You can specify userland programs that will run when new devices
|
|
|
|
become available as a result of loading modules, or existing devices
|
|
|
|
go away when modules are unloaded, by configuring
|
|
|
|
.Xr devd 8 .
|
1999-04-13 13:23:11 +00:00
|
|
|
.El
|
|
|
|
.Sh FILES
|
|
|
|
.Bl -tag -width /usr/include/sys/module.h -compact
|
2001-03-16 02:26:48 +00:00
|
|
|
.It Pa /boot/kernel
|
|
|
|
directory containing module binaries built for the kernel also
|
|
|
|
residing in the directory.
|
1999-04-13 13:23:11 +00:00
|
|
|
.It Pa /usr/include/sys/module.h
|
2001-07-14 19:41:16 +00:00
|
|
|
file containing definitions required to compile a
|
1999-04-13 13:23:11 +00:00
|
|
|
.Nm
|
2001-07-14 19:41:16 +00:00
|
|
|
module
|
1999-04-13 13:23:11 +00:00
|
|
|
.It Pa /usr/share/examples/kld
|
|
|
|
example source code implementing a sample kld module
|
2000-12-29 09:18:45 +00:00
|
|
|
.El
|
1999-04-13 13:23:11 +00:00
|
|
|
.Sh SEE ALSO
|
1999-04-13 14:51:51 +00:00
|
|
|
.Xr kldfind 2 ,
|
|
|
|
.Xr kldfirstmod 2 ,
|
|
|
|
.Xr kldload 2 ,
|
|
|
|
.Xr kldnext 2 ,
|
|
|
|
.Xr kldstat 2 ,
|
|
|
|
.Xr kldunload 2 ,
|
2003-03-25 14:35:27 +00:00
|
|
|
.Xr devfs 5 ,
|
|
|
|
.Xr devd 8 ,
|
1999-04-13 13:23:11 +00:00
|
|
|
.Xr kldload 8 ,
|
|
|
|
.Xr kldstat 8 ,
|
2003-10-26 14:21:30 +00:00
|
|
|
.Xr kldunload 8 ,
|
|
|
|
.Xr sysctl 8
|
2005-01-21 08:36:40 +00:00
|
|
|
.Sh HISTORY
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
facility appeared in
|
|
|
|
.Fx 3.0
|
|
|
|
and was designed as a replacement for the
|
2007-02-13 17:06:15 +00:00
|
|
|
.Nm lkm
|
2005-01-21 08:36:40 +00:00
|
|
|
facility, which was similar in functionality to the loadable kernel modules
|
|
|
|
facility provided by
|
|
|
|
.Tn SunOS
|
|
|
|
4.1.3.
|
|
|
|
.Sh AUTHORS
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
facility was originally implemented by
|
|
|
|
.An Doug Rabson Aq dfr@FreeBSD.org .
|
1999-04-13 13:23:11 +00:00
|
|
|
.Sh BUGS
|
|
|
|
If a module B, is dependent on another module A, but is not compiled with
|
|
|
|
module A as a dependency, then
|
|
|
|
.Xr kldload 8
|
|
|
|
fails to load module B, even if module A is already present in the system.
|
|
|
|
.Pp
|
|
|
|
If multiple modules are dependent on module A, and are compiled with module
|
|
|
|
A as a dependency, then
|
|
|
|
.Xr kldload 8
|
|
|
|
loads an instance of module A when any of the modules are loaded.
|
|
|
|
.Pp
|
|
|
|
If a custom entry point is used for a module, and the module is compiled as
|
2001-07-14 19:41:16 +00:00
|
|
|
an
|
1999-04-13 13:23:11 +00:00
|
|
|
.Sq ELF
|
|
|
|
binary, then
|
|
|
|
.Xr kldload 8
|
|
|
|
fails to execute the entry point.
|
|
|
|
.Pp
|
|
|
|
.Xr kldload 8
|
|
|
|
returns the cryptic message
|
2000-11-22 16:11:48 +00:00
|
|
|
.Sq Li "ENOEXEC (Exec format error)"
|
1999-04-13 13:23:11 +00:00
|
|
|
for any error encountered while loading a module.
|
|
|
|
.Pp
|
|
|
|
When system internal interfaces change, old modules often cannot
|
|
|
|
detect this, and such modules when loaded will often cause crashes or
|
|
|
|
mysterious failures.
|