nuke /usr/share/lkm - kernel modules are inherently depedant upon kernel,
so the example lkms should be included in kernel sets only; furthermore, the stuff was highly outdated relevant items will be moved to lkm(4) and under syssrc/sys/lkm/
This commit is contained in:
parent
2940363203
commit
02ab8e1e3f
@ -1,4 +1,4 @@
|
||||
# $NetBSD: mi,v 1.280 2000/12/11 09:18:03 jdolecek Exp $
|
||||
# $NetBSD: mi,v 1.281 2000/12/11 13:44:00 jdolecek Exp $
|
||||
./sys comp-sysutil-root
|
||||
./usr/bin/addr2line comp-miscutil-bin
|
||||
./usr/bin/ar comp-util-bin
|
||||
@ -1382,21 +1382,6 @@
|
||||
./usr/share/ldscripts/sun4.xn comp-util-share
|
||||
./usr/share/ldscripts/sun4.xr comp-util-share
|
||||
./usr/share/ldscripts/sun4.xu comp-util-share
|
||||
./usr/share/lkm/README comp-lkm-share
|
||||
./usr/share/lkm/misc/Makefile comp-lkm-share
|
||||
./usr/share/lkm/misc/README comp-lkm-share
|
||||
./usr/share/lkm/misc/module/Makefile comp-lkm-share
|
||||
./usr/share/lkm/misc/module/misccall.c comp-lkm-share
|
||||
./usr/share/lkm/misc/module/miscmod.c comp-lkm-share
|
||||
./usr/share/lkm/misc/test/Makefile comp-lkm-share
|
||||
./usr/share/lkm/misc/test/testmisc.c comp-lkm-share
|
||||
./usr/share/lkm/syscall/Makefile comp-lkm-share
|
||||
./usr/share/lkm/syscall/README comp-lkm-share
|
||||
./usr/share/lkm/syscall/module/Makefile comp-lkm-share
|
||||
./usr/share/lkm/syscall/module/mycall.c comp-lkm-share
|
||||
./usr/share/lkm/syscall/module/newsyscall.c comp-lkm-share
|
||||
./usr/share/lkm/syscall/test/Makefile comp-lkm-share
|
||||
./usr/share/lkm/syscall/test/testsyscall.c comp-lkm-share
|
||||
./usr/share/locale/da/LC_MESSAGES/gettext.mo comp-miscutil-bin
|
||||
./usr/share/locale/de/LC_MESSAGES/gettext.mo comp-miscutil-bin
|
||||
./usr/share/locale/es/LC_MESSAGES/gettext.mo comp-miscutil-bin
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: obsolete.mi,v 1.31 2000/12/11 09:18:04 jdolecek Exp $
|
||||
# $NetBSD: obsolete.mi,v 1.32 2000/12/11 13:44:01 jdolecek Exp $
|
||||
/usr/bin/genclass
|
||||
/usr/bin/gettextize
|
||||
/usr/include/bfd
|
||||
@ -371,6 +371,21 @@
|
||||
/usr/share/mk/bsd.crypto.mk
|
||||
/usr/share/mk/bsd.port.mk
|
||||
/usr/share/mk/bsd.port.subdir.mk
|
||||
/usr/share/lkm/README
|
||||
/usr/share/lkm/misc/Makefile
|
||||
/usr/share/lkm/misc/README
|
||||
/usr/share/lkm/misc/module/Makefile
|
||||
/usr/share/lkm/misc/module/misccall.c
|
||||
/usr/share/lkm/misc/module/miscmod.c
|
||||
/usr/share/lkm/misc/test/Makefile
|
||||
/usr/share/lkm/misc/test/testmisc.c
|
||||
/usr/share/lkm/syscall/Makefile
|
||||
/usr/share/lkm/syscall/README
|
||||
/usr/share/lkm/syscall/module/Makefile
|
||||
/usr/share/lkm/syscall/module/mycall.c
|
||||
/usr/share/lkm/syscall/module/newsyscall.c
|
||||
/usr/share/lkm/syscall/test/Makefile
|
||||
/usr/share/lkm/syscall/test/testsyscall.c
|
||||
/usr/share/lkm/vfs/Makefile
|
||||
/usr/share/lkm/vfs/README
|
||||
/usr/share/lkm/vfs/module/Makefile
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: NetBSD.dist,v 1.123 2000/11/18 06:05:10 wiz Exp $
|
||||
# $NetBSD: NetBSD.dist,v 1.124 2000/12/11 13:44:01 jdolecek Exp $
|
||||
# @(#)4.4BSD.dist 8.1 (Berkeley) 6/13/93
|
||||
|
||||
/set type=dir uname=root gname=wheel mode=0755
|
||||
@ -1092,27 +1092,6 @@ ldscripts
|
||||
# ./usr/share/ldscripts
|
||||
..
|
||||
|
||||
# ./usr/share/lkm
|
||||
lkm
|
||||
|
||||
# ./usr/share/lkm/misc
|
||||
misc
|
||||
# ./usr/share/lkm/misc
|
||||
..
|
||||
|
||||
# ./usr/share/lkm/syscall
|
||||
syscall
|
||||
# ./usr/share/lkm/syscall
|
||||
..
|
||||
|
||||
# ./usr/share/lkm/vfs
|
||||
vfs
|
||||
# ./usr/share/lkm/vfs
|
||||
..
|
||||
|
||||
# ./usr/share/lkm
|
||||
..
|
||||
|
||||
# ./usr/share/locale
|
||||
locale
|
||||
|
||||
|
@ -1,19 +0,0 @@
|
||||
#
|
||||
# $NetBSD: Makefile,v 1.18 2000/12/11 09:14:28 jdolecek Exp $
|
||||
#
|
||||
|
||||
.include <bsd.own.mk> # for UNPRIVILEGED
|
||||
|
||||
STUFF= README syscall misc
|
||||
MKOBJ= no
|
||||
|
||||
install:
|
||||
find ${STUFF} -follow -name CVS -prune -o -type f -print | \
|
||||
cpio -pdumL ${DESTDIR}${BINDIR}/lkm
|
||||
.if !defined(UNPRIVILEGED)
|
||||
chown -R ${BINOWN}:${BINGRP} ${DESTDIR}${BINDIR}/lkm
|
||||
.endif
|
||||
find ${DESTDIR}${BINDIR}/lkm -type f | xargs chmod a=rX
|
||||
find ${DESTDIR}${BINDIR}/lkm -type d | xargs chmod u=rwX,go=rX
|
||||
|
||||
.include <bsd.prog.mk>
|
220
share/lkm/README
220
share/lkm/README
@ -1,220 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 1993 Terrence R. Lambert.
|
||||
# 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. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by Terrence R. Lambert.
|
||||
# 4. The name Terrence R. Lambert may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY TERRENCE R. LAMBERT ``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 TERRENCE R. LAMBERT 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.
|
||||
#
|
||||
# $NetBSD: README,v 1.4 1997/10/13 11:20:02 lukem Exp $
|
||||
#
|
||||
|
||||
0.0 README
|
||||
|
||||
README file for the loadable kernel modules interface.
|
||||
|
||||
Direct questions and comments to:
|
||||
|
||||
Terry Lambert
|
||||
terry@cs.weber.edu
|
||||
|
||||
Please do *not* mail me at Novell.
|
||||
|
||||
|
||||
1.0 About this build heirarchy
|
||||
|
||||
This is the build heirarchy for the loadable kernel modules
|
||||
(lkm) command line interface and test suite (including a
|
||||
set of sample code for each possible module type).
|
||||
|
||||
The procedures in this file assume you have installed the
|
||||
kernel portions of the lkm system and have rebooted your
|
||||
machine so that they are ready for use.
|
||||
|
||||
If you have not done this, then there is no reason for you to
|
||||
continue; please take the time to install the lkm system into
|
||||
your kernel at this time.
|
||||
|
||||
|
||||
2.0 Compiler warnings
|
||||
|
||||
Some compiler warnings will occur due to inclusion of kernel
|
||||
and non-kernel header files in the same program that have had
|
||||
the same function names ANSIfied and the prototypes for the
|
||||
kernel and libc functions conflict. This needs to be resolved
|
||||
by fixing the header files, which I haven't bothered to do (the
|
||||
main conflict was "printf", and I made a dirty hack to get
|
||||
around it until the header files have been fixed).
|
||||
|
||||
|
||||
3.0 Usage warnings
|
||||
|
||||
Loading a bogus module will kill your machine, but if you are
|
||||
doing developement, this will end up happening (hopefully)
|
||||
less frequently than changing, recompiling, installing, and
|
||||
rebooting would normally occur. This should speed developement
|
||||
considerably for a lot of the in-kernel work that is currently
|
||||
taking place.
|
||||
|
||||
|
||||
4.0 Loadable module types supported
|
||||
|
||||
There are 6 loadable modules types supported; 5 of these are
|
||||
specific module types; the sixth is to allow the user to make
|
||||
their own loader as part of the module and allow them to replace
|
||||
or extend apropriate tables in the kernel.
|
||||
|
||||
|
||||
4.1 System call modules
|
||||
|
||||
System calls as loadable modules use one of two approaches.
|
||||
|
||||
If the system call slot is unspecified (-1), it will attempt
|
||||
to locate (and allocate) the next free call slot that points
|
||||
to the address of the "lkmnosys" function (an alias for the
|
||||
"nosys" function). It replaces this with the user's call;
|
||||
the user can tell which slot was allocated using the "modstat"
|
||||
command (the call slot is indicated by the value of "Off").
|
||||
|
||||
If the system call slot is specified, it will replace that
|
||||
specific call (assuming it is in range of the entries in the
|
||||
sysent[] table). Care should be taken when replacing system
|
||||
calls. Good candiates are calls which the user is attempting
|
||||
to repair or make POSIX compliant. It is possible to replace
|
||||
all calls, although care should be taken with the "ioctl()"
|
||||
call, as it is the interface for the lkm loader.
|
||||
|
||||
When unloaded, the system call module replaces the previous
|
||||
contents of the call slot it was loaded in. If this was an
|
||||
allocable slot, it is now reallocable; if it was a particular
|
||||
call slot, the previous function is restored.
|
||||
|
||||
The directory ./sample/syscall contains a sample implementation
|
||||
of a loadable system call.
|
||||
|
||||
|
||||
4.2 Virtual file system modules
|
||||
|
||||
A virtual file system can be loaded as a module. The example
|
||||
provided is for the "kernfs" file system; this is the code in
|
||||
NetBSD's /sys/kernfs combined in a single object with another
|
||||
piece of code giving a module entry point for the file system;
|
||||
with very little effort, any file system can be set up this way
|
||||
(although I suggest you leave "ufs" statically linked, since
|
||||
it is necessary for booting).
|
||||
|
||||
The critical section of loading a VFS is to get the entry in
|
||||
the right slot and mounted.
|
||||
|
||||
Because of the dependency on the vfssw[] table index during
|
||||
the mount, we can't simply mix and match file systems except
|
||||
in their predefined locations with regard to mount. This
|
||||
means that there are changes to vfssw[] and mount coming
|
||||
down the road (which will end up incrementing the lkm version
|
||||
and introducing an incompatability as far as file system modules
|
||||
are converned).
|
||||
|
||||
The directory ./sample/vfs contains the sample implementation
|
||||
of the loadable kernfs vfs.
|
||||
|
||||
|
||||
4.3 Device driver modules
|
||||
|
||||
The major issue to deal with when creating device drivers is
|
||||
insuring the creation of the device node. The current approach
|
||||
to this is executing a module specific shell script upon a
|
||||
successful load.
|
||||
|
||||
A potentially better soloution is encoding the device name in
|
||||
the device switch, or, better, providing a functional interface
|
||||
to the init routine, and then using a "/devices" file system
|
||||
to export devices to the file system name space. Of course,
|
||||
the default "/dev" directory would have to be maintained for
|
||||
compatability (probably using symbolic links).
|
||||
|
||||
This distribution does not contain a loadable device driver
|
||||
example. A potentially beneficial example could be made of
|
||||
the "lpa" interruptless printer driver.
|
||||
|
||||
|
||||
4.4 Streams modules
|
||||
|
||||
Streams module support has been removed from this release; when
|
||||
the streams implementation is ready, it wil be restored as a
|
||||
patch.
|
||||
|
||||
Please do not ask me for early availability on my streams
|
||||
implementation; until I have some non-proprietary modules
|
||||
to distribute, I'm putting work on it on the back burner
|
||||
while I finish shared libraries.
|
||||
|
||||
|
||||
4.5 Execution interpreters
|
||||
|
||||
Execution interpreters allow loading of programs with magic
|
||||
numbers other than the default numbers supported by NetBSD.
|
||||
The reasoning behind this is to effectively allow user space
|
||||
developement of changes in exec format to support, among
|
||||
other things, shared libraries.
|
||||
|
||||
Another portential use requires changing the references to
|
||||
the "sysent[]" system call table from direct references to
|
||||
indirect through a pointer in the proc struct. This allows
|
||||
the execution interpreter to, among other things, support
|
||||
(statically linked) executables from other environments,
|
||||
like Xenix, SVR3, SVR4, and Linux.
|
||||
|
||||
There is no example of a loadable execution interpreter
|
||||
provided with this distribution.
|
||||
|
||||
|
||||
4.6 Miscellaneous modules
|
||||
|
||||
Miscellaneous modules are modules for which there is not a
|
||||
current, well defined, or well used interface for extension.
|
||||
They are provided for extension, and the user is expected to
|
||||
write their own loader to handle the kernel pointer/table
|
||||
manipulation to "wire in" their loaded module (and "unwire"
|
||||
it on uload).
|
||||
|
||||
One example of a "miscellaneous module" might be a loader for
|
||||
card-specific VGA drivers or alternate terminal emualtions in
|
||||
an appropriately layered console driver.
|
||||
|
||||
The table manipulations required are specific to the console
|
||||
interface, yet a loadable module may be used if code is written
|
||||
to tell it how to manipulate the interfaces within the internal
|
||||
console interfaces.
|
||||
|
||||
An example of a "miscellaneous module" is provided to show how
|
||||
to write "miscellaneous modules"; it duplicates the functionality
|
||||
of the "system call" module type, and is not intended to be
|
||||
seriously used, as it could interfere with the "system call"
|
||||
module type. The sample code is located in ./sample/misc.
|
||||
|
||||
|
||||
|
||||
5.0 END OF DOCUMENT
|
@ -1,49 +0,0 @@
|
||||
#
|
||||
# Makefile for sample loadable system call
|
||||
#
|
||||
# 25 May 93 Terry Lambert Original
|
||||
#
|
||||
# Copyright (c) 1993 Terrence R. Lambert.
|
||||
# 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. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by Terrence R. Lambert.
|
||||
# 4. The name Terrence R. Lambert may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY TERRENCE R. LAMBERT ``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 TERRENCE R. LAMBERT 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.
|
||||
#
|
||||
# $NetBSD: Makefile,v 1.2 1997/10/13 11:20:07 lukem Exp $
|
||||
#
|
||||
|
||||
SUBDIR= module test
|
||||
|
||||
load: _SUBDIRUSE
|
||||
|
||||
unload: _SUBDIRUSE
|
||||
|
||||
.include <bsd.subdir.mk>
|
||||
|
||||
#
|
||||
# EOF -- This file has not been truncated.
|
||||
#
|
@ -1,89 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 1993 Terrence R. Lambert.
|
||||
# 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. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by Terrence R. Lambert.
|
||||
# 4. The name Terrence R. Lambert may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY TERRENCE R. LAMBERT ``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 TERRENCE R. LAMBERT 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.
|
||||
#
|
||||
# $NetBSD: README,v 1.2 1997/10/13 11:20:10 lukem Exp $
|
||||
#
|
||||
|
||||
1.0 Overview
|
||||
|
||||
This is the README file for the sample miscellaneous module
|
||||
that mimics the loaded system call.
|
||||
|
||||
A miscellaneous module may be used to load any data or
|
||||
program into the kernel that can be made available by
|
||||
modifying a table, pointer, or other kernel data to inform
|
||||
the kernel that the module should be used instead of the
|
||||
previous code/data path.
|
||||
|
||||
Generally, it is assumed that a loadable module is one of
|
||||
a set of similar modules (such as a file system or console
|
||||
terminal emulation), and that the reference is through a
|
||||
table (such as vfssw[]), and that a "special" value is
|
||||
assigned to the slots which are allowed to be replaced.
|
||||
This is not enforced, so you may use the "miscellaneous"
|
||||
module any way you see fit.
|
||||
|
||||
As with the loadable system calls, it may be desirable to
|
||||
allow the module loader to replace an *existing* entry to
|
||||
try out changes to kernel code without rebuilding and
|
||||
booting from the new kernel.
|
||||
|
||||
|
||||
2.0 Directions
|
||||
|
||||
To test the module, do the following:
|
||||
|
||||
cd module
|
||||
make load
|
||||
|
||||
A load message (the copyright) will be printed on the console.
|
||||
|
||||
cd ../test
|
||||
make load
|
||||
|
||||
The system call prints a message on the console when called.
|
||||
This message will be printed when running "make load" in
|
||||
the "test" subdirectory.
|
||||
|
||||
|
||||
3.0 Recovering resources
|
||||
|
||||
The miscellaneous module consumes 8 pages of memory when
|
||||
loaded; it can be freed up by unloading it. To unload it,
|
||||
type the following from the directory this file is in:
|
||||
|
||||
cd module
|
||||
make unload
|
||||
|
||||
The miscellaneous module will be unloaded by name.
|
||||
|
||||
|
||||
4.0 END OF DOCUMENT
|
@ -1,66 +0,0 @@
|
||||
#
|
||||
# Makefile for miscmod
|
||||
#
|
||||
# 05 Jun 93 Terry Lambert Original
|
||||
#
|
||||
# Copyright (c) 1993 Terrence R. Lambert.
|
||||
# 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. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by Terrence R. Lambert.
|
||||
# 4. The name Terrence R. Lambert may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY TERRENCE R. LAMBERT ``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 TERRENCE R. LAMBERT 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.
|
||||
#
|
||||
# $NetBSD: Makefile,v 1.8 1999/11/10 00:44:22 wrstuden Exp $
|
||||
#
|
||||
|
||||
SRCS=miscmod.c
|
||||
OBJS=$(SRCS:.c=.o)
|
||||
|
||||
KSRCS=misccall.c
|
||||
KOBJS=misccall.o
|
||||
|
||||
MODOBJ=combined.o
|
||||
|
||||
KMOD=miscmod
|
||||
CFLAGS= -D_LKM -D_KERNEL -I/sys
|
||||
|
||||
all: $(MODOBJ)
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS) $(KOBJS) $(MODOBJ) $(KMOD)
|
||||
|
||||
load:
|
||||
modload -o $(KMOD) -e$(KMOD) $(MODOBJ)
|
||||
|
||||
unload:
|
||||
modunload -n $(KMOD)
|
||||
|
||||
$(MODOBJ): $(OBJS) $(KOBJS)
|
||||
$(LD) -r -o $(MODOBJ) $(OBJS) $(KOBJS)
|
||||
|
||||
#
|
||||
# EOF -- This file has not been truncated
|
||||
#
|
@ -1,77 +0,0 @@
|
||||
/*
|
||||
* misccall.c
|
||||
*
|
||||
* 05 Jun 93 Terry Lambert Split out of newsyscall.c
|
||||
*
|
||||
* Copyright (c) 1993 Terrence R. Lambert.
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Terrence R. Lambert.
|
||||
* 4. The name Terrence R. Lambert may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY TERRENCE R. LAMBERT ``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 TERRENCE R. LAMBERT 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.
|
||||
*
|
||||
* $NetBSD: misccall.c,v 1.2 1997/10/13 11:20:19 lukem Exp $
|
||||
*/
|
||||
#include <sys/param.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
|
||||
/*
|
||||
* This is the actual code for system call... it can be static because
|
||||
* we've externed it up above... the only plae it needs to be referenced
|
||||
* is the sysent we are interested in.
|
||||
*
|
||||
* To write your own system call using this as a template, you could strip
|
||||
* out this code and use the rest as a prototype module, changing only the
|
||||
* function names and the number of arguments to the call in the module
|
||||
* specific "sysent".
|
||||
*
|
||||
* You would have to use the "-R" option of "ld" to ensure a linkable file
|
||||
* if you were to do this, since you would need to combine multiple ".o"
|
||||
* files into a single ".o" file for use by "modload".
|
||||
*/
|
||||
int
|
||||
misccall( p, uap, retval)
|
||||
struct proc *p;
|
||||
void *uap;
|
||||
int retval[];
|
||||
{
|
||||
/*
|
||||
* Our new system call simply prints a message; it takes no
|
||||
* arguments.
|
||||
*/
|
||||
|
||||
printf( "\nI am a loaded system call using the miscellaneous\n");
|
||||
printf( "module loader interface and a kernel printf!\n");
|
||||
printf( "I will print this message each time I am called!\n");
|
||||
|
||||
return( 0); /* success (or error code from errno.h)*/
|
||||
}
|
||||
|
||||
/*
|
||||
* EOF -- This file has not been truncated.
|
||||
*/
|
@ -1,188 +0,0 @@
|
||||
/*
|
||||
* Makefile for miscmod
|
||||
*
|
||||
* 05 Jun 93 Terry Lambert Split mycall.c out
|
||||
* 25 May 93 Terry Lambert Original
|
||||
*
|
||||
* Copyright (c) 1993 Terrence R. Lambert.
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Terrence R. Lambert.
|
||||
* 4. The name Terrence R. Lambert may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY TERRENCE R. LAMBERT ``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 TERRENCE R. LAMBERT 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.
|
||||
*
|
||||
* $NetBSD: miscmod.c,v 1.5 1997/12/01 19:08:31 mjacob Exp $
|
||||
*/
|
||||
#include <sys/param.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/exec.h>
|
||||
#include <sys/lkm.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
|
||||
extern int misccall();
|
||||
|
||||
/*
|
||||
* These two entries define our system call and module information. We
|
||||
* have 0 arguments to our system call.
|
||||
*/
|
||||
static struct sysent newent = {
|
||||
0, 0, misccall /* # of args, args size, fn pointer*/
|
||||
};
|
||||
|
||||
/*
|
||||
* Miscellaneous modules must have their own save areas...
|
||||
*/
|
||||
static struct sysent oldent; /* save are for old callslot entry*/
|
||||
|
||||
MOD_MISC( "miscmod")
|
||||
|
||||
|
||||
/*
|
||||
* This function is called each time the module is loaded or unloaded.
|
||||
* Since we are a miscellaneous module, we have to provide whatever
|
||||
* code is necessary to patch ourselves into the area we are being
|
||||
* loaded to change.
|
||||
*
|
||||
* For the system call table, we duplicate the code in the kern_lkm.c
|
||||
* file for patching into the system call table. We can tell what
|
||||
* has been allocated, etc. by virtue of the fact that we know the
|
||||
* criteria used by the system call loader interface. We still
|
||||
* kick out the copyright to the console here (to give an example).
|
||||
*
|
||||
* The stat information is basically common to all modules, so there
|
||||
* is no real issue involved with stat; we will leave it lkm_nofunc(),
|
||||
* since we don't have to do anything about it.
|
||||
*/
|
||||
static int
|
||||
miscmod_handle( lkmtp, cmd)
|
||||
struct lkm_table *lkmtp;
|
||||
int cmd;
|
||||
{
|
||||
int i;
|
||||
struct lkm_misc *args = lkmtp->private.lkm_misc;
|
||||
int err = 0; /* default = success*/
|
||||
extern int sys_lkmnosys __P((struct proc *, void *, register_t *));
|
||||
|
||||
switch( cmd) {
|
||||
case LKM_E_LOAD:
|
||||
|
||||
/*
|
||||
* Don't load twice! (lkmexists() is exported by kern_lkm.c)
|
||||
*/
|
||||
if( lkmexists( lkmtp))
|
||||
return( EEXIST);
|
||||
|
||||
/*
|
||||
* This is where we would express a slot preference if
|
||||
* we had one; since we don't, we will simply duplicate
|
||||
* the "auto" code and forget the other.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Search the table looking for a slot...
|
||||
*/
|
||||
for (i = 0; i < SYS_MAXSYSCALL; i++)
|
||||
if (sysent[i].sy_call == sys_lkmnosys)
|
||||
break; /* found it!*/
|
||||
/* out of allocable slots?*/
|
||||
if (i == SYS_MAXSYSCALL) {
|
||||
err = ENFILE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* save old -- we must provide our own data area*/
|
||||
bcopy( &sysent[ i], &oldent, sizeof( struct sysent));
|
||||
|
||||
/* replace with new*/
|
||||
bcopy( &newent, &sysent[ i], sizeof( struct sysent));
|
||||
|
||||
/* done!*/
|
||||
args->lkm_offset = i; /* slot in sysent[]*/
|
||||
|
||||
|
||||
/* if we make it to here, print copyright on console*/
|
||||
printf( "\nSample Loaded miscellaneous module (system call)\n");
|
||||
printf( "Copyright (c) 1993\n");
|
||||
printf( "Terrence R. Lambert\n");
|
||||
printf( "All rights reserved\n");
|
||||
|
||||
break; /* Success*/
|
||||
|
||||
case LKM_E_UNLOAD:
|
||||
/* current slot...*/
|
||||
i = args->lkm_offset;
|
||||
|
||||
/* replace current slot contents with old contents*/
|
||||
bcopy( &oldent, &sysent[ i], sizeof( struct sysent));
|
||||
|
||||
break; /* Success*/
|
||||
|
||||
default: /* we only understand load/unload*/
|
||||
err = EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
return( err);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* External entry point; should generally match name of .o file. The
|
||||
* arguments are always the same for all loaded modules. The "load",
|
||||
* "unload", and "stat" functions in "DISPATCH" will be called under
|
||||
* their respective circumstances. If no function is desired, lkm_nofunc()
|
||||
* should be supplied. They are called with the same arguments (cmd is
|
||||
* included to allow the use of a single function, ver is included for
|
||||
* version matching between modules and the kernel loader for the modules).
|
||||
*
|
||||
* Since we expect to link in the kernel and add external symbols to
|
||||
* the kernel symbol name space in a future version, generally all
|
||||
* functions used in the implementation of a particular module should
|
||||
* be static unless they are expected to be seen in other modules or
|
||||
* to resolve unresolved symbols alread existing in the kernel (the
|
||||
* second case is not likely to ever occur).
|
||||
*
|
||||
* The entry point should return 0 unless it is refusing load (in which
|
||||
* case it should return an errno from errno.h).
|
||||
*/
|
||||
miscmod( lkmtp, cmd, ver)
|
||||
struct lkm_table *lkmtp;
|
||||
int cmd;
|
||||
int ver;
|
||||
{
|
||||
DISPATCH(lkmtp,cmd,ver,miscmod_handle,miscmod_handle,lkm_nofunc)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* EOF -- This file has not been truncated.
|
||||
*/
|
@ -1,67 +0,0 @@
|
||||
#
|
||||
# Makefile for testmisc
|
||||
#
|
||||
# 05 Jun 93 Terry Lambert Original
|
||||
#
|
||||
# Copyright (c) 1993 Terrence R. Lambert.
|
||||
# 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. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by Terrence R. Lambert.
|
||||
# 4. The name Terrence R. Lambert may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY TERRENCE R. LAMBERT ``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 TERRENCE R. LAMBERT 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.
|
||||
#
|
||||
# $NetBSD: Makefile,v 1.3 1999/02/13 02:54:35 lukem Exp $
|
||||
#
|
||||
|
||||
PROG= testmisc
|
||||
MKMAN= no
|
||||
|
||||
load:
|
||||
@echo "This test program will call the sample system call;"
|
||||
@echo "the "offset requested will be shown as 'Off' in the"
|
||||
@echo "status display below. If no modules are loaded, an"
|
||||
@echo "error '3' will be reported."
|
||||
@echo
|
||||
@echo "The sample system call will display a message on the"
|
||||
@echo "system console each time it is run."
|
||||
@echo
|
||||
@echo
|
||||
modstat -n miscmod
|
||||
@echo
|
||||
@./testmisc
|
||||
|
||||
unload:
|
||||
@echo "This test program will cause an error '3' if the call"
|
||||
@echo "has been successfully unloaded by building 'unload' in"
|
||||
@echo "the 'module' subdirectory."
|
||||
@echo
|
||||
modstat -n miscmod
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
||||
#
|
||||
# EOF -- This file has not been truncated.
|
||||
#
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
* testmisc.c
|
||||
*
|
||||
* Test program to call the sample loaded miscellaneous system call.
|
||||
*
|
||||
* 05 Jun 93 Terry Lambert Original
|
||||
*
|
||||
*
|
||||
* Copyright (c) 1993 Terrence R. Lambert.
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Terrence R. Lambert.
|
||||
* 4. The name Terrence R. Lambert may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY TERRENCE R. LAMBERT ``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 TERRENCE R. LAMBERT 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.
|
||||
*
|
||||
* $NetBSD: testmisc.c,v 1.2 1997/10/13 11:20:30 lukem Exp $
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
main()
|
||||
{
|
||||
char buf[ 80];
|
||||
int err = 0;
|
||||
|
||||
printf( "Table offset as reported by modstat: ");
|
||||
if( gets( buf) == NULL) {
|
||||
printf( "[ABORT]\n");
|
||||
exit( 1);
|
||||
}
|
||||
|
||||
if( err = syscall( atoi( buf) /* no arguments*/))
|
||||
perror( "syscall");
|
||||
|
||||
exit( err);
|
||||
}
|
||||
|
||||
/*
|
||||
* EOF -- This file has not been truncated
|
||||
*/
|
@ -1,50 +0,0 @@
|
||||
#
|
||||
# Makefile for sample loadable system call
|
||||
#
|
||||
# 25 May 93 Terry Lambert Original
|
||||
#
|
||||
# Copyright (c) 1993 Terrence R. Lambert.
|
||||
# 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. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by Terrence R. Lambert.
|
||||
# 4. The name Terrence R. Lambert may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY TERRENCE R. LAMBERT ``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 TERRENCE R. LAMBERT 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.
|
||||
#
|
||||
# $NetBSD: Makefile,v 1.2 1997/10/13 11:20:34 lukem Exp $
|
||||
#
|
||||
|
||||
# Makefile for sample loadable system call
|
||||
SUBDIR= module test
|
||||
|
||||
load: _SUBDIRUSE
|
||||
|
||||
unload: _SUBDIRUSE
|
||||
|
||||
.include <bsd.subdir.mk>
|
||||
|
||||
#
|
||||
# EOF -- This file has not been truncated.
|
||||
#
|
@ -1,69 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 1993 Terrence R. Lambert.
|
||||
# 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. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by Terrence R. Lambert.
|
||||
# 4. The name Terrence R. Lambert may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY TERRENCE R. LAMBERT ``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 TERRENCE R. LAMBERT 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.
|
||||
#
|
||||
# $NetBSD: README,v 1.2 1997/06/19 07:21:10 mikel Exp $
|
||||
#
|
||||
|
||||
1.0 Overview
|
||||
|
||||
This is the README file for the sample loaded system call.
|
||||
|
||||
|
||||
2.0 Directions
|
||||
|
||||
To test the module, do the following:
|
||||
|
||||
cd module
|
||||
make load
|
||||
|
||||
A load message (the copyright) will be printed on the console.
|
||||
|
||||
cd ../test
|
||||
make load
|
||||
|
||||
The system call prints a message on the console when called.
|
||||
This message will be printed when running "make load" in
|
||||
the "test" subdirectory.
|
||||
|
||||
|
||||
3.0 Recovering resources
|
||||
|
||||
The system call consumes 8 pages of memory when loaded; it
|
||||
can be freed up by unloading it. To unload it, type the
|
||||
following from the directory this file is in:
|
||||
|
||||
cd module
|
||||
make unload
|
||||
|
||||
The system call will be unloaded by name.
|
||||
|
||||
|
||||
4.0 END OF DOCUMENT
|
@ -1,66 +0,0 @@
|
||||
#
|
||||
# Makefile for newsyscall
|
||||
#
|
||||
# 05 Jun 93 Terry Lambert Original
|
||||
#
|
||||
# Copyright (c) 1993 Terrence R. Lambert.
|
||||
# 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. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by Terrence R. Lambert.
|
||||
# 4. The name Terrence R. Lambert may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY TERRENCE R. LAMBERT ``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 TERRENCE R. LAMBERT 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.
|
||||
#
|
||||
# $NetBSD: Makefile,v 1.8 1999/11/10 00:44:22 wrstuden Exp $
|
||||
#
|
||||
|
||||
SRCS=newsyscall.c
|
||||
OBJS=$(SRCS:.c=.o)
|
||||
|
||||
KSRCS=mycall.c
|
||||
KOBJS=mycall.o
|
||||
|
||||
MODOBJ=combined.o
|
||||
|
||||
KMOD=newsyscall
|
||||
CFLAGS= -D_LKM -D_KERNEL -I/sys
|
||||
|
||||
all: $(MODOBJ)
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS) $(KOBJS) $(MODOBJ) $(KMOD)
|
||||
|
||||
load:
|
||||
modload -o $(KMOD) -e$(KMOD) $(MODOBJ)
|
||||
|
||||
unload:
|
||||
modunload -n $(KMOD)
|
||||
|
||||
$(MODOBJ): $(OBJS) $(KOBJS)
|
||||
$(LD) -r -o $(MODOBJ) $(OBJS) $(KOBJS)
|
||||
|
||||
#
|
||||
# EOF -- This file has not been truncated
|
||||
#
|
@ -1,76 +0,0 @@
|
||||
/*
|
||||
* mycall.c
|
||||
*
|
||||
* 05 Jun 93 Terry Lambert Split out of newsyscall.c
|
||||
*
|
||||
* Copyright (c) 1993 Terrence R. Lambert.
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Terrence R. Lambert.
|
||||
* 4. The name Terrence R. Lambert may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY TERRENCE R. LAMBERT ``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 TERRENCE R. LAMBERT 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.
|
||||
*
|
||||
* $NetBSD: mycall.c,v 1.2 1997/10/13 11:20:41 lukem Exp $
|
||||
*/
|
||||
#include <sys/param.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
|
||||
/*
|
||||
* This is the actual code for system call... it can be static because
|
||||
* we've externed it up above... the only plae it needs to be referenced
|
||||
* is the sysent we are interested in.
|
||||
*
|
||||
* To write your own system call using this as a template, you could strip
|
||||
* out this code and use the rest as a prototype module, changing only the
|
||||
* function names and the number of arguments to the call in the module
|
||||
* specific "sysent".
|
||||
*
|
||||
* You would have to use the "-R" option of "ld" to ensure a linkable file
|
||||
* if you were to do this, since you would need to combine multiple ".o"
|
||||
* files into a single ".o" file for use by "modload".
|
||||
*/
|
||||
int
|
||||
mycall( p, uap, retval)
|
||||
struct proc *p;
|
||||
void *uap;
|
||||
int retval[];
|
||||
{
|
||||
/*
|
||||
* Our new system call simply prints a message; it takes no
|
||||
* arguments.
|
||||
*/
|
||||
|
||||
printf( "\nI am a loaded system call using the kernel printf!\n");
|
||||
printf( "I will print this message each time I am called!\n");
|
||||
|
||||
return( 0); /* success (or error code from errno.h)*/
|
||||
}
|
||||
|
||||
/*
|
||||
* EOF -- This file has not been truncated.
|
||||
*/
|
@ -1,114 +0,0 @@
|
||||
/*
|
||||
* Makefile for newsyscall
|
||||
*
|
||||
* 05 Jun 93 Terry Lambert Split mycall.c out
|
||||
* 25 May 93 Terry Lambert Original
|
||||
*
|
||||
* Copyright (c) 1993 Terrence R. Lambert.
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Terrence R. Lambert.
|
||||
* 4. The name Terrence R. Lambert may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY TERRENCE R. LAMBERT ``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 TERRENCE R. LAMBERT 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.
|
||||
*
|
||||
* $NetBSD: newsyscall.c,v 1.4 1997/10/13 11:20:45 lukem Exp $
|
||||
*/
|
||||
#include <sys/param.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/exec.h>
|
||||
#include <sys/lkm.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/errno.h>
|
||||
|
||||
|
||||
extern int mycall();
|
||||
|
||||
/*
|
||||
* These two entries define our system call and module information. We
|
||||
* have 0 arguments to our system call.
|
||||
*/
|
||||
static struct sysent newent = {
|
||||
0, 0, mycall /* # of args, args size, fn. pointer */
|
||||
};
|
||||
|
||||
MOD_SYSCALL( "newsyscall", -1, &newent)
|
||||
|
||||
|
||||
/*
|
||||
* This function is called each time the module is loaded. Technically,
|
||||
* we could have made this "lkm_nofunc" in the "DISPATCH" in "newsyscall()",
|
||||
* but it's a convenient place to kick a copyright out to the console.
|
||||
*/
|
||||
static int
|
||||
newsyscall_load( lkmtp, cmd)
|
||||
struct lkm_table *lkmtp;
|
||||
int cmd;
|
||||
{
|
||||
if( cmd == LKM_E_LOAD) { /* print copyright on console*/
|
||||
printf( "\nSample Loaded system call\n");
|
||||
printf( "Copyright (c) 1993\n");
|
||||
printf( "Terrence R. Lambert\n");
|
||||
printf( "All rights reserved\n");
|
||||
}
|
||||
|
||||
return( 0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* External entry point; should generally match name of .o file. The
|
||||
* arguments are always the same for all loaded modules. The "load",
|
||||
* "unload", and "stat" functions in "DISPATCH" will be called under
|
||||
* their respective circumstances. If no function is desired, lkm_nofunc()
|
||||
* should be supplied. They are called with the same arguments (cmd is
|
||||
* included to allow the use of a single function, ver is included for
|
||||
* version matching between modules and the kernel loader for the modules).
|
||||
*
|
||||
* Since we expect to link in the kernel and add external symbols to
|
||||
* the kernel symbol name space in a future version, generally all
|
||||
* functions used in the implementation of a particular module should
|
||||
* be static unless they are expected to be seen in other modules or
|
||||
* to resolve unresolved symbols alread existing in the kernel (the
|
||||
* second case is not likely to ever occur).
|
||||
*
|
||||
* The entry point should return 0 unless it is refusing load (in which
|
||||
* case it should return an errno from errno.h).
|
||||
*/
|
||||
newsyscall( lkmtp, cmd, ver)
|
||||
struct lkm_table *lkmtp;
|
||||
int cmd;
|
||||
int ver;
|
||||
{
|
||||
DISPATCH(lkmtp,cmd,ver,newsyscall_load,lkm_nofunc,lkm_nofunc)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* EOF -- This file has not been truncated.
|
||||
*/
|
@ -1,67 +0,0 @@
|
||||
#
|
||||
# Makefile for testsyscall
|
||||
#
|
||||
# 25 May 93 Terry Lambert Original
|
||||
#
|
||||
# Copyright (c) 1993 Terrence R. Lambert.
|
||||
# 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. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by Terrence R. Lambert.
|
||||
# 4. The name Terrence R. Lambert may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY TERRENCE R. LAMBERT ``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 TERRENCE R. LAMBERT 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.
|
||||
#
|
||||
# $NetBSD: Makefile,v 1.3 1999/02/13 02:54:35 lukem Exp $
|
||||
#
|
||||
|
||||
PROG= testsyscall
|
||||
MKMAN= no
|
||||
|
||||
load:
|
||||
@echo "This test program will call the sample system call;"
|
||||
@echo "the "offset requested will be shown as 'Off' in the"
|
||||
@echo "status display below. If no modules are loaded, an"
|
||||
@echo "error '3' will be reported."
|
||||
@echo
|
||||
@echo "The sample system call will display a message on the"
|
||||
@echo "system console each time it is run."
|
||||
@echo
|
||||
@echo
|
||||
modstat -n newsyscall
|
||||
@echo
|
||||
@./testsyscall
|
||||
|
||||
unload:
|
||||
@echo "This test program will cause an error '3' if the call"
|
||||
@echo "has been successfully unloaded by building 'unload' in"
|
||||
@echo "the 'module' subdirectory."
|
||||
@echo
|
||||
modstat -n newsyscall
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
||||
#
|
||||
# EOF -- This file has not been truncated.
|
||||
#
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
* testsyscall.c
|
||||
*
|
||||
* Test program to call the sample loaded system call.
|
||||
*
|
||||
* 23 May 93 Terry Lambert Original
|
||||
*
|
||||
*
|
||||
* Copyright (c) 1993 Terrence R. Lambert.
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Terrence R. Lambert.
|
||||
* 4. The name Terrence R. Lambert may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY TERRENCE R. LAMBERT ``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 TERRENCE R. LAMBERT 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.
|
||||
*
|
||||
* $NetBSD: testsyscall.c,v 1.2 1997/10/13 11:20:53 lukem Exp $
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
main()
|
||||
{
|
||||
char buf[ 80];
|
||||
int err = 0;
|
||||
|
||||
printf( "Table offset as reported by modstat: ");
|
||||
if( gets( buf) == NULL) {
|
||||
printf( "[ABORT]\n");
|
||||
exit( 1);
|
||||
}
|
||||
|
||||
if( err = syscall( atoi( buf) /* no arguments*/))
|
||||
perror( "syscall");
|
||||
|
||||
exit( err);
|
||||
}
|
||||
|
||||
/*
|
||||
* EOF -- This file has not been truncated
|
||||
*/
|
Loading…
Reference in New Issue
Block a user