User:Mercury0x000d
Hey there! I'm Mercury, longtime computer enthusiast and creator/primary coder of the Night Kernel. This is my sandbox to flesh out ideas on which I'm working.
Filesystems |
---|
Virtual Filesystems |
Disk Filesystems |
CD/DVD Filesystems |
Network Filesystems |
Flash Filesystems |
This page or section is a work in progress and may thus be incomplete. Its content may be changed in the near future. |
MFAT
That's right, it's Mercury's FAT file system! It's similar to exFAT, but slimmed down and simpler. In a way, FAT-based file systems are a great choice for solid state drives since fragmentation doesn't add to the overall load time of the file.
Features
- Very low overhead
- Minimal wasted drive space
- Long filename support
Differences from exFAT
- exFAT stores the case given to a file but internally ignores case when matching filenames, but MFAT honors case exactly as presented, eliminating the need for an upcase table.
- MFAT uses the traditional method of determining free sectors by walking the FAT as opposed to using a volume allocation bitmap.
- No 0x55AA signature at the end of the boot partition. Since regular FAT drivers should verify this signature prior to attempting to parse the file system structures, this is done to signify that they should not attempt to process an MFAT file system.
Partition Layout
Section | Contents | Offset (sector number) | Size (in sectors) |
---|---|---|---|
Main Boot Region | Boot Sector | 0 | 1 |
Extended Boot Sectors | 1 | 8 | |
Reserved sectors | 10 | 1 | |
FAT Region | First FAT | FATOffset | FATLength |
Second FAT | FATOffset + FATLength | FATLength * (NumberOfFATs - 1) | |
Data Region | Cluster Heap | ClusterheapOffset | ClusterCount * 2SectorsPerClusterShift |
Excess Space (to end of partition or disk) | ClusterheapOffset + ClusterCount * 2SectorsPerClusterShift | VolumeLength - (ClusterHeapOffset + ClusterCount * 2SectorsPerClusterShift) |
Structures
Boot Sector Structure
Offset | Size | Name | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
0x000 | 3 | JumpBoot | Jump instruction to start of boot code. For x86 CPUs, the byte sequence is usually EB 76 90. | |||||||||
0x003 | 8 | FileSystemName | The "MFAT " signature. | |||||||||
0x00B | 53 | MustBeZero | This range of bytes is set null to help existing FAT drivers from mistakenly parsing an MFAT partition under the assumption that it contains valid FAT16 or FAT32 data. | |||||||||
0x048 | 8 | VolumeSize | The total number of sectors in this MFAT partition. | |||||||||
0x050 | 4 | FATOffset | Offset in sectors from the start of the partition to the first FAT | |||||||||
0x054 | 4 | FATSize | Number of sectors in each FAT. | |||||||||
0x058 | 4 | ClusterHeapOffset | Offset in sectors from the start of the partition to the start of the Cluster Heap, where files and folders live. | |||||||||
0x05C | 4 | ClusterHeapSize | The total number of clusters in the Cluster Heap. | |||||||||
0x060 | 4 | RootDirectoryChain | The starting cluster of the root directory's cluster chain. Usually, but not necessarily, zero. | |||||||||
0x064 | 4 | VolumeSerialNumber | A serial number for this partition. | |||||||||
0x068 | 1 | Revision | Specifies the version of MFAT specification to which the structures in this partition adhere. | |||||||||
0x06A | 4 | VolumeFlags |
| |||||||||
0x06C | 1 | BytesPerSectorShift | The number of places one would need to shift to translate bytes to sectors or sectors to bytes. Serves as an assist to allow shifting instead of multiplication or division. | |||||||||
0x06D | 1 | SectorsPerClusterShift | Similar to the above, except used to calculate sectors per cluster. | |||||||||
0x06F | 1 | DriveSelect | Similar to the Drive Number field found at offset 0x24 in previous FAT versions. Usually 0x80 for hard disks. | |||||||||
0x070 | 1 | PercentInUse | Percent of clusters in the Cluster Heap which are allocated, rounded down to the nearest whole number. | |||||||||
0x071 | 7 | Reserved | Do not use | |||||||||
0x078 | 390 | BootCode | Boot code pointed to by the initial jump instruction at the beginning of the structure |
Extended Boot Sectors Structure
Offset | Size | Name | Description |
---|---|---|---|
0x00 | 2BytesPerSectorShift - 4 | ExtendedBootCode | Additional space for boot code. |
2BytesPerSectorShift - 4 | 4 | ExtendedBootSignature | A series of bytes (0x00, 0x00, 0x55, 0xAA) which indicates this is a proper boot sector, similar to previous FAT versions, but now a 32-bit value instead of 16-bit. Should be verified prior to depending on any other fields in the Extended Boot Sector. Note that this signature will appear on each of the Extended Boot Sectors. |
FAT Region Structure
Offset | Size | Name | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0x00 | 4 | FatEntry[0] | Comprised of a Media Descriptor byte (always 0xF8) followed by three bytes of 0xFF each | ||||||||||
0x04 | 4 | FatEntry[1] | Always 0xFFFFFFFF. Do not use, interpret, or change. | ||||||||||
0x08 | 4 | FatEntry[2] | One of the following:
These are identical to the values used in previous FAT versions, with the difference that 0x00000001, 0xFFFFFFF0 - 0xFFFFFFF6, and 0xFFFFFFF8 - 0xFFFFFFFE are no longer ascribed any significance. | ||||||||||
... | ... | ... | ... |
The Second FAT is structured identically to the first, and is only present in transaction-safe exFAT implementations.
Directory Hexdump Example
00200000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00200010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00200020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00200030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00200040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00200050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00200060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00200070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00200080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00200090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 002000A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 002000B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 002000C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 002000D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 002000E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 002000F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|