当前位置: 技术问答>linux和unix
proc中钩子函数被多次调用的问题
来源: 互联网 发布时间:2016-07-23
本文导语: sprintf(tmp, "flashlog/read"); create_proc_read_entry(tmp, 0, NULL, proc_read_flashprintk, NULL); static int proc_read_flashprintk(char *page, char **start, off_t off, int cnt, int *eof, void *data) { int r = 0; r = printk_flash_read(page, 10, first_r...
sprintf(tmp, "flashlog/read");
create_proc_read_entry(tmp, 0, NULL, proc_read_flashprintk, NULL);
static int proc_read_flashprintk(char *page, char **start, off_t off, int cnt, int *eof, void *data)
{
int r = 0;
r = printk_flash_read(page, 10, first_read);
printk("$$$$read-matched!n");
*eof = 1;
return r;
}
cat /proc/flashlog/read时,发现$$$$read-matched!输出了两次。
create_proc_read_entry(tmp, 0, NULL, proc_read_flashprintk, NULL);
static int proc_read_flashprintk(char *page, char **start, off_t off, int cnt, int *eof, void *data)
{
int r = 0;
r = printk_flash_read(page, 10, first_read);
printk("$$$$read-matched!n");
*eof = 1;
return r;
}
cat /proc/flashlog/read时,发现$$$$read-matched!输出了两次。
|
是return的问题,改一下return的返回值试试。
|
把cat /proc/flashlog/read的结果弄出来看看~