FAT12 FAT16 FAT32 学习

Currently there are three FAT file system types: FAT12, FAT16 and FAT32. The basic difference in these FAT
sub types, and the reason for the names, is the size, in bits, of the entries in the actual FAT
structure on the disk. There are 12 bits in a FAT12 FAT entry, 16 bits in a FAT16 FAT entry
and 32 bits in a FAT32 FAT entry. 

Contents
Notational Conventions in this Document................................................................................. 6
General Comments (Applicable to FAT File System All Types)............................................... 6
Boot Sector and BPB ................................................................................................................ 6
FAT Data Structure ................................................................................................................. 12
FAT Type Determination......................................................................................................... 13
FAT Volume Initialization ........................................................................................................ 18
FAT32 FSInfo Sector Structure and Backup Boot Sector ...................................................... 20
FAT Directory Structure .......................................................................................................... 21
Other Notes Relating to FAT Directories ................................................................................ 24
Specification Compliance........................................................................................................ 25

Notational Conventions in this Document


Numbers that have the characters “0x” at the beginning of them are hexadecimal (base 16) numbers.
Any numbers that do not have the characters “0x” at the beginning are decimal (base 10) numbers.
The code fragments in this document are written in the ‘C’ programming language. Strict typing and
syntax are not adhered to.
There are several code fragments in this document that freely mix 32-bit and 16-bit data elements. It is
assumed that you are a programmer who understands how to properly type such operations so that
data is not lost due to truncation of 32-bit values to 16-bit values. Also take note that all data types are
UNSIGNED. Do not do FAT computations with signed integer types, because the computations will
be wrong on some FAT volumes.


General Comments (Applicable to FAT File System All Types)
All of the FAT file systems were originally developed for the IBM PC machine architecture. The
importance of this is that FAT file system on disk data structure is all “little endian.” If we look at one
32-bit FAT entry stored on disk as a series of four 8-bit bytes—the first being byte[0] and the last
being byte[4]—here is where the 32 bits numbered 00 through 31 are (00 being the least significant
bit):
byte[3] 3 3 2 2 2 2 2 2
1 0 9 8 7 6 5 4
byte[2] 2 2 2 2 1 1 1 1
3 2 1 0 9 8 7 6
byte[1] 1 1 1 1 1 1 0 0
5 4 3 2 1 0 9 8
byte[0] 0 0 0 0 0 0 0 0
7 6 5 4 3 2 1 0
This is important if your machine is a “big endian” machine, because you will have to translate
between big and little endian as you move data to and from the disk.
A FAT file system volume is composed of four basic regions, which are laid out in this order on the
volume:
0 – Reserved Region
1 – FAT Region
2 – Root Directory Region (doesn’t exist on FAT32 volumes)
3 – File and Directory Data Region


Boot Sector and BPB
The first important data structure on a FAT volume is called the BPB (BIOS Parameter Block), which
is located in the first sector of the volume in the Reserved Region. This sector is sometimes called the
“boot sector” or the “reserved sector” or the “0th sector,” but the important fact is simply that it is the
first sector of the volume.
This is the first thing about the FAT file system that sometimes causes confusion. In MS-DOS version
1.x, there was not a BPB in the boot sector. In this first version of the FAT file system, there were
only two different formats, the one for single-sided and the one for double-sided 360K 5.25-inchfloppy disks. The determination of which type was on the disk was done by looking at the first byte of
the FAT (the low 8 bits of FAT[0]).
This type of media determination was superseded in MS-DOS version 2.x by putting a BPB in the
boot sector, and the old style of media determination (done by looking at the first byte of the FAT)
was no longer supported. All FAT volumes must have a BPB in the boot sector.
This brings us to the second point of confusion relating to FAT volume determination: What exactly
does a BPB look like? The BPB in the boot sector defined for MS-DOS 2.x only allowed for a FAT
volume with strictly less than 65,536 sectors (32 MB worth of 512-byte sectors). This limitation was
due to the fact that the “total sectors” field was only a 16-bit field. This limitation was addressed by
MS-DOS 3.x, where the BPB was modified to include a new 32-bit field for the total sectors value.
The next BPB change occurred with the Microsoft Windows 95 operating system, where the FAT32
type was introduced. FAT16 was limited by the maximum size of the FAT and the maximum valid
cluster size to no more than a 2 GB volume if the disk had 512-byte sectors. FAT32 addressed this
limitation on the amount of disk space that one FAT volume could occupy so that disks larger than
2 GB only had to have one partition defined.
The FAT32 BPB exactly matches the FAT12/FAT16 BPB up to and including the BPB_TotSec32
field. They differ starting at offset 36, depending on whether the media type is FAT12/FAT16 or
FAT32 (see discussion below for determining FAT type). The relevant point here is that the BPB in
the boot sector of a FAT volume should always be one that has all of the new BPB fields for either the
FAT12/FAT16 or FAT32 BPB type. Doing it this way ensures the maximum compatibility of the FAT
volume and ensures that all FAT file system drivers will understand and support the volume properly,
because it always contains all of the currently defined fields.
NOTE: In the following description, all the fields whose names start with BPB_ are part of the BPB.
All the fields whose names start with BS_ are part of the boot sector and not really part of the BPB.
The following shows the start of sector 0 of a FAT volume, which contains the BPB

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
提供的源码资源涵盖了Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 适合毕业设计、课程设计作业。这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。 所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值