From: Tom Rini Date: Mon, 12 May 2014 21:54:42 -0400 Subject: [U-Boot] [U-Boot, 3/3] fs/fat: correct FAT16/12 file finding in root dir In-Reply-To: <1399536847-21719-4-git-send-email-josh.wu@atmel.com> References: <1399536847-21719-4-git-send-email-josh.wu@atmel.com> Message-ID: <20140513015442.GM22182@bill-the-cat> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Thu, May 08, 2014 at 04:14:07PM +0800, Wu, Josh wrote: > When write a file into FAT file system, it will search a match file in > root dir. So the find_directory_entry() will get the first cluster of > root dir content and search the directory item one by one. If the file > is not found, we will call get_fatent_value() to get next cluster of root > dir via lookup the FAT table and continue the search. > > The issue is in FAT16/12 system, we cannot get root dir's next clust > from FAT table. The FAT table only be use to find the clust of data > aera in FAT16/12. > > In FAT16/12 if the clust is in root dir, the clust number is a negative > number or 0, 1. Since root dir is located in front of the data area. > Data area start clust #2. So the root dir clust number should < 2. > > This patch will check above situation before call get_fatenv_value(). > If curclust is < 2, include minus number, we just increase one on the > curclust since root dir is in continous cluster. > > The patch also add a sanity check for entry in get_fatenv_value(). > > Signed-off-by: Josh Wu Applied to u-boot/master, thanks! -- Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: