Page 1 of 1
[SOLVED] FAT32 filesystem short entry of LFN
Posted: Thu Apr 25, 2013 7:23 am
by HugeCode
Hi all. I've read this
document. I was looking for how to use long file names and I found a part that is not covered there. There's an example which shows translation of "The quick brown.fox" to LFN entries. After all LFN entries there's also one 'short entry'. I found that in it's name there's only the part which fits there. So from the string above there's only "T H E Q U I ~ F O X". And creation of these names is the point of my question:
Is there any standard way how to build name of short entry following LFNs?
What about usage of unicode charcters only (char>255)? There's written that unreadable unicode char should be replaced with '_', but I don't know if it also applies on SFNs.
Thanks.
Re: FAT32 filesystem short entgry of LFN
Posted: Thu Apr 25, 2013 8:11 am
by thepowersgang
The algorithm is standardised (from my memory), and I think it is provided in the official documentation (intended for UEFI implementers). A quick descripton of the method used is
- All invalid characters are replaced by '_'
- Lowercase characters are converted to uppercase
- The name is truncated to 6 characters if the non-extension part is longer than 8 (or not unique) and '~' plus a number is appended (such that the 8.3 name is unique)
[edit: Fixed list
Re: FAT32 filesystem short entgry of LFN
Posted: Thu Apr 25, 2013 8:39 am
by HugeCode
Isn't the document I put here official (it's from microsoft)?
BTW what from extension is put to 3 chars in short entry? Start or end?
Also I saw numbers after ~. Does it something to do with number of LFN entries following?
I'm fed up a bit from my FAT code, because Windows doesn't accept it (invalid short entry -> invalid checksum -> invalid long file name -> "There's a problem with this drive. Scan the drive now and fix it.").
Thanks.
Re: FAT32 filesystem short entgry of LFN
Posted: Thu Apr 25, 2013 8:59 am
by HugeCode
Found it. The older one contains it:
http://msdn.microsoft.com/en-us/library ... 63080.aspx
Just an optional question: can number tail rewrite the extension?
EDIT:
What the hack is this? No tails, only mess of characters. Why?
Re: FAT32 filesystem short entgry of LFN
Posted: Thu Apr 25, 2013 3:16 pm
by dozniak
All ~1 are tails. No they can not overwrite the extension.
Re: FAT32 filesystem short entgry of LFN
Posted: Thu Apr 25, 2013 3:51 pm
by Combuster
dozniak wrote:A.ll ~1 are tails. No they can not overwrite the extension.
So if you force a single-digit tail to be insufficient, it'll need to find space elsewhere to create unique filenames, and that has to be earlier in the 8.3 string.
Re: FAT32 filesystem short entgry of LFN
Posted: Thu Apr 25, 2013 4:35 pm
by dozniak
Combuster wrote:dozniak wrote:A.ll ~1 are tails. No they can not overwrite the extension.
So if you force a single-digit tail to be insufficient, it'll need to find space elsewhere to create unique filenames, and that has to be earlier in the 8.3 string.
And if you look carefully at your dump, you'll see that it takes only 2 first characters of the long filename and then generates a 4-character random identifier, then finishes it with a tail.
Re: FAT32 filesystem short entgry of LFN
Posted: Thu Apr 25, 2013 5:21 pm
by Owen
Note that you can omit the short name. Linux, for example, does this because the "FAT LFN" patent only covers cases where you create a file with both the long and short names.
Re: FAT32 filesystem short entgry of LFN
Posted: Fri Apr 26, 2013 9:22 am
by HugeCode
So if I understand it correctly, faster way for LFN SFN entry generation is to create random numbers (based on actual time) so they won't mess and there's no need to perform check in directory to generate correct tail number.
Thank you all.