How to call compat_ioctl or unlocked_ioctl?

I am trying to implement a driver for RTC (real time clock). I used the function ioctlin kernel 2.6.32. It worked fine. But when I run the same driver in kernel 3.13.0, it gave an error‘struct file_operations’ has no member named ‘ioctl’

when I changed ioctlto unlocked_ioctland compat_ioctl, compiled and modeled.

But a call ioctlin a user application does not call a ioctlfunction in a module. What function should I use in a user application to call compat_ioctlor unlocked_ioctl?

+4
source share
1 answer

Check with arguments in driver

,

static struct file_operations query_fops =
{
    .owner = THIS_MODULE,
    .open = my_open,
    .release = my_close,
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35))
    .ioctl = my_ioctl
#else
    .unlocked_ioctl = my_ioctl
#endif
};

ioctl

#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35))
static int my_ioctl(struct inode *i, struct file *f, unsigned int cmd, unsigned long arg)
#else
static long my_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
        #endif
    {
              switch(cmd){
                ....................................
                ...................................
              }
    }

, ioctl .

+7

Source: https://habr.com/ru/post/1540946/


All Articles