April 2012
Intermediate to advanced
352 pages
8h
English
You now know enough to write your first KLD. Example 1-1 is the complete skeleton code for a KLD.
Example 1-1. hello.c
#include <sys/param.h> #include <sys/module.h> #include <sys/kernel.h> #include <sys/systm.h> static inthello_modevent(module_t mod __unused, int event, void *arg __unused) { int error = 0; switch (event) { case MOD_LOAD: uprintf("Hello, world!\n"); break; case MOD_UNLOAD: uprintf("Good-bye, cruel world!\n"); break; default: error = EOPNOTSUPP; break; } return (error); }
static moduledata_t hello_mod = { "hello", hello_modevent, ...
Read now
Unlock full access