- 论坛徽章:
- 0
|
------------------------------hello.c文件内容------------------------------------
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void)
{
printk(KERN_ALERT "hello, world\n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye, cruel world\n");
}
module_init(hello_init);
module_exit(hello_exit);
---------------------------Makefile文件内容------------------------------------------
ifneq ($(KERNELRELEASE),)
obj-m := hello.o
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
[root@yang-centos hello]# make
make -C /lib/modules/2.6.32-358.14.1.el6.i686/build M=/root/exam_drive/hello modules
make[1]: Entering directory `/usr/src/kernels/2.6.32-358.14.1.el6.i686'
CC [M] /root/exam_drive/hello/hello.o
Building modules, stage 2.
MODPOST 1 modules
CC /root/exam_drive/hello/hello.mod.o
LD [M] /root/exam_drive/hello/hello.ko.unsigned
NO SIGN [M] /root/exam_drive/hello/hello.ko
make[1]: Leaving directory `/usr/src/kernels/2.6.32-358.14.1.el6.i686'
[root@yang-centos hello]# ls
hello.c hello.ko.unsigned hello.mod.o Makefile Module.symvers
hello.ko hello.mod.c hello.o modules.order
[root@yang-centos hello]# insmod ./hello.ko
[root@yang-centos hello]# rmmod hello
[root@yang-centos hello]#
make时上面红色的与书上的结果不一样,insmod也没有打印hello word,请问怎么回事?
|
|