diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-11-16 01:28:01 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-11-16 01:28:01 +0000 |
commit | fd8cf5088ad9d355baa5bfad15617b0f2459a7a9 (patch) | |
tree | 19effabc97123de0838c12226c19a79c00d784e9 /nuttx/fs | |
parent | d7445458fbee6a0939be1f1560b01e138b7767af (diff) | |
download | px4-nuttx-fd8cf5088ad9d355baa5bfad15617b0f2459a7a9.tar.gz px4-nuttx-fd8cf5088ad9d355baa5bfad15617b0f2459a7a9.tar.bz2 px4-nuttx-fd8cf5088ad9d355baa5bfad15617b0f2459a7a9.zip |
Fix a FAT mount bug
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1249 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/fs')
-rw-r--r-- | nuttx/fs/fat/fs_fat32util.c | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/nuttx/fs/fat/fs_fat32util.c b/nuttx/fs/fat/fs_fat32util.c index 6c96746cc..dc1404f9e 100644 --- a/nuttx/fs/fat/fs_fat32util.c +++ b/nuttx/fs/fat/fs_fat32util.c @@ -314,10 +314,10 @@ static int fat_checkbootrecord(struct fat_mountpt_s *fs) fs->fs_rootentcnt = MBR_GETROOTENTCNT(fs->fs_buffer); if (fs->fs_rootentcnt != 0) - { + { notfat32 = TRUE; /* Must be zero for FAT32 */ rootdirsectors = (32 * fs->fs_rootentcnt + fs->fs_hwsectorsize - 1) / fs->fs_hwsectorsize; - } + } /* Determine the number of sectors in a FAT. */ @@ -655,28 +655,32 @@ int fat_mount(struct fat_mountpt_s *fs, boolean writeable) * partition and see if we can find the boot record there. */ - if (PART1_GETTYPE(fs->fs_buffer) != 0) + if (PART1_GETTYPE(fs->fs_buffer) == 0) { - /* There appears to be a partition, get the sector number of the - * partition (LBA) - */ + fdbg("No MBR or partition\n"); + goto errout_with_buffer; + } - fs->fs_fatbase = PART1_GETSTARTSECTOR(fs->fs_buffer); + /* There appears to be a partition, get the sector number of the + * partition (LBA) + */ - /* Read the new candidate boot sector */ + fs->fs_fatbase = PART1_GETSTARTSECTOR(fs->fs_buffer); - ret = fat_hwread(fs, fs->fs_buffer, fs->fs_fatbase, 1); - if (ret < 0) - { - goto errout_with_buffer; - } + /* Read the new candidate boot sector */ + + ret = fat_hwread(fs, fs->fs_buffer, fs->fs_fatbase, 1); + if (ret < 0) + { + goto errout_with_buffer; + } - /* Check if this is a boot record */ + /* Check if this is a boot record */ - if (fat_checkbootrecord(fs) != OK) - { - goto errout_with_buffer; - } + if (fat_checkbootrecord(fs) != OK) + { + fdbg("No valid MBR\n"); + goto errout_with_buffer; } } |