A simple Linux kernel module. Each row of information is displayed when the user loads and exits. It can be used as a program framework or as a test and load module.
# Include "Linux/init. H "# include" Linux/module. H "// module_license (" GPL "); -- here: the code compiled into the kernel must identify that it complies with open source protocols such as the GPL protocol. The module does not need to use static int mysc_init (void) {printk ("Hello \ n"); Return 0;} static void mysc_exit (void) {printk ("Bye \ n ");} module_init (mysc_init); module_exit (mysc_exit );
The corresponding makefile (not simplified, but can be used .)
Kernelversion = $ (shell uname-R) kerneldir =/lib/modules/$ (kernelversion)/buildcc = gccifneq ($ (kernelrelease),) obj-M: = mysc. oelsepwd :=$ (shell PWD) modules: $ (make)-C $ (kerneldir) M = $ (PWD) modulesmodules_install: $ (make)-C $ (kerneldir) M = $ (PWD) modules_installclean: Rm-RF *. O *~ Core. depend. *. CMD *. Ko *. Mod. C. tmp_versionsendif