dev builds
themes manual
device status forums
mailing lists
IRC bugs
dev guide

Rockbox mail archive

Subject: Re: Nasty FAT bug killed

Re: Nasty FAT bug killed

From: Linus Nielsen Feltzing <>
Date: Wed, 05 Mar 2003 02:25:26 +0100

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.

Received on 2003-03-05

Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy