File System Component
Version 6.6
MDK-Professional Middleware for Devices with Flash File System
|
The FAT File System was initially used on PC operating systems such as MS-DOS and early versions of Microsoft Windows. Still, it is widely used on USB memory sticks or memory cards for file storage. It is simple, robust and offers good performance especially in embedded applications.
FAT is an acronym for File Allocation Table. This table provides the index of the files in the system and is statically allocated at the time of formatting the drive. It contains an entry for each cluster (a data storage area). The FAT's entries contain either the number of the next cluster in the file, or a marker indicating EOF (end of file), unused disk space, or other areas of the drive that are specially reserved. The drive's root directory contains the number of the first cluster of each file in the directory; the operating system traverses the FAT table, looking up the cluster number of each successive part of the file, until the end of the file is reached. Likewise, sub-directories are implemented as special files containing the directory entries of their respective files.
Since the first implementation, the maximum number of clusters of a drive has increased dramatically, and so the number of bits used to identify each cluster has grown. The versions of the FAT format are named after the number of table element bits: FAT12, FAT16, and FAT32. Each of these variants is is supported by the File System Component.
The actual FAT file system is made up of four different sections:
Section | Description |
---|---|
Boot sector | Contains machine startup code |
File Allocation Table | Contains the data region map; multiple entries might exist for redundancy purposes |
Root Directory | Stores information about the files and directories located in the root directory (FAT12/FAT16 only) |
File Data Region | Actual stored file data |
Volume label for FAT12, FAT16 or FAT32 volume must be maximum 11 characters long and cannot contain the following characters: * ? / \ | , ; : + = < > [ ] "" .
Path name format used to specify either a drive, directory or file:
Depending on the usage case, each specifier can be optional:
The table below explains how to specify either absolute or relative path.
Path name | Type | Description |
---|---|---|
\ | Absolute | Root directory |
\ .. | Absolute | Root directory |
. | Relative | Current directory |
.. | Relative | Parent directory |
M:\file.txt | Absolute | A file in root directory of the drive M0 |
M:file.txt | Relative | A file in current directory of the drive M0 |
\file.txt | Absolute | A file in the root directory of the current drive |
file.txt | Relative | A file in the current directory of the current drive |
folder1\ .. | Relative | Current directory |
File System Component is provided with the library with long (LFN) and short (SFN or 8.3) filename support. Since there is no compulsory algorithm for creating the 8.3 name from an LFN, File System Component uses convention described below.
The File System Component fully supports time stamping for files and directories. it supports:
To be able to use the time information provided by an on-chip RTC, the user application needs to implement the function fs_get_time(). The fsTime structure must be filled with the data returned from the RTC driver. If the fs_get_time() function is not implemented in the user application (which is the default), predefined time and date stamps are used.
By design, FAT carries a few limitations:
The actual FAT implementation of the File System Component has the following limitations: