0

我想捕获 pipe() 系统调用,所以我更改了 pipe.c 中的源代码

static pipe_hook_t pipe_hook;
pipe_hook_t set_pipe_hook(pipe_hook_t hook)
{
    pipe_hook_t old_hook = pipe_hook;
    pipe_hook = hook;
    printk(KERN_INFO, "pipe hook: %p", hook);
    return old_hook;
}

EXPORT_SYMBOL_GPL(set_pipe_hook); 

然后我尝试在文件 syscalls.h 中定义 pipe_hook_t(包含在 pipe.c 中)

typedef void (*pipe_hook_t)(int *filedes);
pipe_hook_t set_pipe_hook(pipe_hook_t hook);

我有错误:

fs/pipe.c:1130: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘pipe_hook’
fs/pipe.c:1131: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘set_pipe_hook’
fs/pipe.c:1138: error: ‘set_pipe_hook’ undeclared here (not in a function)
fs/pipe.c:1138: warning: type defaults to ‘int’ in declaration of ‘set_pipe_hook’
fs/pipe.c: In function ‘sys_pipe2’:
fs/pipe.c:1153: error: ‘pipe_hook’ undeclared (first use in this function)
fs/pipe.c:1153: error: (Each undeclared identifier is reported only once
fs/pipe.c:1153: error: for each function it appears in.)
fs/pipe.c:1154: error: implicit declaration of function ‘pipe_hook’

我试图创建自己的 .h 文件并在那里定义 pipe_hook_t 但错误是一样的

4

1 回答 1

0

Problem has been solved. I've just confused directory where header files are.

于 2013-04-08T14:57:36.930 回答