ext2文件系统的核心数据结构

原创
2021/03/26 14:52
阅读数 253

0x01 信息类

主要定义在ext2.h头文件中。

名称 意义
struct ext2_inode 磁盘上inode的布局,用来读出和写入inode。可以根据此inode生成VFS对应的标准inode。
struct ext2_super_block 对应磁盘上实际的ext2的超级块,可以转换为VFS的标准超级块,同上用来表示ext2的特有信息。一个文件系统只有一个,可以有多个备份。
struct struct ext2_sb_info 同样是用来扩展超级块的。
struct ext2_dir_entry/struct ext2_dir_entry_2 目录项。_2后缀的表示是新版本的,两者通过对name_len后未使用的8bit实现兼容。
struct ext2_inode_info 扩展的inode。ext2_inode中的某些信息VFS中标准的inode不能存放,但其提供了扩展手段。ext2_node_info就是用来扩展保存这些额外信息的。
struct ext2_reserve_window 块分配实现中关于预留窗口的信息。
struct ext2_reserve_window_node 预留窗口的红黑树节点。
struct ext2_block_alloc_info 块分配信息。

1.1 问题

  1. 为什么要有两种类型,内存的和磁盘的?

磁盘上数据之间的相互索引基准为block id,即块id。而在程序运行时,计算机中的信息都是保存在内存中,相互引用的基准是内存地址。在信息保存和读取时,做要一次转换,所以有两种类型。一种对应磁盘中的信息,在读写时用到;另外一种是内存中的信息,在处理信息时用到。

0x02 方法类

方法类是按照VFS要求定义一些方法集合,可以理解为钩子函数。

名称 意义
struct file_operations ext2_dir_operations ext2中对目录的操作方法集合。
struct inode_operations ext2_file_inode_operations 文件inode的操作方法集合,修改文件的属性,
struct file_operations ext2_file_operations 文件操作方法集合。
struct iomap_ops ext2_iomap_ops iomap处理方法集合,进行内存映射。
struct address_space_operations ext2_aops 地址空间处理,还有个nobh的版本。
struct inode_operations ext2_dir_inode_operations 目录inode操作方法集合。
struct inode_operations ext2_special_inode_operations 特殊类型inode的操作方法集合。
struct inode_operations ext2_symlink_inode_operations 链接类型inode的操作方法集合。
struct super_operations ext2_sops 超级块的操作方法集合。
struct file_system_type ext2_fs_type 文件系统类型的注册结构。
展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
0 评论
0 收藏
0
分享
返回顶部
顶部