Chinaunix首页 | 论坛 | 博客
  • 博客访问: 376999
  • 博文数量: 48
  • 博客积分: 743
  • 博客等级: 上士
  • 技术积分: 956
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-22 13:51
文章分类

全部博文(48)

文章存档

2015年(3)

2014年(17)

2012年(23)

2011年(5)

分类: 嵌入式

2014-03-14 10:51:05

file_operation结构体在 /usr/src/linux-3.0.0.15/include/linux/fs.h定义。
以下是file_operation结构体的定义:

注:
1.linux3.0.0.15版本内核 file_operation结构体已经删除了ioctl函数,取代的是:

    long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
    long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
2.linux3.0.0.15版本内核 file_operation结构体添加
    long (*fallocate)(struct file *file, int mode, loff_t offset,loff_t len); 

  1. struct file_operations {  
  2.         struct module *owner;  
  3.             /*拥有该结构的模块的指针,一般为 THIS_MODULES*/
  4.         loff_t (*llseek) (struct file *, loff_t, int); 
  5.             /*用来修改文件当前的读写位置*/ 
  6.         ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);  
  7.             /*从设备中同步读取数据*/
  8.         ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);  
  9.             /*向设备发送数据*/
  10.         ssize_t (*aio_read) (struct kiocb *, const struct iovec *, unsigned long, loff_t);  
  11.             /*初始化一个异步的读取操作*/
  12.         ssize_t (*aio_write) (struct kiocb *, const struct iovec *, unsigned long, loff_t);  
  13.              /*初始化一个异步的写入操作*/
  14.         int (*readdir) (struct file *, void *, filldir_t);  
  15.             /*仅用于读取目录,对于设备文件,该字段为 NULL*/
  16.         unsigned int (*poll) (struct file *, struct poll_table_struct *); 
  17.             /*轮询函数,判断目前是否可以进行非阻塞的读取或写入*/
  18.         int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long); 
  19.             /*执行设备 I/O 控制命令*/ 
  20.         long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);  
  21.             /*不使用 BLK 文件系统,将使用此种函数指针代替 ioctl*/
  22.         long (*compat_ioctl) (struct file *, unsigned int, unsigned long); 
  23.             /*在 64 位系统上,32 位的 ioctl 调用将使用此函数指针代替*/
  24.         int (*mmap) (struct file *, struct vm_area_struct *);  
  25.             /*用于请求将设备内存映射到进程地址空间*/
  26.         int (*open) (struct inode *, struct file *);
  27.             /*打开*/  
  28.         int (*flush) (struct file *, fl_owner_t id);  
  29.         int (*release) (struct inode *, struct file *); 
  30.             /*关闭*/ 
  31.         int (*fsync) (struct file *, int datasync);  
  32.             /*刷新待处理的数据*/
  33.         int (*aio_fsync) (struct kiocb *, int datasync);  
  34.             /*异步 fsync*/
  35.         int (*fasync) (int, struct file *, int);  
  36.             /*通知设备 FASYNC 标志发生变化*/
  37.         int (*lock) (struct file *, int, struct file_lock *);  
  38.         ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);  
  39.             /*通常为 NULL*/
  40.         unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);  
  41.             /*在进程地址空间找到一个将底层设备中的内存段映射的位置*/
  42.         int (*check_flags)(int);  
  43.             /*允许模块检查传递给 fcntl(F_SETEL...)调用的标志*/
  44.         int (*flock) (struct file *, int, struct file_lock *);
  45.         ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int);  
  46.         ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int);  
  47.         int (*setlease)(struct file *, long, struct file_lock **);  
  48.         long (*fallocate)(struct file *file, int mode, loff_t offset,loff_t len);  //linux3.0添加
  49. };  

阅读(1935) | 评论(0) | 转发(0) |
0

上一篇:SSH登录linux相关

下一篇:ioctl命令的生成

给主人留下些什么吧!~~