Long file name issue of FAT

erlking ruizx at qq.com
Wed Dec 3 02:53:34 UTC 2014

Hello everyone,
We'v found a long file name issue of FAT in our application.

When create a long name file on SD card in rtems system, it can display the right long name.
But if use the SD card in Windows, it just display the short name of the file, like "ABCDE1~4.TXT", :(

I trace the code, the root cause of this issue is in msdos_add_file function, near line 1837.
The unicode coding of long file name use the 0x0000 as the end flag, the memory content is unknown after the flag.

When fill the long name in MSDOS_LFN_ENTRY, current code want to fill 0xffff  after the flag.
But it not consider the memory content is unknown ‍after the end flag, continue copying the content. 
for (i = 0; i < MSDOS_LFN_LEN_PER_ENTRY; ++i) {     if (!(*n == 0 && *(n+1) == 0))//xxx, after the flag, the condition is no use, should fill 0xffff.     {         *p = *n;         *(p+1) = *(n+1);     }     else     {         p [0] = fill;         p [1] = fill;         fill = 0xff;     } ------------------------------------------------------------‍‍
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20141203/f97cfcb1/attachment-0001.html>

More information about the users mailing list