資源描述:
《Linux+26179內(nèi)核文件系統(tǒng)調(diào)用詳解.doc》由會員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫。
1、Linux2.6.17.9內(nèi)核文件系統(tǒng)調(diào)用詳解本部分主要講述的是文件I/O操作的2.6.17.9內(nèi)核版本實現(xiàn),包括了主要的數(shù)據(jù)結(jié)構(gòu)、宏定義和函數(shù)流程。以下分別講述open,create,close,read,write,lseek系統(tǒng)調(diào)用。1重要數(shù)據(jù)結(jié)構(gòu)1.1structfilestructfile{??/*??*fu_listbecomesinvalidafterfile_freeiscalledandqueuedvia??*fu_rcuheadforRCUfreeing??*/??union{????structlist_head??
2、fu_list;//文件鏈表指針????structrcu_head??fu_rcuhead;//rcu鏈表??}f_u;??structdentry????*f_dentry;//文件對應(yīng)的目錄結(jié)構(gòu)??structvfsmount????*f_vfsmnt;//虛擬文件系統(tǒng)掛載點??conststructfile_operations??*f_op;//文件操作函數(shù)指針??atomic_t????f_count;//引用計數(shù)??unsignedint????f_flags;??mode_t??????f_mode;//文件模式??lof
3、f_t??????f_pos;//文件offset??structfown_struct??f_owner;//文件owner結(jié)構(gòu)??unsignedint????f_uid,f_gid;//文件用戶id,組id??structfile_ra_state??f_ra;//跟蹤上次文件操作狀態(tài)的結(jié)構(gòu)指針??unsignedlong????f_version;??void??????*f_security;//hook文件操作的security結(jié)構(gòu)指針??/*neededforttydriver,andmaybeothers*/??void?
4、?????*private_data;//tty驅(qū)動器所需數(shù)據(jù)#ifdefCONFIG_EPOLL??/*Usedbyfs/eventpoll.ctolinkallthehookstothisfile*/??structlist_head??f_ep_links;//EPOLL機(jī)制檢測所需鏈表結(jié)構(gòu)??spinlock_t????f_ep_lock;//兼容早期gccbug的標(biāo)志#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結(jié)構(gòu)指針*/??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_