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上,调用的是unlocke...
我们可以看到unlocked_ioctl 和 compat_ioctl这2个函数的最后一个参数是 unsigned long类型的,long类型在不同的架构下面的长度是不同的,在32位平台下是4字节,64位平台下就是8个字节,当32位的应用程序使用ioctl系统调用时,传了4个字节的参数,到驱动中,应该是8个字节,这样就产生了不兼容,为了不影响64位的应用程...
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); long (*compat_ioctl) (struct file *, unsigned int, unsigned long); 在字符设备驱动开发中,一般情况下只要实现 unlocked_ioctl 函数即可,因为在 vfs 层的代码是直接调用 unlocked_ioctl 函数。 代码语言:javascript 代码运行次数:0 运...
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); long (*compat_ioctl) (struct file *, unsigned int, unsigned long); 在字符设备驱动开发中,一般情况下只要实现 unlocked_ioctl 函数即可,因为在 vfs 层的代码是直接调用 unlocked_ioctl 函数。 // fs/ioctl.c static long vfs_ioc...
在Linux中,ioctl是一个系统调用,它允许用户空间程序与设备驱动程序进行通信。通过编写特定的ioctl命令代码,用户可以控制设备的行为,或者获取设备的状态信息。在红帽操作系统中,有一种特殊的ioctl命令称为“linux compat ioctl”,它允许用户在新的64位系统中使用32位的ioctl接口。
第5行,ioctl函数用于块设备的I/O控制。 第6行,compat_ioctl函数和ioctl函数一样,都是用于块设备的I/O控制。区别在于在64位系统上,32位应用程序的ioctl会调用compat_iotl函数。在32位系统上运行的32位应用程序调用的就是ioctl函数。 第13行,getgeo函数用于获取磁盘信息,包括磁头、柱面和扇区等信息。
compat_ioctl = compat_ptr_ioctl, }; static const struct vfio_iommu_driver_ops vfio_noiommu_ops = { .name = "vfio-noiommu", .owner = THIS_MODULE, .open = vfio_noiommu_open, .release = vfio_noiommu_release, .ioctl = vfio_noiommu_ioctl, .attach_group = vfio_noiommu_...
long (*compat_ioctl) (struct file *, unsigned int, unsigned long); 1. 2. 在字符设备驱动开发中,一般情况下只要实现 unlocked_ioctl 函数即可,因为在 vfs 层的代码是直接调用 unlocked_ioctl 函数。 AI检测代码解析 // fs/ioctl.c static long vfs_ioctl(struct file *filp, unsigned int cmd, ...
struct block_device_operations--1559-->当应用层打开一个块设备的时候被回调--1560-->当应用层关闭一个块设备的时候被回调--1562-->相当于file_operations里的compat_ioctl,不过块设备的ioctl包含大量的标准操作,所以在这个接口实现的操作很少--1567-->在移动块设备中测试介质是否改变的方法,已经过时,同样的功能...
.compat_ioctl = compat_sock_ioctl, #endif .mmap = sock_mmap, .release = sock_close, .fasync = sock_fasync, .sendpage = sock_sendpage, .splice_write = generic_splice_sendpage, .splice_read = sock_splice_read, }; 以上操作完成了struct socket、struct sock、struct file等的创建、初始化、...