FS#11118 - Reduce the number of cached sector in the fat driver

Attached to Project: Rockbox
Opened by amaury pouly (pamaury) - Wednesday, 17 March 2010, 13:26 GMT
Last edited by amaury pouly (pamaury) - Monday, 22 March 2010, 10:48 GMT
Task Type Patches
Category Drivers
Status Closed
Assigned To amaury pouly (pamaury)
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


This patch reduces the number of cached sector in the fat_dir structure because it's useless.
It requires a nearly complete rewrite of fat_getnext.
At the same time, I made it check more things about LFN entries:
* last long entry attribute in the first entry
* ordinal are all present and decreasing
I could also implement checkuming but I I fear that not all fat drivers implement it.

Please review and test it !
   fat.diff (13.8 KiB)
This task depends upon

Closed by  amaury pouly (pamaury)
Monday, 22 March 2010, 10:48 GMT
Reason for closing:  Accepted
Additional comments about closing:  r25290
Comment by Marc Aarts (topik) - Friday, 19 March 2010, 10:48 GMT
Amaury, I have tested it on my Nano2G and Sansa Fuze and I have no noticeable differences.

Rockbox starts fine, playing music and a random selection of plugins work.
Comment by amaury pouly (pamaury) - Friday, 19 March 2010, 22:54 GMT
New patch, mostly cosmetics.
Comment by Magnus Holmgren (learman) - Saturday, 20 March 2010, 15:40 GMT
But why is it useless? A cache ought to be useful for HD-based targets, even if it is useless for flash-based targets...
Comment by Torne Wuff (torne) - Saturday, 20 March 2010, 15:50 GMT
Only the most recently read sector in the cache is ever reused (the structure of FAT directories guarantees it). Keeping the other two sectors around has *zero* benefit, on any target.
Comment by amaury pouly (pamaury) - Saturday, 20 March 2010, 23:12 GMT
New patch. I fixed a potential buffer overflow and several other things :)
I tested it to the limit and it works correctly.
   fat.diff (14.7 KiB)