9
0
Fork 0

Fix an NXFFS initialization problem

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4074 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2011-10-31 17:04:03 +00:00
parent cf8a318439
commit e349bc29c1
3 changed files with 25 additions and 3 deletions

View File

@ -2183,3 +2183,6 @@
inode structure would fit at the end of a block. This is a rare case
if the block size is large, but can be common for tiny block sizes
and results in a crash and file system corruption.
* fs/nxffs/nxffs_initialize.c: Fix an initialize error. If the FLASH
is on power-up, NXFFS will fail to initialize correctly.

View File

@ -398,7 +398,24 @@ int nxffs_limits(FAR struct nxffs_volume_s *volume)
* is full?
*/
fvdbg("nxffs_getc failed: %d\n", -ch);
if (volume->ioblock + 1 >= volume->nblocks &&
volume->iooffset + 1 >= volume->geo.blocksize)
{
/* Yes.. the FLASH is full. Force the offsets to the end of FLASH */
volume->froffset = volume->nblocks * volume->geo.blocksize;
fvdbg("Assume no free FLASH, froffset: %d\n", volume->froffset);
if (noinodes)
{
volume->inoffset = volume->froffset;
fvdbg("No inodes, inoffset: %d\n", volume->inoffset);
}
return OK;
}
// No? Then it is some other failure that we do not know how to handle
fdbg("nxffs_getc failed: %d\n", -ch);
return ch;
}

View File

@ -470,9 +470,11 @@ off_t nxffs_inodeend(FAR struct nxffs_volume_s *volume,
if (entry->doffset)
{
/* This is the maximum size of one data block */
/* This is the maximum size of one data block. It is the physcal size
* of the block minus the minimum number of headers: block sna data
*/
uint16_t maxsize = volume->geo.blocksize - SIZEOF_NXFFS_DATA_HDR;
uint16_t maxsize = volume->geo.blocksize - SIZEOF_NXFFS_BLOCK_HDR - SIZEOF_NXFFS_DATA_HDR;
/* This is the minimum number of blocks require to span all of the
* inode data. One additional block could possibly be required -- we