struct FILE

 struct file
  struct file结构体定义在include/linux/fs.h中定义。 文件结构体代表一个打开的文件,系统中的每个打开的文件在内核空间都有一个关联的 struct file。 它由内核在打开文件时创建,并传递给在文件上进行操作的任何函数。在文件的所有实例都关闭后,内核释放这个 数据 结构。在内核创建和驱动源码中, struct file的指针通常被命名为file或filp 。如下所示:
  struct file {
  union {
  struct list_head fu_list; 文件对象链表指针linux/include/linux/list.h
  struct rcu_head fu_rcuhead; RCU(Read-Copy Update)是Linux 2.6内核中新的锁机制
  } f_u;
  struct path f_path; 包含dentry和mnt两个成员,用于确定文件路径
  #define f_dentry f_path.dentry f_path的成员之一,当前文件的dentry结构
  #define f_vfsmnt f_path.mnt 表示当前文件所在文件系统的挂载根目录
  const struct file_operations *f_op; 与该文件相关联的操作函数
  atomic_t f_count; 文件的引用计数(有多少进程打开该文件)
  unsigned int f_flags; 对应于open时指定的flag
  mode_t f_mode; 读写模式:open的mod_t mode参数
  off_t f_pos; 该文件在当前进程中的文件偏移量
  struct fown_struct f_owner; 该结构的作用是通过信号进行I/O时间通知的数据。
  unsigned int f_uid, f_gid; 文件所有者id,所有者组id
  struct file_ra_state f_ra; 在linux/include/linux/fs.h中定义,文件预读相关
  unsigned long f_version;
  #ifdef CONFIG_SECURITY
  void *f_security;
  #endif
  /* needed for tty driver, and maybe others */
  void *private_data;
  #ifdef CONFIG_EPOLL
  /* Used by fs/eventpoll.c to link all the hooks to this file */
  struct list_head f_ep_links;
  spinlock_t f_ep_lock;
  #endif /* #ifdef CONFIG_EPOLL */
  struct address_space *f_mapping;
  };
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值