summaryrefslogtreecommitdiff
path: root/nuttx/fs
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-10-29 16:30:29 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-10-29 16:30:29 +0000
commit4610a2d28a1e52200bb622b426eeaed3d2a96834 (patch)
treee2aa02fa122ba80340df5c18826d29451760ea6f /nuttx/fs
parente876ab20bae53a5e217f00c5b0dfb35554e6ac4f (diff)
downloadpx4-nuttx-4610a2d28a1e52200bb622b426eeaed3d2a96834.tar.gz
px4-nuttx-4610a2d28a1e52200bb622b426eeaed3d2a96834.tar.bz2
px4-nuttx-4610a2d28a1e52200bb622b426eeaed3d2a96834.zip
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
Diffstat (limited to 'nuttx/fs')
-rw-r--r--nuttx/fs/nxffs/nxffs_pack.c55
1 files changed, 33 insertions, 22 deletions
diff --git a/nuttx/fs/nxffs/nxffs_pack.c b/nuttx/fs/nxffs/nxffs_pack.c
index 66ae2b073..d0e5deb56 100644
--- a/nuttx/fs/nxffs/nxffs_pack.c
+++ b/nuttx/fs/nxffs/nxffs_pack.c
@@ -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 */
-
- 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;
- }
+ /* Make sure there is space at this location for an inode header */
+
+ if (pack.iooffset + SIZEOF_NXFFS_INODE_HDR > volume->geo.blocksize)
+ {
+ /* No.. not enough space here. Skip the rest of this block */
+
+ pack.iooffset = SIZEOF_NXFFS_BLOCK_HDR;
+ }
+ else
+ {
+ /* Pack write data into this block */
+
+ 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;
+ }
+ }
}
}
}