- 论坛徽章:
- 2
|
因为地址空间操作的操作对象是内存,与磁盘的组织方式无关,所以这个我们可以直接使用VFS的地址空间操作,这样就简单多了
gt_aops(在inode.c中定义)
- const struct address_space_operations gt_aops ={
- .readpage =gt_readpage,
- .writepage =gt_writepage,
- .sync_page =block_sync_page,
- .write_begin =gt_write_begin,
- .write_end =generic_write_end,
- .bmap =gt_bmap,
- };
复制代码
我就直接贴代码了,这部分对于我们实现一个文件系统来说很简单,如果你想继续深入下去,可以跟踪这些函数读下去
这些函数都是在inode.c中定义实现
- static int gt_writepage(struct page *page,struct writeback_control *wbc){
- return block_write_full_page(page,gt_get_block,wbc);
- }
- static int gt_readpage(struct file *file,struct page *page){
- return block_read_full_page(page,gt_get_block);
- }
- int __gt_write_begin(struct file *file,struct address_space *mapping,loff_t pos,unsigned len,unsigned flags,struct page *pagep,void **fsdata){
- return block_write_begin(file,mapping,pos,len,flags,pagep,fsdata,gt_get_block);
- }
- static int gt_write_begin(struct file *file,struct address_space *mapping,
- loff_t pos,unsigned len,unsigned flags,struct page **pagep,void **fsdata){
- *pagep=NULL;
- return __gt_write_begin(file,mapping,pos,len,flags,pagep,fsdata);
- }
- static sector_t gt_bmap(struct address_space *mapping,sector_t block){
- return generic_block_bmap(mapping,block,gt_get_block);
- }
复制代码
地址空间操作就是这样,接下来是对目录索引节点的操作 |
|