Add some missing error handling to NXFFS
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4068 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
b8ebda1ae6
commit
47233f1b3c
@ -2178,3 +2178,8 @@
|
||||
not being recognized and handled properly.
|
||||
* graphics/nxsu/nx_releasebkgdg.c: Fix a bad cast that was causing
|
||||
problems with the backgournd window was released.
|
||||
* fs/nxffs/nxffs_pack.c: Correct a critical bug in the NXFFS file system:
|
||||
When repacking the filesystem, there was a missing check to see if an
|
||||
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.
|
||||
|
@ -1433,34 +1433,45 @@ int nxffs_pack(FAR struct nxffs_volume_s *volume)
|
||||
}
|
||||
|
||||
/* If all of the "normal" inodes have been packed, then check if
|
||||
* we need to the current, in-progress write operation.
|
||||
* we need to pack the current, in-progress write operation.
|
||||
*/
|
||||
|
||||
if (wrfile)
|
||||
{
|
||||
DEBUGASSERT(packed == true);
|
||||
|
||||
/* Pack write data into this block */
|
||||
/* Make sure there is space at this location for an inode header */
|
||||
|
||||
ret = nxffs_packwriter(volume, &pack, wrfile);
|
||||
if (ret < 0)
|
||||
{
|
||||
/* The error -ENOSPC is a special value that simply
|
||||
* means that there is nothing further to be packed.
|
||||
*/
|
||||
if (pack.iooffset + SIZEOF_NXFFS_INODE_HDR > volume->geo.blocksize)
|
||||
{
|
||||
/* No.. not enough space here. Skip the rest of this block */
|
||||
|
||||
if (ret == -ENOSPC)
|
||||
{
|
||||
wrfile = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Otherwise, something really bad happened */
|
||||
pack.iooffset = SIZEOF_NXFFS_BLOCK_HDR;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Pack write data into this block */
|
||||
|
||||
fdbg("Failed to pack into block %d: %d\n",
|
||||
block, ret);
|
||||
goto errout_with_pack;
|
||||
}
|
||||
ret = nxffs_packwriter(volume, &pack, wrfile);
|
||||
if (ret < 0)
|
||||
{
|
||||
/* The error -ENOSPC is a special value that simply
|
||||
* means that there is nothing further to be packed.
|
||||
*/
|
||||
|
||||
if (ret == -ENOSPC)
|
||||
{
|
||||
wrfile = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Otherwise, something really bad happened */
|
||||
|
||||
fdbg("Failed to pack into block %d: %d\n",
|
||||
block, ret);
|
||||
goto errout_with_pack;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user