在linux 3.2下写了一个通过修改receive_buf系统函数截获键盘敲击的驱动模块,遇到个问题请指教

用到的系统结构如下:struct tty_struct {
……
struct tty_ldisc *ldisc;
……
}
struct tty_ldisc{
struct tty_ldisc_ops *ops;

……
}
struct tty_ldisc_ops{
……

……
}
在进行如下操作时:tty->ldisc->ops时,对模块make后没有错误,但是在insmod时出错,提示->ops为空指针,但是结构里确实有这个变量啊 请大神解释一下,还有关于替换receive_buf进行键盘记录截获也可以发表些观点,不吝赐教。

你用的是指针,一般的步骤应该是:
应该是定义--初始化--使用
#include <mallco.h>
struct tty_struct *tty; --定义
tty =(struct tty_struct *) malloc( sizeof( tty_struct )); --初始化
tty->ldisc->ops --使用
free(tty);
温馨提示:答案为网友推荐,仅供参考
相似回答