Much cleaner, shorter, and simpler, skeleton for an LKM.

Not connected to the build.
This commit is contained in:
elad 2007-02-04 22:53:09 +00:00
parent f053782e48
commit 6c98db2b70
2 changed files with 55 additions and 0 deletions

View File

@ -0,0 +1,8 @@
# $NetBSD: Makefile,v 1.1 2007/02/04 22:53:09 elad Exp $
KMOD= skel
SRCS= lkminit_skel.c
.include <bsd.kmod.mk>
.include <bsd.subdir.mk>

View File

@ -0,0 +1,47 @@
/* $NetBSD: lkminit_skel.c,v 1.1 2007/02/04 22:53:09 elad Exp $ */
/* This code is in the public domain. */
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lkminit_skel.c,v 1.1 2007/02/04 22:53:09 elad Exp $");
#include <sys/param.h>
#include <sys/lkm.h>
int skel_lkmentry(struct lkm_table *lkmtp, int, int);
static int skelmod_handle(struct lkm_table *, int);
/* The module name, as appears in 'modstat' (and used in 'modunload'). */
MOD_MISC("skelmod");
static int
skelmod_handle(struct lkm_table *lkmtp, int cmd)
{
int error = 0;
switch(cmd) {
case LKM_E_LOAD:
if(lkmexists(lkmtp))
return( EEXIST);
printf("hello world\n");
break;
case LKM_E_UNLOAD:
printf("goodbye world\n");
break;
default:
error = EINVAL;
break;
}
return (error);
}
int
skel_lkmentry(struct lkm_table *lkmtp, int cmd, int ver)
{
DISPATCH(lkmtp, cmd, ver, skelmod_handle, skelmod_handle, lkm_nofunc)
}