linux 驱动 --- unlocked_ioctl 与 compat_ioctl 1、compat_ioctl:支持64bit的driver必须要实现的ioctl,当有32bit的userspace application call 64bit kernel的IOCTL的时候,这个callback会被调用到。如果没有实现compat_ioctl,那么32位的用户程序在64位的kernel上执行ioctl时会返回错误:Not a typewriter 2、如果是64...
unlocked_ioctl与compat_ioctl 1、compat_ioctl:支持64bit的driver必须要实现的ioctl,当有32bit的userspace application call 64bit kernel的IOCTL的时候,这个callback会被调用到。如果没有实现compat_ioctl,那么32位的用户程序在64位的kernel上执行ioctl时会返回错误:Not a typewriter 2、如果是64位的用户程序运行在64...
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); long (*compat_ioctl) (struct file *, unsigned int, unsigned long); ... ... }; 注意: 1、compat_ioctl:支持64bit的driver必须要实现的ioctl,当有32bit的userspace application call 64bit kernel的IOCTL的时候,这个callback会...
如果没有实现compat_ioctl,那么32位的用户程序在64位的kernel上执行ioctl时会返回错误:Not a typewriter 2、如果是64位的用户程序运行在64位的kernel上,调用的是unlocked_ioctl,如果是32位的APP运行在32位的kernel上,调用的也是unlocked_ioctl
Linux刚开始只有ioctl,没有unlocked_ioctl和compat_ioctl,这时候还是大内核锁机制(BKL),后来因为大内核锁的各种争议而去掉了ioctl,增加了unlocked_ioctl,顾名思义,unlocked就是无锁,因为unlocked_ioctl没了锁,如果想要并发操作,就要在unlocked_ioctl内部实现锁。再后来,为了让32位用户程序能访问64位内核,增加了compat_...
long (*compat_ioctl) (struct file *, unsigned int, unsigned long); ... 1. 2. 3. 4. 5. 在kernel 2.6.36中已经完全删除了struct file_operation中的ioctl指针,取而代之的是unlocked_ioctl。 struct file_operations { long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); ...
#include <linux/compat.h> //否则报compat_alloc_user_space找不到 //compact_ioctl中先对arg做些处理,然后直接调用ioctl即可 long compact_ioctl(struct file *file, unsigned
... ...long(*unlocked_ioctl) (structfile *, unsignedint, unsignedlong);long(*compat_ioctl) (structfile *, unsignedint, unsignedlong); ... ... }; 注意: 1、compat_ioctl:支持64bit的driver必须要实现的ioctl,当有32bit的userspace application call 64bit kernel的IOCTL的时候,这个callback会被调...
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); long (*compat_ioctl) (struct file *, unsigned int, unsigned long); ... ... }; 1. 2. 3. 4. 5. 6. 注意: 1、compat_ioctl:支持64bit的driver必须要实现的ioctl,当有32bit的userspace application call 64bit kernel的...
从名字就可以猜测,compat_ioctl就是发生兼容性的场景下要调用的函数,事实也确实如此。 当应用层是32位程序,内核及架构是32位程序,那么驱动的unlocked_ioctl函数被调用。 当应用层是32位程序,内核及架构是64位程序,那么驱动的compat_ioctl函数被调用。 当应用层是64位程序,内核及架构是64位程序,那么驱动的unlocked_...