I was implementing FAT32, FAT16 and FAT12 in my os. It's almost done, except one thing.
According to fatgen103 documentation (https://staff.washington.edu/dittrich/m ... gen103.pdf), LFN entries doesn't have to be fully ordered. But does it apply for first and last entries? So can I safely assume the first (entry->order is 0x1, or 0x41 if it's the first and last entry) LFN entry is just before the directory entry and the last (entry->order ORed with 0x40) LFN entry is the first entry of directory like that:
And what's the best and correct method of parsing LFN entries? This is the method that I use:
Code: Select all
...
{
while (1)
{
lfn_entry_t* lfn_entry = (lfn_entry_t*) (cluster_buffer + buffer_index);
uint32_t lfn_order = lfn_entry->order & 0x3F;
memcpy((uint8_t*)long_name_buffer, &lfn_entry->name_1, 10);
memcpy((uint8_t*)long_name_buffer + 10, &lfn_entry->name_2, 12);
memcpy((uint8_t*)long_name_buffer + 22, &lfn_entry->name_3, 4);
for (uint8_t index = 0; long_name_buffer[index] && long_name_buffer[index] != 0xFFFF && index < 13; index++) name_buffer[(lfn_order - 1) * 13 + index] = long_name_buffer[index] & 0xFF;
buffer_index += sizeof(lfn_entry_t);
if (lfn_order == 1) break;
}
directory_entry_t* directory_entry = (directory_entry_t*) (cluster_buffer + buffer_index);
buffer_index += sizeof(directory_entry_t);
...
}
...
Thanks in advance.