当我将ioctl更改为unlocked_ioctl和compat_ioctl时,编译并模块化插入.
但是在用户应用程序中调用ioctl而不是在模块中调用ioctl函数.我必须在用户应用程序中使用什么函数来调用compat_ioctl或unlocked_ioctl?
解决方法 检查驱动程序中的参数定义结构文件 *** 作定义如
static struct file_operations query_fops ={ .owner = THIS_MODulE,.open = my_open,.release = my_close,#if (liNUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) .ioctl = my_ioctl#else .unlocked_ioctl = my_ioctl#endif};
像ioctl一样定义
#if (liNUX_VERSION_CODE < KERNEL_VERSION(2,35))static int my_ioctl(struct inode *i,struct file *f,unsigned int cmd,unsigned long arg)#elsestatic long my_ioctl(struct file *f,unsigned long arg) #endif { switch(cmd){ .................................... ................................... } }
和应用程序级别
无需进行任何修改,您可以在应用程序级别遵循ioctl的基本规则.
总结以上是内存溢出为你收集整理的linux-device-driver – 如何调用compat_ioctl或unlocked_ioctl?全部内容,希望文章能够帮你解决linux-device-driver – 如何调用compat_ioctl或unlocked_ioctl?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)