Fix an NXFFS initialization problem

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4074 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2011-10-31 17:04:03 +00:00
parent ae91fa0be3
commit 807c279a83
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