From 1670d2d218ad2dbcf33c53dbce818b8514836f65 Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 31 Oct 2011 17:04:03 +0000 Subject: Fix an NXFFS initialization problem git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4074 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/fs/nxffs/nxffs_initialize.c | 19 ++++++++++++++++++- nuttx/fs/nxffs/nxffs_inode.c | 6 ++++-- 2 files changed, 22 insertions(+), 3 deletions(-) (limited to 'nuttx/fs') diff --git a/nuttx/fs/nxffs/nxffs_initialize.c b/nuttx/fs/nxffs/nxffs_initialize.c index 0fa879f75..0fe519cee 100644 --- a/nuttx/fs/nxffs/nxffs_initialize.c +++ b/nuttx/fs/nxffs/nxffs_initialize.c @@ -398,7 +398,24 @@ int nxffs_limits(FAR struct nxffs_volume_s *volume) * is full? */ - fvdbg("nxffs_getc failed: %d\n", -ch); + if (volume->ioblock + 1 >= volume->nblocks && + volume->iooffset + 1 >= volume->geo.blocksize) + { + /* Yes.. the FLASH is full. Force the offsets to the end of FLASH */ + + volume->froffset = volume->nblocks * volume->geo.blocksize; + fvdbg("Assume no free FLASH, froffset: %d\n", volume->froffset); + if (noinodes) + { + volume->inoffset = volume->froffset; + fvdbg("No inodes, inoffset: %d\n", volume->inoffset); + } + return OK; + } + + // No? Then it is some other failure that we do not know how to handle + + fdbg("nxffs_getc failed: %d\n", -ch); return ch; } diff --git a/nuttx/fs/nxffs/nxffs_inode.c b/nuttx/fs/nxffs/nxffs_inode.c index 121c1f6db..3362d1f29 100644 --- a/nuttx/fs/nxffs/nxffs_inode.c +++ b/nuttx/fs/nxffs/nxffs_inode.c @@ -470,9 +470,11 @@ off_t nxffs_inodeend(FAR struct nxffs_volume_s *volume, if (entry->doffset) { - /* This is the maximum size of one data block */ + /* This is the maximum size of one data block. It is the physcal size + * of the block minus the minimum number of headers: block sna data + */ - uint16_t maxsize = volume->geo.blocksize - SIZEOF_NXFFS_DATA_HDR; + uint16_t maxsize = volume->geo.blocksize - SIZEOF_NXFFS_BLOCK_HDR - SIZEOF_NXFFS_DATA_HDR; /* This is the minimum number of blocks require to span all of the * inode data. One additional block could possibly be required -- we -- cgit v1.2.3