问题描述
静态const struct inode_operations msdos_dir_inode_operations = {
static const struct inode_operations msdos_dir_inode_operations = {
.create = msdos_create,
.lookup = msdos_lookup,
.unlink = msdos_unlink,
.mkdir = msdos_mkdir,
.rmdir = msdos_rmdir,
.rename = msdos_rename,
.setattr = fat_setattr,
.getattr = fat_getattr,
.compat_ioctl = my_ioctl, ---->error
};
我也尝试使用unlocked_ioctl,但是发生了相同的错误
i also tried with unlocked_ioctl but same error occured
[root @ localhost fat]#make
[root@localhost fat]# make
make -C/lib/modules/3.11.10-100.fc18.x86_64/build M =/home/aditya/linux-3.12.6/fs/fat模块
make -C /lib/modules/3.11.10-100.fc18.x86_64/build M=/home/aditya/linux-3.12.6/fs/fat modules
make [1]:进入目录`/usr/src/kernels/3.11.10-100.fc18.x86_64' CC [M]/home/aditya/linux-3.12.6/fs/fat/namei_msdos.o
make[1]: Entering directory `/usr/src/kernels/3.11.10-100.fc18.x86_64' CC [M] /home/aditya/linux-3.12.6/fs/fat/namei_msdos.o
/home/aditya/linux-3.12.6/fs/fat/namei_msdos.c:646:2:错误:初始化程序中指定了未知字段"compat_ioctl"
/home/aditya/linux-3.12.6/fs/fat/namei_msdos.c:646:2: error: unknown field ‘compat_ioctl’ specified in initializer
/home/aditya/linux-3.12.6/fs/fat/namei_msdos.c:646:2:警告:从不兼容的指针类型进行初始化[默认启用]/home/aditya/linux-3.12.6/fs/fat/namei_msdos.c:646:2:警告:(在"msdos_dir_inode_operations.setxattr"附近初始化)[默认情况下启用]make [2]: * [/home/aditya/linux-3.12.6/fs/fat/namei_msdos.o]错误1make [1]:* [模块/home/aditya/linux-3.12.6/fs/fat]错误2make [1]:离开目录`/usr/src/kernels/3.11.10-100.fc18.x86_64'make: * [all]错误2
/home/aditya/linux-3.12.6/fs/fat/namei_msdos.c:646:2: warning: initialization from incompatible pointer type [enabled by default]/home/aditya/linux-3.12.6/fs/fat/namei_msdos.c:646:2: warning: (near initialization for ‘msdos_dir_inode_operations.setxattr’) [enabled by default]make[2]: * [/home/aditya/linux-3.12.6/fs/fat/namei_msdos.o] Error 1make[1]: * [module/home/aditya/linux-3.12.6/fs/fat] Error 2make[1]: Leaving directory `/usr/src/kernels/3.11.10-100.fc18.x86_64'make: * [all] Error 2
推荐答案
已经更改了ioctl是有原因的,最好也遵循驱动程序中的内核更改.您不能使用为一个版本编译的驱动程序.改变不是太困难的一项.
The ioctl has been changed for a reason and it would be best if you follow the kernel changes in your driver too. You can not use drivers compiled for one version in another. The change is not too difficult one.
在Fops结构中更改
ioctl
至unlocked_ioctl
以及驱动程序的ioctl函数中,请勿传递inode
指针.就是说,其余的代码可以保持不变.
and in the ioctl function in your driver, do not pass the inode
pointer. That is all, the rest of the code can remain the same.
有关更多详细信息,请参见本教程
see this tutorial for more details
这篇关于"错误:在初始化程序“"中指定了未知字段"compat_ioctl"在创建虚拟ioctl时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!