summaryrefslogtreecommitdiff
path: root/nuttx/fs
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-05-01 19:48:21 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-05-01 19:48:21 +0000
commita86b56511ae7a4f183841e3708407625fcec8e2c (patch)
tree9f43facf9f4909f5c46c064eeaabb9477d191408 /nuttx/fs
parent9ce05b3c4e19291d5b83daf0b34e858d665c9203 (diff)
downloadpx4-nuttx-a86b56511ae7a4f183841e3708407625fcec8e2c.tar.gz
px4-nuttx-a86b56511ae7a4f183841e3708407625fcec8e2c.tar.bz2
px4-nuttx-a86b56511ae7a4f183841e3708407625fcec8e2c.zip
More NXFFS bugfixes
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3549 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/fs')
-rw-r--r--nuttx/fs/nxffs/nxffs_cache.c4
-rw-r--r--nuttx/fs/nxffs/nxffs_inode.c2
-rw-r--r--nuttx/fs/nxffs/nxffs_read.c25
3 files changed, 18 insertions, 13 deletions
diff --git a/nuttx/fs/nxffs/nxffs_cache.c b/nuttx/fs/nxffs/nxffs_cache.c
index 7f563820f..f97d94c70 100644
--- a/nuttx/fs/nxffs/nxffs_cache.c
+++ b/nuttx/fs/nxffs/nxffs_cache.c
@@ -102,8 +102,8 @@ int nxffs_rdcache(FAR struct nxffs_volume_s *volume, off_t block,
nxfrd = MTD_BREAD(volume->mtd, block, nblocks, volume->cache);
if (nxfrd != nblocks)
{
- fdbg("Read block %d-%d failed: %d\n",
- block, block + nblocks - 1, nxfrd);
+ fvdbg("Read block %d-%d failed: %d\n",
+ block, block + nblocks - 1, nxfrd);
return -EIO;
}
diff --git a/nuttx/fs/nxffs/nxffs_inode.c b/nuttx/fs/nxffs/nxffs_inode.c
index 72a6170bb..1e982c90d 100644
--- a/nuttx/fs/nxffs/nxffs_inode.c
+++ b/nuttx/fs/nxffs/nxffs_inode.c
@@ -291,7 +291,7 @@ int nxffs_nextentry(FAR struct nxffs_volume_s *volume, off_t offset,
ret = nxffs_rdentry(volume, offset, entry);
if (ret == OK)
{
- fdbg("Found a valid fileheader\n");
+ fvdbg("Found a valid fileheader, offset: %d\n", offset);
return OK;
}
diff --git a/nuttx/fs/nxffs/nxffs_read.c b/nuttx/fs/nxffs/nxffs_read.c
index a50a439bc..91bff3956 100644
--- a/nuttx/fs/nxffs/nxffs_read.c
+++ b/nuttx/fs/nxffs/nxffs_read.c
@@ -146,11 +146,11 @@ static int nxffs_rdblkhdr(FAR struct nxffs_volume_s *volume, off_t offset,
* Name: nxffs_nextblock
*
* Description:
- * Search for the next valid data block starting at the provided FLASH offset.
+ * Search for the next valid data block starting at the provided
+ * FLASH offset.
*
* Input Parameters:
* volume - Describes the NXFFS volume.
- * offset - The FLASH memory offset to begin searching.
* datlen - A memory location to return the data block length.
*
* Returned Value:
@@ -246,7 +246,8 @@ int nxffs_nextblock(FAR struct nxffs_volume_s *volume, off_t offset,
ret = nxffs_rdblkhdr(volume, blkentry->hoffset, &blkentry->datlen);
if (ret == OK)
{
- fdbg("Found a valid fileheader\n");
+ fvdbg("Found a valid data block, offset: %d datlen: %d\n",
+ blkentry->hoffset, blkentry->datlen);
return OK;
}
@@ -285,15 +286,21 @@ static ssize_t nxffs_rdseek(FAR struct nxffs_volume_s *volume,
struct nxffs_blkentry_s blkentry;
size_t datstart;
size_t datend;
- off_t offset = fpos;
+ off_t offset;
int ret;
+ /* The initial FLASH offset will be the offset to first data block of
+ * the inode
+ */
+
+ offset = entry->doffset;
+
/* Loop until we read the data block containing the desired position */
datend = 0;
do
{
- /* Find the next the next data block */
+ /* Check if the next data block contains the sought after file position */
ret = nxffs_nextblock(volume, offset, &blkentry);
if (ret < 0)
@@ -302,16 +309,14 @@ static ssize_t nxffs_rdseek(FAR struct nxffs_volume_s *volume,
return ret;
}
- /* Get the range of data offses for this data block */
+ /* Get the range of data offsets for this data block */
datstart = datend;
datend += blkentry.datlen;
- /* Protect against reading past the end of the file */
-
- /* Offset to search for the the next data block */
+ /* Offset to search for the the next data block */
- offset += blkentry.hoffset + SIZEOF_NXFFS_DATA_HDR + blkentry.datlen;
+ offset = blkentry.hoffset + SIZEOF_NXFFS_DATA_HDR + blkentry.datlen;
}
while (datend <= fpos);