根据我的理解,内核维护4个表。
struct filestruct vnodestruct file有一个名为struct file_operations f_ops;的字段,它包含FS特定的操作,如ext2_read()、ext2_write();
struct vnode还有一个字段struct vnodeops v_op;,它也包含FS特定的操作。
我的问题是,为什么我们在两个系统中都有相似的功能呢?还是我搞错了?在Unix和Linux中有什么不同吗?因为我没有在Linux的fs.h中找到struct vnode
参考资料:https://www.usna.edu/Users/cs/wcbrown/courses/IC221/classes/L09/Class.html
图表(取自"Unix内部组件新前沿“一书)

发布于 2020-06-24 05:56:18
好吧,我找到答案了。
在以前版本的Unix (如SVR4 )中,struct file不包含file_operations字段和vnode->v_op包含的所有操作(如读、写等)。
但是,在Linux中,struct file将包含具有打开、读、写等功能的file_operations字段,而struct inode (类似于vnode)将包含具有查找、链接、unlink、符号链接、rmdir、mkdir、rename等操作的inode_operations字段。
https://unix.stackexchange.com/questions/584340
复制相似问题