Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: Re: Nasty FAT bug killed
From: Linus Nielsen Feltzing (linus_at_haxx.se)
Date: 2003-03-05


Greg Haerr wrote:
>>I just found and viciously killed a nasty bug in the FAT driver.
>
>
> What was it?

The update_fat_entry() function attempted to set a FAT cache entry dirty
after updating it, but it set the wrong entry. This only happened on
file systems that were formatted with a ReservedSectors field set to
something other than 32.

Old code:

fat_cache[sector % FAT_CACHE_MASK].dirty = true;

Corrected code:

fat_cache[(sector + bpb.bpb_rsvdseccnt) % FAT_CACHE_MASK].dirty = true;

The old code worked on systems with 32 reserved sectors since the modulo
operation "masked" the error, because the FAT cache size happens to be
32 as well. On file systems 36 reserved sectors, the wrong cache entry
would be set to dirty, and the updated entry would never be flushed to disk.

/Linus



Page was last modified "Jan 10 2012" The Rockbox Crew
aaa