1、struct file

这个结构体定义在  linuxsource/include/linux/fs.h 中第960行左右

具体成员如下:

  1. struct file {
  2. /*
  3. * fu_list becomes invalid after file_free is called and queued via
  4. * fu_rcuhead for RCU freeing
  5. */
  6. union {
  7. struct list_head fu_list;
  8. struct rcu_head fu_rcuhead;
  9. } f_u;
  10. struct path f_path;
  11. #define f_dentry f_path.dentry
  12. #define f_vfsmnt f_path.mnt
  13. const struct file_operations *f_op;
  14. spinlock_t f_lock; /* f_ep_links, f_flags, no IRQ */
  15. #ifdef CONFIG_SMP
  16. int f_sb_list_cpu;
  17. #endif
  18. atomic_long_t f_count;
  19. unsigned int f_flags;
  20. fmode_t f_mode;
  21. loff_t f_pos;
  22. struct fown_struct f_owner;
  23. const struct cred *f_cred;
  24. struct file_ra_state f_ra;
  25.  
  26. u64 f_version;
  27. #ifdef CONFIG_SECURITY
  28. void *f_security;
  29. #endif
  30. /* needed for tty driver, and maybe others */
  31. void *private_data;
  32.  
  33. #ifdef CONFIG_EPOLL
  34. /* Used by fs/eventpoll.c to link all the hooks to this file */
  35. struct list_head f_ep_links;
  36. #endif /* #ifdef CONFIG_EPOLL */
  37. struct address_space *f_mapping;
  38. #ifdef CONFIG_DEBUG_WRITECOUNT
  39. unsigned long f_mnt_write_state;
  40. #endif
  41. };

从内核来看,每一个打开的文件都需要有一个file结构体来描述它

具体查看

http://blog.csdn.net/wangchaoxjtuse/article/details/6036684

2、struct inode

  索引节点对象由inode结构体表示,定义文件在linux/fs.h中。

linux 中每一个文件都需要有一个inode节点来描述

 

  1. struct inode {
  2.   struct hlist_node i_hash; 哈希表
  3.   struct list_head i_list; 索引节点链表
  4.   struct list_head i_dentry; 目录项链表
  5.   unsigned long i_ino; 节点号
  6.   atomic_t i_count; 引用记数
  7.   umode_t i_mode; 访问权限控制
  8.   unsigned int i_nlink; 硬链接数
  9.   uid_t i_uid; 使用者id
  10.   gid_t i_gid; 使用者id
  11.   kdev_t i_rdev; 实设备标识符
  12.   loff_t i_size; 以字节为单位的文件大小
  13.   struct timespec i_atime; 最后访问时间
  14.   struct timespec i_mtime; 最后修改(modify)时间
  15.   struct timespec i_ctime; 最后改变(change)时间
  16.   unsigned int i_blkbits; 以位为单位的块大小
  17.   unsigned long i_blksize; 以字节为单位的块大小
  18.   unsigned long i_version; 版本号
  19.   unsigned long i_blocks; 文件的块数
  20.   unsigned short i_bytes; 使用的字节数
  21.   spinlock_t i_lock; 自旋锁
  22.   struct rw_semaphore i_alloc_sem; 索引节点信号量
  23.   struct inode_operations *i_op; 索引节点操作表
  24.   struct file_operations *i_fop; 默认的索引节点操作
  25.   struct super_block *i_sb; 相关的超级块
  26.   struct file_lock *i_flock; 文件锁链表
  27.   struct address_space *i_mapping; 相关的地址映射
  28.   struct address_space i_data; 设备地址映射
  29.   struct dquot *i_dquot[MAXQUOTAS];节点的磁盘限额
  30.   struct list_head i_devices; 块设备链表
  31.   struct pipe_inode_info *i_pipe; 管道信息
  32.   struct block_device *i_bdev; 块设备驱动
  33.   unsigned long i_dnotify_mask;目录通知掩码
  34.   struct dnotify_struct *i_dnotify; 目录通知
  35.   unsigned long i_state; 状态标志
  36.   unsigned long dirtied_when;首次修改时间
  37.   unsigned int i_flags; 文件系统标志
  38.   unsigned char i_sock; 套接字
  39.   atomic_t i_writecount; 写者记数
  40.   void *i_security; 安全模块
  41.   __u32 i_generation; 索引节点版本号
  42.   union {
  43.   void *generic_ip;文件特殊信息
  44.   } u;
  45.   };

1、Linux驱动重要的数据结构的更多相关文章

  1. Linux驱动学习之常用的模块操作命令

    1.常用的模块操作命令 (1)lsmod(list module,将模块列表显示),功能是打印出当前内核中已经安装的模块列表 (2)insmod(install module,安装模块),功能是向当前 ...

  2. Linux驱动学习步骤(转载)

    1. 学会写简单的makefile 2. 编一应用程序,可以用makefile跑起来 3. 学会写驱动的makefile 4. 写一简单char驱动,makefile编译通过,可以insmod, ls ...

  3. 迅为4412开发板Linux驱动教程——总线_设备_驱动注册流程详解

    本文转自:http://www.topeetboard.com 视频下载地址: 驱动注册:http://pan.baidu.com/s/1i34HcDB 设备注册:http://pan.baidu.c ...

  4. 编写linux驱动所用到的头文件(转)

    转自:http://blog.csdn.net/lufeiop02/article/details/6448497 关于linux驱动(应用)程序头文件使用 收藏 驱动程序: #include < ...

  5. linux驱动之I2C

    include/linux/i2c.h struct i2c_msg;struct i2c_algorithm;struct i2c_adapter;struct i2c_client;struct ...

  6. linux驱动面试题目汇总

    http://blog.csdn.net/blueice8601/article/details/7666427 1.linux驱动分类 2.信号量与自旋锁 3.platform总线设备及总线设备如何 ...

  7. Linux驱动开发学习的一些必要步骤

      1. 学会写简单的makefile 2. 编一应用程序,可以用makefile跑起来 3. 学会写驱动的makefile 4. 写一简单char驱动,makefile编译通过,可以insmod, ...

  8. 【linux驱动】linux驱动总览

    欢迎转载,转载时需保留作者信息,谢谢. 邮箱:tangzhongp@163.com 博客园地址:http://www.cnblogs.com/embedded-tzp Csdn博客地址:http:// ...

  9. linux驱动之中断处理过程C程序部分

    当发生中断之后,linux系统在汇编阶段经过一系列跳转,最终跳转到asm_do_IRQ()函数,开始C程序阶段的处理.在汇编阶段,程序已经计算出发生中断的中断号irq,这个关键参数最终传递给asm_d ...

随机推荐

  1. c++ 类的静态变量

    类的静态变量作为类的一部分,但不由类的创建产生,类的销毁而消失.静态变量和全局变量一样,会在main函数结束后销毁. 类可以对静态变量的值进行改变 #pragma once class ctest { ...

  2. [Python] MySQLdb(即 MySQL-python 包)在 OS X 中安装指南

    本文参考:http://www.cnblogs.com/ifantastic/archive/2013/04/13/3017677.html 安装环境:OS X 操作系统,Python 2.7.10 ...

  3. WPF绘制矢量图形模糊的问题

    WPF默认提供了抗锯齿功能,通过向外扩展的半透明边缘来实现模糊化.由于WPF采用了设备无关单位,当设备DPI大于系统DPI时,可能会产生像素自动扩展问题,这就导致线条自动向外扩展一个像素,并且与边缘相 ...

  4. oracle的游标

    declare v_0 number; v_1 number; cursor c1 is select productordernumber from his_productorder@pro_crm ...

  5. 宏碁台式机,如何设置u盘启动

    1.按delete进入BIOS2.Authentication->Secure Boot状态改为Disabled;Boot Options->Launch CSM状态改为Always;Bo ...

  6. Logstash 父子关系 配置

    最近在使用Lostash的过程中遇到了一个问题:在一个log文件里包含两类数据,而且两类数据之间存在父子关系,那如何使用lostash的configuration实现这个需求呢 思路: 首先定义父事件 ...

  7. C++ 里大写TRUE和小写true区别

    1.C++里大写TRUE和小写true区别 true是bool型的: TRUE是int型的,VC里这个是ms自己定义的: C++规定不允许只通过返回类型不同区别两个函数 2.MFC中的”false“和 ...

  8. Spring scope

    scope用来声明IOC容器中的对象应该处的限定场景或者说该对象的存活空间,即在IOC容器在 对象进入相应的scope之前,生成并装配这些对象,在该对象不再处于这些scope的限定之后,容器通常会销毁 ...

  9. JS正则2

    正则表达式可以:•测试字符串的某个模式.例如,可以对一个输入字符串进行测试,看在该字符串是否存在一个电话号码模式或一个信用卡号码模式.这称为数据有效性验证•替换文本.可以在文档中使用一个正则表达式来标 ...

  10. Java OOP中的字符串篇

    字符串的三大特征: String 字符串常量 StringBuffer 字符串变量(线程安全) StringBuilder 字符串变量(非线程安全) 一.定义 查看 API 会发现,String.St ...