Linux+2.6.17.9内核文件系统调用详解.docVIP

  • 2
  • 0
  • 约7.91千字
  • 约 6页
  • 2016-02-25 发布于江苏
  • 举报
Linux+2.6.17.9内核文件系统调用详解.doc

Linux 2.6.17.9内核文件系统调用详解 本部分主要讲述的是文件I/O操作的2.6.17.9内核版本实现,包括了主要的数据结构、宏定义和函数流程。以下分别讲述open,create,close,read,write,lseek系统调用。 1 重要数据结构 1.1 struct file struct file { ? ? /* ? ? * fu_list becomes invalid after file_free is called and queued via ? ? * fu_rcuhead for RCU freeing ? ? */ ? ? union { ? ? ? ? struct list_head? ? fu_list; //文件链表指针 ? ? ? ? struct rcu_head? ? fu_rcuhead; //rcu链表 ? ? } f_u; ? ? struct dentry? ? ? ? *f_dentry; // 文件对应的目录结构 ? ? struct vfsmount? ? ? ? *f_vfsmnt; // 虚拟文件系统挂载点 ? ? const struct file_operations? ? *f_op; // 文件操作函数指针 ? ? atomic_t? ? ? ? f_count; // 引用计数 ? ? unsigned int? ? ? ? f_flags; ? ? mode_t? ? ? ? ? ? f_mode; // 文件模式 ? ? loff_t? ? ? ? ? ? f_pos; // 文件offset ? ? struct fown_struct? ? f_owner; //文件owner 结构 ? ? unsigned int? ? ? ? f_uid, f_gid;//文件用户id,组id ? ? struct file_ra_state? ? f_ra; // 跟踪上次文件操作状态的结构指针 ? ? unsigned long? ? ? ? f_version; ? ? void? ? ? ? ? ? *f_security; // hook 文件操作的security结构指针 ? ? /* needed for tty driver, and maybe others */ ? ? void? ? ? ? ? ? *private_data; // tty 驱动器所需数据 #ifdef CONFIG_EPOLL ? ? /* Used by fs/eventpoll.c to link all the hooks to this file */ ? ? struct list_head? ? f_ep_links; // EPOLL 机制检测所需链表结构 ? ? spinlock_t? ? ? ? f_ep_lock; // 兼容早期gcc bug 的标志 #endif /* #ifdef CONFIG_EPOLL */ ? ? struct address_space? ? *f_mapping; // 地址映射表 }; 1.2 struct fown_struct struct fown_struct { ? ? rwlock_t lock;? ? ? ? ? /* protects pid, uid, euid fields */ ? ? int pid;? ? ? ? /* pid or -pgrp where SIGIO should be sent */ ? ? uid_t uid, euid;? ? /* uid/euid of process setting the owner */ ? ? void *security; /*hook 文件操作的security结构指针*/ ? ? int signum;? ? ? ? /* posix.1b rt signal to be delivered on IO */ }; 1.3 struct file_ra_state /* * Track a single files readahead state */ struct file_ra_state { ? ? unsigned long start;? ? ? ? /* Current window */ ? ? unsigned long size; ? ? unsigned long flags;? ? ? ? /* ra flags RA_FLAG_xxx*/ ? ? unsigned long cache_hit;? ? /* cache hit count*/ ? ? unsigned long pr

文档评论(0)

1亿VIP精品文档

相关文档