FAT12 is one of FAT file system families,mostly used on 1.44MB floppy disk。express
FAT 's full name is File Allocation Systemspa
FAT12 has 4 key parts as follows:code
Boot sector:blog
Store data and code that necessary for OS or other users to use it. The data is BPB, BIOS Parameter Block。ci
regularly, BPB take 25 Bytes, some attributes :input
As you can see, in fat12, it has 512 Bytes every sector, and a cluster has ONLY one sector.it
And you can write your program into the code area of boot , for example, you can use it to create you OS with a tool--Bochs.io
FAT tables:table
FAT tables is very important.class
It take Sector 1 to Sector 18, 18 sectors totally. And it's has two copies,--FAT1, FAT2
it was splited into little entries. Every entry has 12 bits.
Why 12 bits, because 1.44MB floppy need 12 bits to address: 2^11< 1.44MB < 2^12
every 12-bit entry is one-to-one-correspondence to a cluster in data area. So it just like contents of books, which can locate to the chapters.
12 bits means a value, it has special meaning:
Root Directory Entry:
A file system must has root, FAT12 has root directories.
We know that there are two types things in a file system: 1. File, 2. Directory
So how to express and store them???
In FAT12, every directory has a sector to store it's sub-directories or files. As for the sector, if it's root directory or file(parallel to the root dir), it's stored in Root Dorectory Area. Others are stored in data area.
enery Dir or file has a entry, which is 32 bytes:
so: a dir has 16 sub-dir or files at most.
Where is the cluster of sub-dir?
A entry has attr "First Logicial Cluster", which point to the next cluster. As for a dir , it's cluster No of it's entries of sub-files, sub-dir. As for File, if it's size < 512Bytes, over. if not ,it has another cluster, and the logical cluster points to it.
(Note: A file take integer clusters)
Data Area:
The main area of data, store file/dir entries and file data.
總結:
文件系統由根目錄開始,每一個目錄/文件有一個表項,存儲了相關的信息,其中,根目錄/根文件的表項存在根目錄區,而其餘普通的則存在數據區。
對於每一個表項,佔32位,其中有第一邏輯簇號FLC,目錄的FLC指向另外一個簇,裏面存的的文件和子目錄的表項,一個目錄最多有16個子目錄和文件。文件的GLC指向的簇裏存儲了文件的內容,若是文件大於512字節,須要另外一個存,用當前簇號去FAT表中取出下一簇號便可重定位到下一簇。