How is an ioctl call called from user space? Anyone please give some examples?

Suppose I have defined the following.

#define MY_IOCTL_CMD1 _IOR(MAGIC_NUMBER, 0x01, arg1)
#define MY_IOCTL_CMD2 _IOW(MAGIC_NUMBER, 0x02, arg2)
#ifdef CONFIG_COMPAT
#define MY_COMPAT_IOCTL_CMD1 _IOR(MAGIC_NUMBER, 0x01, compat_arg1)
#define MY_COMPAT_IOCTL_CMD2 _IOW(MAGIC_NUMBER, 0x02, compat_arg2)
#endif

Now when we do ioctl from user space, we usually do

ioctl(fd, MY_IOCTL_CMD1, &arg1)

Q: Do we need to have ioctl with MY_COMPAT_IOCTL_CMD1as request?

In the division code, I have handlers defined as follows. ioctl: device_ioctl

#ifdef CONFIG_COMPAT
compat_ioctl: device_compat_ioctl
#endif

Can someone explain some clarifications?

+5
source share
1 answer

32- 64- . ioctl(fd, MY_IOCTL_CMD1, &arg1) 32- 64- , ​​ ioctl .compat_ioctl file_operations. compat_ioctl arg1, compat_arg1, 32- . compat_arg1 typedef , 64- , arg1, 32-.

MY_IOCTL_CMD1 sizeof arg1 id cmd. 32- , MY_IOCTL_CMD1 , 64- . 32- MY_IOCTL_CMD1 , 64- MY_COMPAT_IOCTL_CMD1 .

compat_arg1 MY_COMPAT_IOCTL_CMD1 . , .

+6

All Articles