FS#7359 - Filesystem errors after moving directorys with rockbox

Attached to Project: Rockbox
Opened by PaulJam (PaulJam) - Tuesday, 26 June 2007, 16:38 GMT
Last edited by Peter D'Hoye (petur) - Thursday, 05 July 2007, 18:31 GMT
Task Type Bugs
Category Drivers
Status Closed
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version Daily build (which?)
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


When you move a directory in the filetree by using the "cut" and "paste" options in the context menu, this causes filesystem errors.
This was reproduceable with a fresh formatted (quickformat) harddrive with only the .rockbox folder and some testfiles copied to it. I started Rockbox and moved the folder "Müll" from "/Daten" to "/Aufnahmen", then shutdown Rockbox, connected to USB and ran chkdsk.
Here is the output of chkdsk (unfortunately only in german):

Der Typ des Dateisystems ist FAT32.
Volume H300 erstellt 26.06.2007 17:50
Volumenummer: 4CBB-1706
Dateien und Ordner werden überprüft...
Windows hat auf dem Datenträger Fehler gefunden, wird diese aber nicht repariere
n, weil der Parameter /F nicht angegeben wurde.
\Aufnahmen\Müll Fehler in . und/oder .. berichtigt.
Die Datei- und Ordnerüberprüfung ist abgeschlossen.
Windows hat Probleme im Dateisystem festgestellt.
Führen Sie CHKDSK mit der Option /F (Fehlerbehebung) aus, um die Probleme zu
19.517.424 KB Speicherplatz auf dem Datenträger insgesamt
784 KB in 49 Ordnern
53.824 KB in 850 Dateien
19.462.800 KB sind verfügbar

16.384 Bytes in jeder Zuordnungseinheit
1.219.839 Zuordnungseinheiten auf dem Datenträger insgesamt
1.216.425 Zuordnungseinheiten auf dem Datenträger verfügbar

I think the line with the error translates to something like:
\Aufnahmen\Müll Errors in . and/or .. corrected

H320 with version: r13721M-070626 (default settings)
This task depends upon

Closed by  Peter D'Hoye (petur)
Thursday, 05 July 2007, 18:31 GMT
Reason for closing:  Fixed
Additional comments about closing:  thanks for spotting!
Comment by Peter D'Hoye (petur) - Saturday, 30 June 2007, 22:08 GMT
Bah... the problem was staring in my face the whole time: the .. dir entry points to the parent dir, so when moving the dir, one must update the sectornumber of the .. entry

And now for a fix....
Comment by Peter D'Hoye (petur) - Sunday, 01 July 2007, 08:56 GMT
The attached patch does NOT work although it's not clear why. Just put it here so I can discuss it with a FAT32 code expert. The detection of the .. entry is a bit of a hack, it assumes it is the second entry in the dir.
Comment by Peter D'Hoye (petur) - Monday, 02 July 2007, 00:21 GMT
v2 - still not working. If anybody would care to tell me what I'm doing wrong?
(please ignore the c++ style comments, it was late ;)
Comment by Peter D'Hoye (petur) - Wednesday, 04 July 2007, 23:28 GMT
this patch fixes the problem, but for testing only. Needs to be written a bit better:
- enumerate all entries in the dir in search of ..
- make sure the first cluster is correct in case the parent is the root
(please don't mind the C++ style comments, they'll go away too ;)
   p.patch (2.3 KiB)
Comment by Linus Nielsen Feltzing (linusnielsen) - Thursday, 05 July 2007, 04:50 GMT
Correct me if I'm wrong, but I believe the . and .. entries are always the first two entries of a FAT directory (except for the root of course), so there won't be a need to search for the .. entry.