1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
.\" $OpenBSD: lkm.4,v 1.6 1999/05/16 19:56:29 alex Exp $
.\" $NetBSD: lkm.4,v 1.4 1994/11/30 16:22:22 jtc Exp $
.\"
.\" 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.
.\"
.Dd September 4, 1993
.Dt LKM 4
.Os OpenBSD
.Sh NAME
.Nm LKM
.Nd Loadable Kernel Modules interface
.Sh SYNOPSIS
.Cd "option LKM"
.Sh DESCRIPTION
Loadable kernel modules allow the system administrator to
dynamically add and remove functionality from a running system.
This ability also helps software 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 sytem.
There are several defined module types, listed below, which can
be added to the system in a predefined way. In addition, there
is a generic type, for which the module itself handles loading and
unloading.
.Pp
The
.Nm
interface is used by performing
.Xr ioctl 2
calls on the
.Pa /dev/lkm
device. Normally all operations involving
Loadable Kernel Modules are handled by the
.Xr modload 8 ,
.Xr modunload 8 ,
and
.Xr modstat 8
programs. Users should never have to interact with
.Pa /dev/lkm
directly.
.Sh "MODULE TYPES"
.Bl -tag -width indent
.It System Call modules
System calls may be replaced by loading
new ones via the
.Nm
interface. All system calls may be
replaced, but special care should
be taken with the
.Xr ioctl 2
system call, as it is used to load and
unload modules.
.Pp
When a system call module is unloaded,
the system call which
was replaced by the loadable module
is returned to its rightful place
in the system call table.
.It Virtual File System modules
Virtual file systems may be added
via the
.Nm
interface.
.It Device Driver modules
New block and character device
drivers may be loaded into the system with
.Nm LKM .
The major problem with loading
a device driver is that the driver's
device nodes must be exist for the
devices to be accessed. They are usually
created by instructing
.Xr modload 8
to run an appropriate program when
the driver has been successfully loaded.
.It Execution Interpreters
Execution interpreters allow
the loading and execution of
binaries which are normally not
usable by the operating system.
.It Miscellaneous modules
Miscellaneous modules are modules
for which there are not currently
well-defined or well-used interfaces
for extension. The user is expected
to write their own loader to manipulate
whatever kernel data structures necessary
to enable and disable the new module
when it is loaded and unloaded.
.El
.Sh FILES
.Bl -tag -width /usr/include/sys/lkm.h -compact
.It Pa /dev/lkm
.Nm
interface device
.It Pa /usr/include/sys/lkm.h
file containing definitions of module types
.It Pa /usr/share/lkm
example source code implementing several of the modules types
.Sh SEE ALSO
.Xr modload 8 ,
.Xr modstat 8 ,
.Xr modunload 8
.Sh HISTORY
The
.Nm
facility was designed to be similar in functionality
to the loadable kernel modules facility provided by
.Tn "SunOS 4.1.3" .
.Sh AUTHOR
.Bl -tag
Terrence R. Lambert, terry@cs.weber.edu
.El
.Sh BUGS
Loading a bogus module is likely to kill your machine.
.Pp
Loadable streams modules should and will be implemented
when a streams implementation is written.
|