File and Path name on the FatFs module

The format of file and path name on the FatFs module is similer to MS-DOS. However it does not have a concept of current directory like OS oriented file system. All objects on the drive are always specified in full path name from the root directory.


 "[drive#:][/]directory/file"

 "file1.txt"           A file on the drive 0
 "/file1.txt"          (same as above)
 "dir1/dir2/file1.txt" A file on the drive 0
 "2:dir3/file2.txt"    A file on the drive 2
 "2:/dir5"             A directory on the drive 2
 ""                    The root directory on the drive 0
 "/"                   (same as above)
 "2:"                  The root directory on the drive 2

The FatFs module supports long file name and 8.3 format file name. The long file name can be handled when _USE_LFN option is selected. The sub directories are separated with a / or \. Heading separator is ignored and it may be exist or omitted.

The logical drive number is specified in a numeral with a colon. When the drive number is omitted, it is assumed as default drive (0:).


Correspondence between logical/physical drive

In default, the FatFs module has work areas that called file system object for each logical drive. The logical drive is bound to the physical drive that has same drive number, and the first partition is mounted. When _MULTI_PARTITION is specified in configuration option, each individual logical drive can be bound to any physical drive/partition. In this case, a drive number resolution table must be defined as follows:

Example: Logical drive 0-2 are assigned to three pri-partitions on the physical drive 0 (fixed disk)
         Logical drive 3 is assigned to physical drive 1 (removable disk)

const PARTITION Drives[] = {
    {0, 0},     /* Logical drive 0 ==> Physical drive 0, 1st partition */
    {0, 1},     /* Logical drive 1 ==> Physical drive 0, 2nd partition */
    {0, 2},     /* Logical drive 2 ==> Physical drive 0, 3rd partition */
    {1, 0}      /* Logical drive 3 ==> Physical drive 1 */
};

There are some consideration when use _MULTI_PARTITION configuration.