Data Recovery Software :: File systems :: FAT recovery ::
FAT Data Structures (Long File Name Directory Entries)
Long File Name Directory Entries
The standard directory entry can support names with only 8 characters in the name and 3 characters in the extension. Longer names or names that use special characters require long file name (LFN) directory entries. A file will have a normal entry in addition to any LFN entries, and the LFN entries will precede the normal entry. The LFN version of the directory entry has the fields shown in table.
The sequence number field is a counter for each entry needed to store the file name, and the first entry has a value of 1. The sequence number increases for each LFN entry until the final entry, which is a bitwise OR with the value 0x40. When two values are bitwise ORed together, the result has a 1 wherever any of the two inputs had a 1.
The LFN entries for a file are listed before the short name entry and are in reverse order. Therefore, the first entry that you will find in the directory will be the last LFN entry for the file and will have the largest sequence value. Unused characters are padded with 0xff, and the name should be NULL-terminated if there is room.
The file attributes of a LFN entry must be 0x0F. The checksum is calculated using the short name of the file, and it should be the same for each of the LFN entries for the file. If the checksum in a LFN entry does not match its corresponding short name, an OS that does not support long file names could have been used and made the directory corrupt. The checksum algorithm iterates over each letter in the name, and at each step it rotates the current checksum by one bit to the right and then adds the ASCII value of the next letter.
Data structure for an LFN FAT directory entry
| Byte Range | Description | Essential |
| 0–0 | Sequence number (ORed with 0x40) and allocation status (0xe5 if unallocated) | Yes |
| 1–10 | File name characters 1–5 (Unicode) | Yes |
| 11–11 | File attributes (0x0f) | Yes |
| 12–12 | Reserved | No |
| 13–13 | Checksum | Yes |
| 14–25 | File name characters 6–11 (Unicode) | Yes |
| 26–27 | Reserved | No |
| 28–31 | File name characters 12–13 (Unicode) | Yes |
The sequence number field is a counter for each entry needed to store the file name, and the first entry has a value of 1. The sequence number increases for each LFN entry until the final entry, which is a bitwise OR with the value 0x40. When two values are bitwise ORed together, the result has a 1 wherever any of the two inputs had a 1.
The LFN entries for a file are listed before the short name entry and are in reverse order. Therefore, the first entry that you will find in the directory will be the last LFN entry for the file and will have the largest sequence value. Unused characters are padded with 0xff, and the name should be NULL-terminated if there is room.
The file attributes of a LFN entry must be 0x0F. The checksum is calculated using the short name of the file, and it should be the same for each of the LFN entries for the file. If the checksum in a LFN entry does not match its corresponding short name, an OS that does not support long file names could have been used and made the directory corrupt. The checksum algorithm iterates over each letter in the name, and at each step it rotates the current checksum by one bit to the right and then adds the ASCII value of the next letter.
Data recovery content
Articles
Data recovery software for anyone
Recovering digital photos and raw files
The easy way of recovering digital photos
Photo recovery made easy: now with raw support
The importance of photo recovery software
How to recover digital pictures and raw photos: an easy way
Digital photo recovery revisited: when the impossible becomes a reality
A truly universal data recovery tool
Undelete software made simple
Truly universal data recovery
Data recovery made easy with Hetman Uneraser
Hetman Uneraser restore every single bit you lost
Recovering digital photos and raw files
The easy way of recovering digital photos
Photo recovery made easy: now with raw support
The importance of photo recovery software
How to recover digital pictures and raw photos: an easy way
Digital photo recovery revisited: when the impossible becomes a reality
A truly universal data recovery tool
Undelete software made simple
Truly universal data recovery
Data recovery made easy with Hetman Uneraser
Hetman Uneraser restore every single bit you lost