先插一段网上搜的
A FAT file system is composed of four different sections.
- The Reserved sectors, located at the very beginning. The first reserved sector (sector 0) is theBoot Sector (akaPartition Boot Record). It includes an area called theBIOS Parameter Block (with some basic file system information, in particular its type, and pointers to the location of the other sections) and usually contains the operating system'sboot loader code. The total count of reserved sectors is indicated by a field inside the Boot Sector. Important information from the Boot Sector is accessible through an operating system structure called theDrive Parameter Block in DOS and OS/2. For FAT32 file systems, the reserved sectors include aFile System Information Sector at sector 1 and aBackup Boot Sector at Sector 6.
- The FAT Region. This typically contains two copies (may vary) of theFile Allocation Table for the sake of redundancy checking, although the extra copy is rarely used, even by disk repair utilities. These are maps of the Data Region, indicating which clusters are used by files and directories. In FAT16 and FAT12 they immediately follow the reserved sectors.
- The Root Directory Region. This is a Directory Table that stores information about the files and directories located in the root directory. It is only used with FAT12 and FAT16, and imposes on the root directory a fixed maximum size which is pre-allocated at creation of this volume. FAT32 stores the root directory in the Data Region, along with files and other directories, allowing it to grow without such a constraint. Thus, for FAT32, the Data Region starts here.
- The Data Region. This is where the actual file and directory data is stored and takes up most of the partition. The size of files and subdirectories can be increased arbitrarily (as long as there are free clusters) by simply adding more links to the file's chain in the FAT. Note however, that files are allocated in units of clusters, so if a1 kB file resides in a32 kB cluster,31 kB are wasted. FAT32 typically commences the Root Directory Table in cluster number 2: the first cluster of the Data Region.
FAT uses little endian format for entries in the header and the FAT(s). It is possible to allocate more FAT sectors than necessary for the number of clusters. The end of the last FAT sector can be unused if there are no corresponding clusters. The total number of sectors (as noted in the boot record) can be larger than the number of sectors used by data (clusters × sectors per cluster), FATs (number of FATs × sectors per FAT), and hidden sectors including the boot sector — this would result in unused sectors at the end of the volume. If a partition contains more sectors than the total number of sectors occupied by the file system it would also result in unused sectors at the end of the volume.
下面是我的理解:
文件和目录是由一个个链组成的。我们由链的开头能够找到链尾,这样就能够拼成一个完整的文件,那么链头放在哪里呢?
毫无疑问,链头是放在数据区Data Region,那么我们怎么要找到链头放在哪个簇里面呢?
答案就在Root Director里面,在Root Director里保存了每个文件和目录的信息,其中包括了一个标志位用来记录文件的起始簇号,这样我们就可以知道文件的链头放在数据区的什么位置了,进而我们可以通过FAT区来访问链表,寻找到第二个簇,第三个簇……直到找到标志为0xFF就是文件的结尾了。
好了,一个的文件就这样被我们拼出来了,为什么说是拼出来呢?
因为一个文件在数据区Data Region里面保存是不连续的,而是分散保存在数据区内的。