内核态和用户态之间使用ioctl通信
我想使用 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,
};
:知道为什么会发生这种情况。
谢谢
I want to communicate with my kernel module using ioctl. I have written two c program one for kernel module and other for user mode. I am getting this error while compiling kernel module:
error: unknown field ‘ioctl’ specified in initializer
at this line :
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,
};
any idea why this is happening.
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在较新的内核中,首选方法是使用
.unlocked_ioctl
或.compat_ioctl
字段。普通的.ioctl
已从struct file_operations
中删除。 此讨论可能会澄清发生了什么以及如何处理。In newer kernels, the preferred way is to use
.unlocked_ioctl
or.compat_ioctl
fields. The plain.ioctl
was removed fromstruct file_operations
. This discussion may clarify what happened and how to deal with that.在较新的内核中,使用
.unlocked_ioctl
代替.ioctl
。效果很好。In newer kernels, use
.unlocked_ioctl
in the place of.ioctl
. It works fine.