From f4734ea953e1c4b7dd2b32393df82efac49730c0 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Thu, 27 Jul 1995 09:45:28 +0000 Subject: [PATCH] Make this bugger actually compile and work again: o a couple of header files have been missing o convert the LKM Makefile to use o rename the module to ``misc_mod'' (as opposed to ``miscmod''), so the module name can be made identical to the module's file name, avoiding the clash with one of the component's .o file names o modstat(1/8) has been moved meanwhile --- share/examples/lkm/misc/module/Makefile | 32 ++++++----------------- share/examples/lkm/misc/module/misccall.c | 1 + share/examples/lkm/misc/module/miscmod.c | 14 +++++++--- share/examples/lkm/misc/test/Makefile | 9 ++++--- 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 562a75d87acd..edb299817a70 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 # # 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 86741c4a61a0..5cadafc2843a 100644 --- a/share/examples/lkm/misc/module/misccall.c +++ b/share/examples/lkm/misc/module/misccall.c @@ -37,6 +37,7 @@ */ #include #include +#include #include diff --git a/share/examples/lkm/misc/module/miscmod.c b/share/examples/lkm/misc/module/miscmod.c index cc992aa67693..0f5a38f83be7 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 #include +#include #include #include #include #include +#include #include #include #include @@ -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 466e4ac19021..61bbf372708b 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 diff --git a/share/examples/lkm/misc/test/testmisc.c b/share/examples/lkm/misc/test/testmisc.c index 622857d0ca52..83f333817fc0 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);