在内核模式和用户模式之间使用ioctl通信

17

我想使用ioctl与我的内核模块通信。我编写了两个C程序,一个用于内核模块,另一个用于用户模式。在编译内核模块时,我遇到了以下错误:

错误:在初始化器中指定了未知字段“ioctl”

出错的代码行如下:

struct file_operations Fops = {
 .read = device_read,
 .write = device_write,
 .ioctl = device_ioctl,  ------> at this point error is occuring.
 .open = device_open,
 .release = device_release,
};

有什么想法为什么会发生这种情况。

谢谢

2个回答

23

在新的内核中,首选的方法是使用 .unlocked_ioctl.compat_ioctl 字段。纯粹的 .ioctl 已经从 struct file_operations 中移除了。 这个讨论 可以澄清发生了什么以及如何处理。


4

在较新的内核中,使用 .unlocked_ioctl 替代 .ioctl。它可以很好地工作。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接