Using ioctl communication between Kernel mode and user mode

Dalchand  picture Dalchand · May 3, 2011 · Viewed 16.1k times · Source

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

Answer

Eugene picture Eugene · May 4, 2011

In newer kernels, the preferred way is to use .unlocked_ioctl or .compat_ioctl fields. The plain .ioctl was removed from struct file_operations. This discussion may clarify what happened and how to deal with that.