From daf21a493158b44c57edb065356cd56d39e0021d Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 3 May 2011 22:30:53 +0000 Subject: [PATCH] Incorporate two FAT bugfixes reported by Sheref Younan. git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@3557 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- nuttx/ChangeLog | 3 +++ nuttx/fs/fat/fs_fat32.c | 2 +- nuttx/fs/fat/fs_fat32util.c | 6 ++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index a0ade8166..702ffe09f 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -1718,3 +1718,6 @@ implementation is incomplete on initial checkin. * apps/examples/nxffs and configs/sim/nxffs: Add a test a a configuration that will be used to verify NXFFS. + * fs/fat/fs_fat32.c and fs_fat32util.c: Incorpated two bugs with fixed provided + by Sheref Younan. Thanks! + diff --git a/nuttx/fs/fat/fs_fat32.c b/nuttx/fs/fat/fs_fat32.c index 2d880dabc..4547d0b24 100644 --- a/nuttx/fs/fat/fs_fat32.c +++ b/nuttx/fs/fat/fs_fat32.c @@ -1179,7 +1179,7 @@ static int fat_sync(FAR struct file *filep) * in the sector using the saved directory index. */ - direntry = &fs->fs_buffer[ff->ff_dirindex * 32]; + direntry = &fs->fs_buffer[(ff->ff_dirindex & DIRSEC_NDXMASK(fs)) * 32]; /* Set the archive bit, set the write time, and update * anything that may have* changed in the directory diff --git a/nuttx/fs/fat/fs_fat32util.c b/nuttx/fs/fat/fs_fat32util.c index aa8db91d5..a37f8fadb 100644 --- a/nuttx/fs/fat/fs_fat32util.c +++ b/nuttx/fs/fat/fs_fat32util.c @@ -649,7 +649,8 @@ int fat_mount(struct fat_mountpt_s *fs, bool writeable) goto errout_with_buffer; } - if (fat_checkbootrecord(fs) != OK) + ret = fat_checkbootrecord(fs); + if (ret != OK) { /* The contents of sector 0 is not a boot record. It could be a * partition, however. Assume it is a partition and get the offset @@ -683,7 +684,8 @@ int fat_mount(struct fat_mountpt_s *fs, bool writeable) /* Check if this is a boot record */ - if (fat_checkbootrecord(fs) != OK) + ret = fat_checkbootrecord(fs); + if (ret != OK) { fdbg("No valid MBR\n"); goto errout_with_buffer;