io_fs_02
一切都是文件:VFS
应用层的read/write/ioctl/open
都是VFS实现的虚函数,所以内核层需要提供struct file_operations
,这样这此虚函数才可以生效。
例子1:各种字符设备驱动 需要实现struct file_operations
例子2:Block RAW设备 需要实现struct file_operations
例子3:Ext4中的file 需要实现struct file_operations
文件系统的管理
文件系统一般由以下五部分组成
Super block, stoing:
size and location of bitmaps
number and location of inodes
number and location of data blocks
index of root inodes
Bitmap of indoes
Bitmap of data blocks
Inodes table
Data blocks(4kB each)
硬链接与软链接
硬链接, inodes号和原文件indoes是一样
b.txt是a.txt的硬链接,所以在inodes table中,a.txt inodes number 等于 b.txt inodes number
软链接,也叫符号链接,inodes号和原文件indoes是不同的
b.txt是a.txt的软链接,所以在Table of inodes中,a.txt inodes number 不等于 b.txt inodes number
icache和dcache
icache, inode cache
dcache, dentry cache
用户空间的文件系统:FUSE
FUSE需要把VFS层的请求传到用户态的fuse app,在用户态处理,然 后再返回到内核态,把结果返回给VFS层;在用户态实现文件系统必 然会引入额外的内核态/用户态切换带来的开销,对性能会产生一定影响
Last updated
Was this helpful?