FAT文件系统有两个重要的数据结构:文件分配表和目录项
There are two important data structures in FAT (the File Allocation Table and directory entries)
FAT文件系统的布局如下图
下面从上一章定义的文件系统的五个范畴来介绍:
文件系统范畴(file system category),主要是保留区的boot sector
1. Reserved area的起始扇区是boot sector(引导扇区,也可称为VBR),其中包含文件系统范畴的数据,比如每簇的大小、保留区的长度、FAT表的个数等。
2. 除了数据,和MBR一样,VBR同样包含boot code,但由于代码较长,因此boot sector只保存了几个字节的跳转指令,引导操作系统跳转到更大的空间执行更长的代码。
(The FAT boot code is called from the boot code in the MBR of the disk, and the FAT boot code locates and loads the appropriate OS files.)
内容范畴(content category)
1. FAT 文件系统的数据单元是“簇(cluster)”,一簇由n个扇区组成,n被定义在文件系统范畴的数据中,并且n是2的幂。
(A FAT file system uses the term cluster for its data units. A cluster is a group of consecutive sectors, and the number of sectors must be a power of 2, such as 1, 2, 4, 8, 16, 32, or 64.)
2. 簇的概念被用于数据区(data area),而保留区和FAT区是不用簇来编址的,因此第一个簇的起始地址应是数据区的起始地址。
“簇”是文件系统层的单位,而“扇区”是卷层的单位,FAT文件系统是一个这两层用不同单位编址的例子。
(The FAT file system is an example where not every logical volume address has a logical file system address.)
3. FAT是用于存放每簇的分配状态的,它的下标隐含为簇号,即FAT的第 i 项记录了第 i 个簇的信息。多簇文件通过FAT来查找下一簇,就像寻宝游戏一样。
(Using the FAT to find cluster addresses is analogous to a treasure hunt. You are given clues about the location of the first site. When you get to the first site, you find a treasure and directions to the second site. This process repeats until you find the final site.)
元数据范畴(metadata category)
1. 目录项相当于更抽象一层的分配表,它记录了每个普通文件或目录文件的一些信息。
(The directory entry is a data structure that is allocated for every file and directory. )
2. 与文件分配表不同的是,目录表的下标并不表示第几个文件或目录。
(Directory entries are not given unique numerical addresses, like clusters are. Instead, the only standard way to address a directory entry is to use the full name of the file or directory that allocated it. )
3. 每个文件通过目录项与文件分配表配合共同找到文件的所有内容。
(The directory entry contains the starting cluster of the file, and the FAT structure is used to find the remaining clusters in the file.)
4. 由于每个目录项可以分给一个普通文件,也可以分给一个目录项,所以类似DOS partition的扩展分区的设计,对目录就也可进行递归展开了。
(Consider a scenario where we want to find all allocated directory entry structures. To do this, we start in the root directory and recursively look in each of the allocated directories. For each directory, we examine each 32-byte structure and skip over the unallocated ones.)
对元数据中时间值的更新规则,以及对文件名范畴的内容会在下一篇介绍