mirror of
https://github.com/apache/nuttx.git
synced 2026-05-18 08:54:05 +08:00
Fix a FAT mount bug
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1249 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -548,10 +548,12 @@
|
||||
no longer have to be the same.
|
||||
* Add a loop device that converts a file into a block device.
|
||||
* Each NSH command can not be disabled through a configuration setting. All of these
|
||||
settings make the configuration of NSH potentially complex but also allow it to squeeze
|
||||
into very small memory footprints.
|
||||
settings make the configuration of NSH potentially complex but also allow it to squeeze
|
||||
into very small memory footprints.
|
||||
* Added a block to character (BCH) driver. This is kind of the reverse of the loop
|
||||
device; it allows you access a block device like a character device.
|
||||
* Added strcasecmp() and strncasecmp()
|
||||
* NSH: Added the 'dd' command
|
||||
* NSH: Added the 'losetup' command
|
||||
* Fixed a FAT bug: After recent changes, it would mount a (invalid) FAT file system
|
||||
even if the medium is not formatted!
|
||||
|
||||
@@ -1191,12 +1191,14 @@ nuttx-0.3.18 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
no longer have to be the same.
|
||||
* Add a loop device that converts a file into a block device.
|
||||
* Each NSH command can not be disabled through a configuration setting. All of these
|
||||
settings make the configuration of NSH potentially complex but also allow it to squeeze
|
||||
into very small memory footprints.
|
||||
settings make the configuration of NSH potentially complex but also allow it to squeeze
|
||||
into very small memory footprints.
|
||||
* Added a block to character (BCH) driver. This is kind of the reverse of the loop
|
||||
device; it allows you access a block device like a character device.
|
||||
* NSH: Added the 'dd' command
|
||||
* NSH: Added the 'losetup' command
|
||||
* Fixed a FAT bug: After recent changes, it would mount a (invalid) FAT file system
|
||||
even if the medium is not formatted!
|
||||
|
||||
pascal-0.1.3 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
|
||||
|
||||
+22
-18
@@ -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 */
|
||||
|
||||
/* Check if this is a boot record */
|
||||
ret = fat_hwread(fs, fs->fs_buffer, fs->fs_fatbase, 1);
|
||||
if (ret < 0)
|
||||
{
|
||||
goto errout_with_buffer;
|
||||
}
|
||||
|
||||
if (fat_checkbootrecord(fs) != OK)
|
||||
{
|
||||
goto errout_with_buffer;
|
||||
}
|
||||
/* Check if this is a boot record */
|
||||
|
||||
if (fat_checkbootrecord(fs) != OK)
|
||||
{
|
||||
fdbg("No valid MBR\n");
|
||||
goto errout_with_buffer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user