Hello. c file
# Include <Linux/init. h> <br/> # include <Linux/module. h> <br/> # include <Linux/kernel. h> <br/> static int hello_init (void) <br/> {<br/> printk (kern_alert "Hello world! /N "); <br/> return 0; <br/>}< br/> static void hello_exit (void) <br/>{< br/> printk (kern_alert "bye world! /N "); <br/>}< br/> module_init (hello_init); <br/> module_exit (hello_exit ); <br/> module_license ("dual BSD/GPL ");
MAKEFILE file (Note: Only makefile, not makefile. This is another difference between 2.4 and 2.6.)
OBJ-M: = Hello. o
Kdir: =/usr/src/Linux
PWD: = $ (shell PWD)
Default:
$ (Make)-C $ (kdir) subdirs = $ (PWD) Modules
Clean:
Rm-RF *. Ko
Rm-RF *. Mod .*
Rm-RF. *. cmd
Rm-RF *. o
Install:
Insmod hello. Ko
Remove:
Rmmod hello
[Root @ localhost Hello] # Make
[Root @ localhost Hello] # make install
If"INvalidModule format"See: Linux 2.6.x kernel module loading error" invalid module format "SOLUTION