summaryrefslogtreecommitdiff
path: root/nuttx/fs/nxffs/nxffs_cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/fs/nxffs/nxffs_cache.c')
-rw-r--r--nuttx/fs/nxffs/nxffs_cache.c66
1 files changed, 29 insertions, 37 deletions
diff --git a/nuttx/fs/nxffs/nxffs_cache.c b/nuttx/fs/nxffs/nxffs_cache.c
index 41974bf93..7f563820f 100644
--- a/nuttx/fs/nxffs/nxffs_cache.c
+++ b/nuttx/fs/nxffs/nxffs_cache.c
@@ -103,7 +103,7 @@ int nxffs_rdcache(FAR struct nxffs_volume_s *volume, off_t block,
if (nxfrd != nblocks)
{
fdbg("Read block %d-%d failed: %d\n",
- block, block + nblocks -1, nxfrd);
+ block, block + nblocks - 1, nxfrd);
return -EIO;
}
@@ -123,22 +123,41 @@ int nxffs_rdcache(FAR struct nxffs_volume_s *volume, off_t block,
*
* Input Parameters:
* volume - Describes the current volume
- * block - The first logical block to write
- * nblocks - The number of logical blocks to be write.
*
* Returned Value:
* Negated errnos are returned only in the case of MTD reported failures.
- * Nothing in the volume data itself will generate errors.
- *
- * Defined in nxffs_cache.c
*
****************************************************************************/
-int nxffs_wrcache(FAR struct nxffs_volume_s *volume, off_t block,
- uint8_t nblocks)
+int nxffs_wrcache(FAR struct nxffs_volume_s *volume)
{
-#warning "Missing logic"
- return OK;
+ size_t nxfrd;
+
+ /* Check if there are blocks in the cache */
+
+ if (volume->ncached > 0)
+ {
+ /* Read the specified blocks into cache */
+
+ nxfrd = MTD_BWRITE(volume->mtd, volume->cblock, volume->ncached,
+ volume->cache);
+ if (nxfrd != volume->ncached)
+ {
+ fdbg("Write block %d-%d failed: %d\n",
+ volume->cblock, volume->cblock + volume->ncached - 1, nxfrd);
+ return -EIO;
+ }
+
+ /* Write was successful */
+
+ return OK;
+ }
+
+ /* Probably won't get here because there is almost always something in
+ * the cache
+ */
+
+ return -EINVAL;
}
/****************************************************************************
@@ -287,30 +306,3 @@ ssize_t nxffs_rddata(FAR struct nxffs_volume_s *volume,
return buflen;
}
-
-/****************************************************************************
- * Name: nxffs_wrdata
- *
- * Description:
- * Write a sequence of data bytes into volume cache memory. Nothing is
- * actually written to FLASH! This function allows the data in the formatted
- * FLASH blocks to be read as a continuous byte stream, skipping over bad
- * blocks and block headers as necessary.
- *
- * Input Parameters:
- * volume - Describes the NXFFS volume.
- * buffer - A pointer to memory to containing the data to write to FLASH.
- * buflen - The maximum number of bytes to write to FLASH.
- *
- * Returned Value:
- * The number of bytes written is returned on success. Otherwise, a negated
- * errno indicating the nature of the failure.
- *
- ****************************************************************************/
-
-ssize_t nxffs_wrdata(FAR struct nxffs_volume_s *volume,
- FAR const uint8_t *buffer, size_t buflen)
-{
-#warning "Missing Logic"
- return -ENOSYS;
-}