欢迎来到天天文库
浏览记录
ID:51469418
大小:35.00 KB
页数:6页
时间:2020-03-25
《Linux+26179内核文件系统调用详解.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、Linux2.6.17.9内核文件系统调用详解本部分主要讲述的是文件I/O操作的2.6.17.9内核版本实现,包括了主要的数据结构、宏定义和函数流程。以下分别讲述open,create,close,read,write,lseek系统调用。1重要数据结构1.1structfilestructfile{ /* *fu_listbecomesinvalidafterfile_freeiscalledandqueuedvia *fu_rcuheadforRCUfreeing */ union{ structlist_head
2、fu_list;//文件链表指针 structrcu_head fu_rcuhead;//rcu链表 }f_u; structdentry *f_dentry;//文件对应的目录结构 structvfsmount *f_vfsmnt;//虚拟文件系统挂载点 conststructfile_operations *f_op;//文件操作函数指针 atomic_t f_count;//引用计数 unsignedint f_flags; mode_t f_mode;//文件模式 lof
3、f_t f_pos;//文件offset structfown_struct f_owner;//文件owner结构 unsignedint f_uid,f_gid;//文件用户id,组id structfile_ra_state f_ra;//跟踪上次文件操作状态的结构指针 unsignedlong f_version; void *f_security;//hook文件操作的security结构指针 /*neededforttydriver,andmaybeothers*/ void
4、 *private_data;//tty驱动器所需数据#ifdefCONFIG_EPOLL /*Usedbyfs/eventpoll.ctolinkallthehookstothisfile*/ structlist_head f_ep_links;//EPOLL机制检测所需链表结构 spinlock_t f_ep_lock;//兼容早期gccbug的标志#endif/*#ifdefCONFIG_EPOLL*/ structaddress_space *f_mapping;//地址映射表};1.2structfo
5、wn_structstructfown_struct{ rwlock_tlock; /*protectspid,uid,euidfields*/ intpid; /*pidor-pgrpwhereSIGIOshouldbesent*/ uid_tuid,euid; /*uid/euidofprocesssettingtheowner*/ void*security;/*hook文件操作的security结构指针*/ intsignum; /*posix.1brtsignaltobedeliveredonIO
6、*/};1.3structfile_ra_state/**Trackasinglefile'sreadaheadstate*/structfile_ra_state{ unsignedlongstart; /*Currentwindow*/ unsignedlongsize; unsignedlongflags; /*raflagsRA_FLAG_xxx*/ unsignedlongcache_hit; /*cachehitcount*/ unsignedlongprev_page; /*Cachelastrea
7、d()position*/ unsignedlongahead_start; /*Aheadwindow*/ unsignedlongahead_size; unsignedlongra_pages; /*Maximumreadaheadwindow*/ unsignedlongmmap_hit; /*Cachehitstatformmapaccesses*/ unsignedlongmmap_miss; /*Cachemissstatformmapaccesses*/};1.4structaddress_spa
8、cestructaddress_space{ structinode *host; /*owner:inode,block_device*/ structradix_tree_
此文档下载收益归作者所有