|
我的内核模块很简单,就是截获mkdir系统调用,在创建目录之前打印出系统调用号,编译通过了,可是执行时出错,错误信息如下:
test.o:unresolved symbol sys_call_table
test.o:
Hint:You are trying to load a module without a GPL compatible license and it has unresolved symbols.Contact the module supplier for assistance only they can help you.
我的源代码如下,请高手给于指点,谢谢了!我很急!!!
#define MODULE
#define __KERNEL__
#include <linux/module.h>
#include <linux/kernel.h>
#include <asm/unistd.h>
#include <linux/string.h>
#include <linux/fs.h>
#include <linux/slab.h>
extern void *sys_call_table[];
int (*old_mkdir)(const char *path);
int hacked_mkdir(const char *path)
{
printk("This is a hacked program!-->syscall number is:%d\n",__NR_mkdir);
return old_mkdir(path);
}
int init_module(void)
{
old_mkdir=sys_call_table[sys_mkdir];
sys_call_table[sys_mkdir]=(void *)hacked_mkdir;
return 0;
}
void cleanup_module(void)
{
sys_call_table[sys_mkdir]=(void *)old_mkdir;
} |
|