diff options
-rw-r--r-- | share/examples/lkm/misc/module/Makefile | 32 | ||||
-rw-r--r-- | share/examples/lkm/misc/module/misccall.c | 1 | ||||
-rw-r--r-- | share/examples/lkm/misc/module/miscmod.c | 14 | ||||
-rw-r--r-- | share/examples/lkm/misc/test/Makefile | 9 | ||||
-rw-r--r-- | share/examples/lkm/misc/test/testmisc.c | 5 |
5 files changed, 28 insertions, 33 deletions
diff --git a/share/examples/lkm/misc/module/Makefile b/share/examples/lkm/misc/module/Makefile index 562a75d..edb2998 100644 --- a/share/examples/lkm/misc/module/Makefile +++ b/share/examples/lkm/misc/module/Makefile @@ -34,32 +34,16 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # +# $Id$ +# +BINDIR= /tmp +SRCS= misccall.c miscmod.c +KMOD= misc_mod +NOMAN= none -SRCS=miscmod.c -OBJS=$(SRCS:.c=.o) - -KSRCS=misccall.c -KOBJS=misccall.o - -MODOBJ=combined.o - -KMOD=miscmod -CFLAGS= -DKERNEL -I/sys/sys -I/sys - -all: $(MODOBJ) - -clean: - rm -f $(OBJS) $(KOBJS) $(MODOBJ) $(KMOD) - -load: - /sbin/modload -o $(KMOD) -e$(KMOD) $(MODOBJ) - -unload: - /sbin/modunload -n $(KMOD) - -$(MODOBJ): $(OBJS) $(KOBJS) - $(LD) -r -o $(MODOBJ) $(OBJS) $(KOBJS) +CLEANFILES+= ${KMOD} +.include <bsd.kmod.mk> # # EOF -- This file has not been truncated # diff --git a/share/examples/lkm/misc/module/misccall.c b/share/examples/lkm/misc/module/misccall.c index 86741c4..5cadafc 100644 --- a/share/examples/lkm/misc/module/misccall.c +++ b/share/examples/lkm/misc/module/misccall.c @@ -37,6 +37,7 @@ */ #include <sys/param.h> #include <sys/ioctl.h> +#include <sys/proc.h> #include <sys/systm.h> diff --git a/share/examples/lkm/misc/module/miscmod.c b/share/examples/lkm/misc/module/miscmod.c index cc992aa..0f5a38f 100644 --- a/share/examples/lkm/misc/module/miscmod.c +++ b/share/examples/lkm/misc/module/miscmod.c @@ -1,6 +1,6 @@ /* 25 May 93*/ /* - * Makefile for miscmod + * miscmod.c * * 05 Jun 93 Terry Lambert Split mycall.c out * 25 May 93 Terry Lambert Original @@ -38,10 +38,12 @@ */ #include <sys/param.h> #include <sys/ioctl.h> +#include <sys/proc.h> #include <sys/systm.h> #include <sys/conf.h> #include <sys/mount.h> #include <sys/exec.h> +#include <sys/sysent.h> #include <sys/lkm.h> #include <a.out.h> #include <sys/file.h> @@ -63,7 +65,12 @@ static struct sysent newent = { */ static struct sysent oldent; /* save are for old callslot entry*/ -MOD_MISC( "miscmod") +/* + * Number of syscall entries for a.out executables + */ +#define nsysent (aout_sysvec.sv_size) + +MOD_MISC( "misc_mod") /* @@ -90,7 +97,6 @@ int cmd; int i; struct lkm_misc *args = lkmtp->private.lkm_misc; int err = 0; /* default = success*/ - extern int nsysent; /* init_sysent.c*/ extern int lkmnosys(); /* allocable slot*/ switch( cmd) { @@ -175,7 +181,7 @@ int cmd; * 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) +misc_mod( lkmtp, cmd, ver) struct lkm_table *lkmtp; int cmd; int ver; diff --git a/share/examples/lkm/misc/test/Makefile b/share/examples/lkm/misc/test/Makefile index 466e4ac..61bbf37 100644 --- a/share/examples/lkm/misc/test/Makefile +++ b/share/examples/lkm/misc/test/Makefile @@ -34,10 +34,13 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # - +# $Id$ +# PROG= testmisc NOMAN= +MODSTAT= /usr/bin/modstat + load: @echo "This test program will call the sample system call;" @echo "the "offset requested will be shown as 'Off' in the" @@ -48,7 +51,7 @@ load: @echo "system console each time it is run." @echo @echo - /sbin/modstat -n miscmod + ${MODSTAT} -n misc_mod @echo @./testmisc @@ -57,7 +60,7 @@ unload: @echo "has been successfully unloaded by building 'unload' in" @echo "the 'module' subdirectory." @echo - /sbin/modstat -n miscmod + ${MODSTAT} -n misc_mod .include <bsd.prog.mk> diff --git a/share/examples/lkm/misc/test/testmisc.c b/share/examples/lkm/misc/test/testmisc.c index 622857d..83f3338 100644 --- a/share/examples/lkm/misc/test/testmisc.c +++ b/share/examples/lkm/misc/test/testmisc.c @@ -46,12 +46,13 @@ main() int err = 0; printf( "Table offset as reported by modstat: "); - if( gets( buf) == NULL) { + fflush( stdout); + if( fgets( buf, 80, stdin) == NULL) { printf( "[ABORT]\n"); exit( 1); } - if( err = syscall( atoi( buf) /* no arguments*/)) + if(( err = syscall( atoi( buf) /* no arguments*/))) perror( "syscall"); exit( err); |