diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-10-31 13:16:08 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-10-31 13:16:08 +0000 |
commit | 4106f1d4fada91322bc16cd5c9f077befa19231e (patch) | |
tree | 590e8bfab2113751a72c76e186c8761645b0c505 /nuttx/fs/nxffs | |
parent | 77456adfeebf170d6fb0cb3a37dd261eb0ed7874 (diff) | |
download | px4-nuttx-4106f1d4fada91322bc16cd5c9f077befa19231e.tar.gz px4-nuttx-4106f1d4fada91322bc16cd5c9f077befa19231e.tar.bz2 px4-nuttx-4106f1d4fada91322bc16cd5c9f077befa19231e.zip |
Yet another re-implementation of the NXFFS bug fix
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4072 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/fs/nxffs')
-rw-r--r-- | nuttx/fs/nxffs/nxffs_pack.c | 68 |
1 files changed, 37 insertions, 31 deletions
diff --git a/nuttx/fs/nxffs/nxffs_pack.c b/nuttx/fs/nxffs/nxffs_pack.c index 9c629e2aa..4f16e89ac 100644 --- a/nuttx/fs/nxffs/nxffs_pack.c +++ b/nuttx/fs/nxffs/nxffs_pack.c @@ -468,9 +468,22 @@ static int nxffs_destsetup(FAR struct nxffs_volume_s *volume, if (pack->dest.entry.hoffset == 0) { - /* Initialize the FLASH offset to the inode header */ + /* Is there room for an inode structure in this block? */ + + if(pack->iooffset + SIZEOF_NXFFS_INODE_HDR > volume->geo.blocksize) + { + /* No.. that inode name will not fit in this block. Return an + * indication that we are at the end of the block and try again + * later. + */ + + return -ENOSPC; + } + + /* The inode header will be placed at this position (but not until + * we are finished. + */ - DEBUGASSERT(pack->iooffset + SIZEOF_NXFFS_INODE_HDR <= volume->geo.blocksize); pack->dest.entry.hoffset = nxffs_packtell(volume, pack); /* Make sure that the initialize state of the inode header memory is @@ -544,7 +557,7 @@ static int nxffs_destsetup(FAR struct nxffs_volume_s *volume, */ ret = -ENOSPC; - goto errout; + goto errout; } /* Yes.. reserve space for the data block header */ @@ -1440,34 +1453,27 @@ int nxffs_pack(FAR struct nxffs_volume_s *volume) { DEBUGASSERT(packed == true); - /* Make sure there is space at this location for an inode - * header. - */ - - if (pack.iooffset + SIZEOF_NXFFS_INODE_HDR <= volume->geo.blocksize) - { - /* 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; - } - } + /* 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; + } } } } |