学习内核编程,自己编译了一个简单的模块,准备的文件hellomod.c
#include<linux/module.h>
#include<linux/kernel.h>
#include<linux/init.h>
static int __init lkp_init(void)
{
printk("<1>Hello,World! from the kernel space.../n");
return 0;
}
static void __exit lkp_cleanup(void)
{
printk("<1>Goodbye,World!leaving kernel space...\n");
}
module_init(lkp_init);
module_exit(lkp_cleanup);
MODULE_LICENSE("GPL");:
objs-m:=hellomod.o
CURRENT_PATH:=$(shell pwd)
LINUX_KERNEL_PATH:=/lib/modules/$(shell uname -r)/build
all:
make -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH) modules
clean:
make -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH) clean
[root@localhost simple_modle]# make
make -C /lib/modules/2.6.18-53.el5/build M=/home/module/simple_modle modules
make[1]: Entering directory `/usr/src/kernels/2.6.18-53.el5-i686'
Building modules, stage 2.
MODPOST
make[1]: Leaving directory `/usr/src/kernels/2.6.18-53.el5-i686'
[root@localhost simple_modle]# ls
hellomod.c Makefile Module.symvers