HFS+文件系统与网络栈深度解析
1. HFS+文件系统基础
HFS+是OS X和iOS的原生文件系统格式,其底层数据结构是B - Tree,文件系统使用多个B - Tree来存储主目录、文件范围、文件属性和元数据。
1.1 B - Tree键格式
B - Tree键由温度和文件ID(即热点文件的CNID)组成,其键格式如下:
struct HotFileKey {
u_int16_t keyLength; /* length of key, excluding this field */
u_int8_t forkType; /* 0 = data fork, FF = resource fork */
u_int8_t pad; /* make the other fields align on 32-bit boundary */
u_int32_t temperature; /* temperature recorded - set to HFC_LOOKUPTAG */
u_int32_t fileID; /* file ID */
};
实际的热点文件数据结构在 hfs_hotfiles.c
中实现,以尽可能保证其私有性。
1.2 分配文件
分配文件是一个较大但不可访问的文件,用于跟踪卷中的所有块。它被设计为一个简