在实现驱动函数的时候,编译出现:unknown field ‘ioctl’ specified in initializer
原因是:在2.6.36内核上file_operations结构体发生了重大的改变,在kernel 2.6.36 中已经完全删除了struct file_operations 中的ioctl 函数指针,取而代之的是unlocked_ioctl 和compat_ioctl。
2.6.36版本以前
int (*ioctl)(struct inode*, struct file*, unsigned int, unsigned long);
2.6.36版本以后
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
例子:
static struct file_operations hello_flops = {
.owner = THIS_MODULE,
.open = hello_open,
.write = hello_write,
.unlocked_ioctl = hello_ioctl,
// .release= hello_release,
};