LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 715|回复: 0

想开始研究防火墙模块,但和搞不定helloword...

[复制链接]
发表于 2004-4-7 21:05:16 | 显示全部楼层 |阅读模式
示例模块代码如下:

---------------------------------------------------------
//It is copied from a book


#ifndef __KERNEL__
#define __KERNEL__
#endif
#ifndef MODULE
#define MODULE
#endif


#include </usr/src/linux-2.4.20-8/include/linux/kernel.h> /*We'ar doing kernel
work*/

#include </usr/src/linux-2.4.20-8/include/linux/module.h> /*Specifically a mod
ule*/



/*Deal with CONFIG_MODVERSIONS>*/



#if CONFIG_MODVERSIONS==1

#define <linux/modversions.h>

#endif



/*Initialize the module*/

int init_module()

{

printk("Hello. World _ this is the kernel speaking\n");



/* If we returned a non zero value, it means that

* init_module failed and the kernel module can't be loaded*/



return 0;

}



/*cleanup - undid whatever init_module did */

void cleanup_module()

{

printk("Short is the file of the kernel module\n");

}
-------------------------------------------------------------

编译后加载,所有信息如下
[root@qg dd]# gcc -c helloword.c
In file included from /usr/src/linux-2.4.20-8/include/linux/module.h:25,
from helloword.c:11:
/usr/include/asm/atomic.h:40:2: warning: #warning Using kernel header in userl
and program. BAD!
[root@qg dd]# /sbin/insmod ./helloword.o
./helloword.o: kernel-module version mismatch
./helloword.o was compiled for kernel version 2.4.20
while this kernel is version 2.4.20-8.

怎样做才能够加载成功啊?谢谢.:help :help :help
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表