当前位置: 技术问答>linux和unix
模块调试的入门问题
来源: 互联网 发布时间:2016-01-11
本文导语: #define MODULE #include #include #include #include MODULE_LICENSE("GPL"); int my_init(void) { printk("current process is %s (pid %i)n",current->comm,current->pid); } void my_cleanup(void) { printk("bye"); } module_init(my_init); module_exit(my_cleanup); gcc -c hell...
#define MODULE
#include
#include
#include
#include
MODULE_LICENSE("GPL");
int my_init(void)
{
printk("current process is %s (pid %i)n",current->comm,current->pid);
}
void my_cleanup(void)
{
printk("bye");
}
module_init(my_init);
module_exit(my_cleanup);
gcc -c hello.c
的时候出现了一堆错误
主要是找不到current.h文件什么的
而我找了一下,只在/usr/src/include/下有
请问,如果要读取current的内容,程序该怎么改?
我的内核版本是2.4.20-8
已经和gcc一致了
初学者,虚心向大家请教
先谢谢大家了!
#include
#include
#include
#include
MODULE_LICENSE("GPL");
int my_init(void)
{
printk("current process is %s (pid %i)n",current->comm,current->pid);
}
void my_cleanup(void)
{
printk("bye");
}
module_init(my_init);
module_exit(my_cleanup);
gcc -c hello.c
的时候出现了一堆错误
主要是找不到current.h文件什么的
而我找了一下,只在/usr/src/include/下有
请问,如果要读取current的内容,程序该怎么改?
我的内核版本是2.4.20-8
已经和gcc一致了
初学者,虚心向大家请教
先谢谢大家了!
|
module_init, module_exit??
2.4内核好象用的是init_module和cleanup_module吧??
2.4内核好象用的是init_module和cleanup_module吧??
|
你要用模块化编译,不能用gcc直接编译
推荐一个gcc -c -D__KERNEL__ -DMODULE -O2 -c *.c ...
推荐一个gcc -c -D__KERNEL__ -DMODULE -O2 -c *.c ...