Technical information
© Jean Louis-Guérin – V1.2a – September 2014 Page 60 / 69
10.6.5 Position of the Structures in a DOS Partition
The position of the Boot Sector P
BS
(the beginning of a logical partition) is directly given in the
Master Boot Record or in an Extended Master Boot Record
The position of the first FAT P
FAT1
is equal to the position of the boot sector plus the number of
reserved sector:
P
FAT1
= P
BS
+ RES
The position of the second FAT P
FAT2
is equal to the position of the P
FAT1
plus the size of the FAT:
P
FAT2
= P
FAT1
+ SPF
The position of the Root Directory P
RD
is equal to the position of P
FAT2
plus the size of the FAT:
P
RD
= P
FAT2
+ SPF
The position of the first data cluster P
DATA
is equal to the position of the Root Directory plus the
size of the Root Directory:
P
DATA
= P
RD
+ NDIRS * (32/512)
The Size of the data region = Number of Clusters * Sectors per Cluster
10.6.6 DOS/FAT Long file names
Long File Names (LFN) are stored on a FAT file system using a trick—adding (possibly multiple)
additional entries into the directory before the normal file entry. When using LFN the DOS/FAT file
system is often referred as DOS/VFAT file system. The additional entries are marked with the Volume
Label, System, Hidden, and Read Only attributes (yielding 0x0F attribute), which is a combination that
is not expected in the MS-DOS environment, and therefore ignored by MS-DOS programs and third-
party utilities. Notably, a directory containing only volume labels is considered as empty and is allowed
to be deleted; such a situation appears if files created with long names are deleted from plain DOS.
Older versions of PC-DOS mistake LFN names in the root directory for the volume label, and are likely
to display an incorrect label.
Each fake entry can contain up to 13 UTF-16 characters (26 bytes) by using fields in the record which
contain file size or time stamps (but not the starting cluster field, for compatibility with disk utilities, the
starting cluster field is set to a value of 0. See 8.3 filename for additional explanations). Up to 20 of
these 13-character entries may be chained, supporting a maximum length of 255 UTF-16 characters.
After the last UTF-16 character, a 0x00 0x00 is added. Other not used characters are filled with 0xFF
0xFF.
LFN entries use the following format:
Byte Offset
Length
Description
0x00
1
Sequence Number
0x01
10
Name characters (five UTF-16 characters)
0x0b
1
Attributes (always 0x0F)
0x0c
1
Reserved (always 0x00)
0x0d
1
Checksum of DOS file name
0x0e
12
Name characters (six UTF-16 characters)
0x1a
2
First cluster (always 0x0000)
0x1c
4
Name characters (two UTF-16 characters)
If there are multiple LFN entries, required to represent a file name, firstly comes the last LFN entry (the
last part of the filename). The sequence number here also has bit 7 (0x40) checked (this means the
last LFN entry. However it's the first entry got when reading the directory file). The last LFN entry has
the biggest sequence number which decreases in following entries. The first LFN entry has sequence
number 1. Bit 8 (0x80) of the sequence number is used to indicate that the entry is deleted.
For example if we have filename "File with very long filename.ext" it would be formatted like this:
Sequence number
Entry data
0x43
"me.ext"
0x02
"y long filena"
0x01
"File with ver"
???
Normal 8.3 entry