ioctl/unlocked_ioctl/compat_ioctl

来源:互联网 发布:战地1优化真的好 编辑:程序博客网 时间:2024/05/16 07:57

在kernel 2.6.35及之前的版本中struct file_opertation一共有3个ioctl:ioctl, unlocked_ioctl, compat_ioctl,

struct file_operations {        int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);        long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);        long (*compat_ioctl) (struct file *, unsigned int, unsigned long);...

在kernel 2.6.36中已经完全删除了struct file_operation中的ioctl指针,取而代之的是unlocked_ioctl。

struct file_operations {        long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);        long (*compat_ioctl) (struct file *, unsigned int, unsigned long);...

unlocked_ioctl与ioctl最大的不同是参数中少了inode,不过用户空间中ioctl对应的系统调用接口却没有变化,用户程序不需要改变。unlocked_ioctl最主要的改进是不再需要上大内核锁(调用之前不再先调用lock_kernel()然后再unlock_kernel()),内核的开发者试图朝移除大内核锁的方向努力。

compat_ioctl被用在用户空间为32位模式,而内核运行在64位模式时,这时候需要将64位转到32位。

0 0
原创粉丝点击