Access 64-bit driver's ioctl from 32-bit Application
If you try to access
ioctls of 64-bit driver from your 32-bit application, it will fail with Error
-ENOTTY. This is because the value of
IOCTL Command will be different when the application is compiled for 32-bit and
64-bit.
In order for 32-bit
application, you need to define .compat_ioctl in your file_operations
structure.
When you call the
ioctl(fd, IOCTL_COMMAND, &arg) from a 32-bit application on a 64-bit
kernel, the kernel will divert the ioctl to the .compat_ioctl function in the
file_operations struct.
.unlocked_ioctl is
used when 64-bit application accesses 64-bit kernel.
static struct
file_operations driver_fops =
{
.owner = THIS_MODULE,
.open = my_open,
.release = my_close,
.compat_ioctl = my_ioctl
.unlocked_ioctl = my_ioctl
};
Comments
Post a Comment