This is the bug/patch tracker for Rockbox. Click here for more information.
Quick links: Bugs · Patches · Rockbox frontpage
FS#6648 - Creating two files with similar names corrupts FAT directory
Attached to Project:
Rockbox
Opened by Dave Chapman (linuxstb) - Monday, 12 February 2007, 02:20 GMT+2
Opened by Dave Chapman (linuxstb) - Monday, 12 February 2007, 02:20 GMT+2
|
DetailsSteps to reproduce:
1) Write a .cfg file called "config01.cfgA" 2) Write a second .cfg file called "config01.cfg" (this should have different content to the first - change at least one setting, or just export a theme .cfg) Accessing the device (I've tested with both an ipod 5g and h140) from Linux and Mac OS X will show two entries with identical filesizes and timestamps. A diff between the two files will show no differences. Mounting the device in Linux with "-t msdos" doesn't show the same problem - the two files have different shortnames, and the filesizes and timestamps are different, and a diff will show differences. In WinXP, the files show different sizes and dates, but when displaying them (I used "type config.cfg" in a cmd prompt), they are both showing the content of the first file written. |
This task depends upon
Writing "config01.cfg" afterwards is problematic because "config01.cfg" is a valid 8.3 name using 1 entry, so no longname. The shortname can't be randomized because it's our real filename.
Solution:
1) always randomize shortname if it differs from longname
2) also scan the (invisible) shortnames when trying to create a new file
(work in progress)
Would there be any problem with changing the shortname of an existing file?
Randomizing lowers the chance enough.
Scanning on shortnames is needed to avoid directory corruption
I did this:
create testdokument.txt, this gets the shortname testdo~1.txt
create testdo~1.txt, the shortname of testdokument.txt is changed to testdo~2.txt, and testdo~1.txt is created as requested.
This seems like the right thing to do to me.
I did get a hint of what happened because I used config01.cfgA and config01.cfg and when I wanted to make config~1.cfg I got a msgbox telling me that changing the extension could make the file unusable. This was generated by the routine that changed the config01.cfgA shortname....
note to self:
http://www.rockbox.org/twiki/pub/Main/DataSheets/FAT32Spec103.pdf page 30+ illustrates how we really should be creating shortnames.
As a bug in it can be nasty (filesystem), please review...