More NXFFS bugfixes

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3560 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2011-05-04 18:49:53 +00:00
parent 4e23151cdd
commit 5196a00b2d
4 changed files with 65 additions and 22 deletions
+9 -9
View File
@@ -127,13 +127,6 @@ static int ram_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks
DEBUGASSERT(dev);
/* Convert the erase block to a logical block and the number of blocks
* in logical block numbers
*/
startblock *= CONFIG_RAMMTD_BLKPER;
nblocks *= CONFIG_RAMMTD_BLKPER;
/* Don't let the erase exceed the size of the ram buffer */
if (startblock >= priv->nblocks)
@@ -141,11 +134,18 @@ static int ram_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks
return 0;
}
if (startblock + nblocks >= priv->nblocks)
if (startblock + nblocks > priv->nblocks)
{
nblocks = priv->nblocks - nblocks;
nblocks = priv->nblocks - startblock;
}
/* Convert the erase block to a logical block and the number of blocks
* in logical block numbers
*/
startblock *= CONFIG_RAMMTD_BLKPER;
nblocks *= CONFIG_RAMMTD_BLKPER;
/* Get the offset corresponding to the first block and the size
* corresponding to the number of blocks.
*/