/* hello-mod.c * * Load and unload a module that does nothing but acknowledge * init_module at insmod and * cleanup_module at rmmod. * * Code from Linux Kernel Module Programmer's Guide (hello-1.c) */ #include /* for module programming */ #include /* for KERN_ALERT in printk */ /* Deal with CONFIG_MODVERSIONS */ #if CONFIG_MODVERSIONS==1 #define MODVERSIONS #include #endif /* No main, kernel modules are loaded with insmod and unloaded with rmmod */ /* Prototypes */ int init_module(void); void cleanup_module(void); /* Module init at insmod */ int init_module(void) { printk("<1>hello-mod: Hello world.\n"); return 0; /* non 0 means init_module failed; module can't be loaded */ } /* Module cleanup at rmmod */ void cleanup_module(void) { printk(KERN_ALERT "hello-mod: Goodby world.\n"); }