error unknown field 'ioctl' specified in initializer

分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

               

在linux-2.6.36内核上加载编译驱动时,出现

 error:unknown field 'ioctl' specified in initializer

原因是:在2.6.36内核上file_operations发生了重大的改变:

原先的

  int (*ioctl)(struct inode*, struct file*, unsigned int, unsigned long);

被改为了       

   long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
        long (*compat_ioctl) (struct file *, unsigned int, unsigned long);

因而在实际驱动中,我们需要将原先的写的ioctl函数头给改成下面的unlocked_ioctl,在file_operations结构体的填充中也是一样。




error: unknown field 'ioctl' specified in initializer问题是由于2.6.36内核之后 去掉了原来的ioctl,添加两个新的成员,所以会出错

long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);

 long (*compat_ioctl) (struct file *, unsigned int, unsigned long);

 所以修改源文件中file_operations内.ioctl 改为 .compat_ioctl 即可

OK,编译通过,警告咱就忽略了


           

给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow

这里写图片描述

error: unknown field 'ioctl' specified in initializer问题是由于2.6.36内核之后 去掉了原来的ioctl,添加两个新的成员,所以会出错

long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);

 long (*compat_ioctl) (struct file *, unsigned int, unsigned long);

 所以修改源文件中file_operations内.ioctl 改为 .compat_ioctl 即可

OK,编译通过,警告咱就忽略了

猜你喜欢

转载自blog.csdn.net/hfhhgfv/article/details/84001065