2)如果是64位的用户程序运行在64位的kernel上,调用的是unlocked_ioctl,如果是32位的用户程序运行在32位的kernel上,调用的也是unlocked_ioctl。 3. struct file_operations结构体 structfile_operations{structmodule*owner;loff_t(*llseek)(structfile*,loff_t,int);ssize_t(*read)(structfile*,char__user*,size...
其实ioctl与unlocked_ioctl所对应的系统调用都是ioctl。但是在应用层调用ioctl的时候,对于我们实现ioctl或者unlocked_ioctl有什么不同呢?这里我们可以追溯一下ioctl系统调用代码的执行过程,这里我简单的写出这个系统调用对于设备驱动(一般是设备驱动使用ioctl)的执行顺序:(fs/ioctl.c) SYSCALL_DEFINE3(ioctl, unsigned int,...
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); int (*mmap) (struct file *, struct vm_area_struct *); int (*open...
SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, unsigned long, arg)--->do_vfs_ioctl--->vfs_ioctl 而ioctl与unlocked_ioctl的区别就体现在了这个vfs_ioctl中,我们先来看ioctl被删除前的函数: /** *vfs_ioctl-callfilesystem specific ioctl methods *@filp:open filetoinvoke ioctl method...
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); long (*compat_ioctl) (struct file *, unsigned int, unsigned long); int (*mmap) (struct file *, struct vm_area_struct *); int (*open) (struct inode *, struct file *); ...
struct proc_dir_entry *pde = PDE(file_inode(file)); long rv = -ENOTTY; if (use_pde(pde)) { typeof_member(struct file_operations, unlocked_ioctl) ioctl; typeof_member(struct proc_ops, proc_ioctl) ioctl; ioctl = pde->proc_fops->unlocked_ioctl; ioctl = pde->proc_ops->proc_ioctl...
staticconststructfile_operationssocket_file_ops= { .owner = THIS_MODULE, .llseek = no_llseek, .read_iter = sock_read_iter, .write_iter = sock_write_iter, .poll = sock_poll, .unlocked_ioctl = sock_ioctl, #ifdef CONFIG_COMPAT
static int a3_module_release(struct inode *, struct file *); static long a3_module_ioctl(struct file *, unsigned int cmd, long unsigned int param); static struct file_operations a3_module_fo = { .owner = THIS_MODULE, .unlocked_ioctl = a3_module_ioctl, ...
int (*readdir) (struct file *, void *, filldir_t); unsigned int (*poll) (struct file *, struct poll_table_struct *); int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long); long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); ...
(structfile *,char__user *,size_t,loff_t*);staticssize_ta3_module_write(structfile *,constchar__user *,size_t,loff_t*);staticinta3_module_release(structinode *,structfile *);staticlonga3_module_ioctl(structfile *,unsignedintcmd,longunsignedintparam);staticstructfile_operationsa3_module_...