OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Apr 24, 2024 12:40 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: FAT LFN order
PostPosted: Mon Jun 12, 2017 1:53 am 
Offline
Member
Member
User avatar

Joined: Sun Nov 20, 2016 7:26 am
Posts: 155
Location: Somewhere
Hello forum.

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:

Image

And what's the best and correct method of parsing LFN entries? This is the method that I use:

Code:
      ...
      {
            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);

            ...
     }
     ...


This is really simple for now, and it doesn't make the important things like comparing checksums and checking lfn order. I'm going to make it better after I learn how can I correctly parse the LFN entries.

Thanks in advance.

_________________
Keyboard not found!

Press F1 to run setup.
Press F2 to continue.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 115 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group