Squashed commit of the following:
fs/nxffs: Giving up on truncate() support in NXFFS for now. There is too much that has to be done to make that work. configs/sim: Add support for testing NXFFS.
This commit is contained in:
parent
17cedb6b20
commit
0253c974b2
@ -48,6 +48,7 @@
|
||||
#include <nuttx/clock.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/mtd/mtd.h>
|
||||
#include <nuttx/fs/nxffs.h>
|
||||
#include <nuttx/video/fb.h>
|
||||
#include <nuttx/timers/oneshot.h>
|
||||
#include <nuttx/wireless/pktradio.h>
|
||||
@ -151,6 +152,15 @@ int sim_bringup(void)
|
||||
*/
|
||||
|
||||
smart_initialize(0, mtd, NULL);
|
||||
#elif defined(CONFIG_FS_NXFFS)
|
||||
/* Initialize to provide NXFFS on the MTD interface */
|
||||
|
||||
ret = nxffs_initialize(mtd);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: NXFFS initialization failed: %d\n",
|
||||
ret);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -888,8 +888,10 @@ int nxffs_updateinode(FAR struct nxffs_volume_s *volume,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __NO_TRUNCATE_SUPPORT__
|
||||
int nxffs_wrextend(FAR struct nxffs_volume_s *volume,
|
||||
FAR struct nxffs_wrfile_s *wrfile, off_t length);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxffs_wrreserve
|
||||
@ -1115,7 +1117,9 @@ int nxffs_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
|
||||
|
||||
int nxffs_dup(FAR const struct file *oldp, FAR struct file *newp);
|
||||
int nxffs_fstat(FAR const struct file *filep, FAR struct stat *buf);
|
||||
#ifdef __NO_TRUNCATE_SUPPORT__
|
||||
int nxffs_truncate(FAR struct file *filep, off_t length);
|
||||
#endif
|
||||
|
||||
int nxffs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
|
||||
FAR struct fs_dirent_s *dir);
|
||||
|
@ -75,7 +75,11 @@ const struct mountpt_operations nxffs_operations =
|
||||
NULL, /* sync -- No buffered data */
|
||||
nxffs_dup, /* dup */
|
||||
nxffs_fstat, /* fstat */
|
||||
#ifdef __NO_TRUNCATE_SUPPORT__
|
||||
nxffs_truncate, /* truncate */
|
||||
#else
|
||||
NULL, /* truncate */
|
||||
#endif
|
||||
|
||||
nxffs_opendir, /* opendir */
|
||||
NULL, /* closedir */
|
||||
|
@ -50,6 +50,8 @@
|
||||
|
||||
#include "nxffs.h"
|
||||
|
||||
#ifdef __NO_TRUNCATE_SUPPORT__
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -136,3 +138,4 @@ errout:
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* __NO_TRUNCATE_SUPPORT__ */
|
||||
|
@ -290,7 +290,7 @@ static inline int nxffs_wralloc(FAR struct nxffs_volume_s *volume,
|
||||
****************************************************************************/
|
||||
|
||||
static inline int nxffs_reverify(FAR struct nxffs_volume_s *volume,
|
||||
FAR struct nxffs_wrfile_s *wrfile)
|
||||
FAR struct nxffs_wrfile_s *wrfile)
|
||||
{
|
||||
uint32_t crc;
|
||||
off_t offset;
|
||||
@ -300,13 +300,13 @@ static inline int nxffs_reverify(FAR struct nxffs_volume_s *volume,
|
||||
/* Get the offset to the start of the data */
|
||||
|
||||
offset = volume->iooffset + SIZEOF_NXFFS_DATA_HDR;
|
||||
DEBUGASSERT(offset + wrfile->datlen < volume->geo.blocksize);
|
||||
DEBUGASSERT(offset + wrfile->datlen <= volume->geo.blocksize);
|
||||
|
||||
/* Calculate the CRC of the partial data block */
|
||||
|
||||
crc = crc32(&volume->cache[offset], wrfile->datlen);
|
||||
|
||||
/* It must match the previoulsy calculated CRC value */
|
||||
/* It must match the previously calculated CRC value */
|
||||
|
||||
if (crc != wrfile->crc)
|
||||
{
|
||||
@ -427,18 +427,19 @@ static inline ssize_t nxffs_wrappend(FAR struct nxffs_volume_s *volume,
|
||||
* nzeros - The number of bytes of zeroed data to be written
|
||||
*
|
||||
* Returned Value:
|
||||
* The number of bytes written is returned on success. Otherwise, a
|
||||
* The number of zero bytes written is returned on success. Otherwise, a
|
||||
* negated errno value is returned indicating the nature of the failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __NO_TRUNCATE_SUPPORT__
|
||||
static inline ssize_t nxffs_zappend(FAR struct nxffs_volume_s *volume,
|
||||
FAR struct nxffs_wrfile_s *wrfile,
|
||||
off_t nzeros)
|
||||
{
|
||||
ssize_t maxsize;
|
||||
size_t nbytestoclear;
|
||||
ssize_t remaining;
|
||||
ssize_t nbytesleft;
|
||||
off_t offset;
|
||||
int ret;
|
||||
|
||||
@ -456,11 +457,11 @@ static inline ssize_t nxffs_zappend(FAR struct nxffs_volume_s *volume,
|
||||
/* Write as many bytes as we can into the data buffer */
|
||||
|
||||
nbytestoclear = MIN(maxsize, nzeros);
|
||||
remaining = maxsize - nbytestoclear;
|
||||
nbytesleft = maxsize - nbytestoclear;
|
||||
|
||||
if (nbytestoclear > 0)
|
||||
{
|
||||
/* Copy the data into the volume write cache */
|
||||
/* Zero the data into the volume write cache */
|
||||
|
||||
memset(&volume->cache[offset], 0, nbytestoclear);
|
||||
|
||||
@ -477,7 +478,7 @@ static inline ssize_t nxffs_zappend(FAR struct nxffs_volume_s *volume,
|
||||
* block is full. In that case, the block will be written below.
|
||||
*/
|
||||
|
||||
if (remaining > 0)
|
||||
if (nbytesleft > 0)
|
||||
{
|
||||
ret = nxffs_wrcache(volume);
|
||||
if (ret < 0)
|
||||
@ -490,7 +491,7 @@ static inline ssize_t nxffs_zappend(FAR struct nxffs_volume_s *volume,
|
||||
|
||||
/* Check if the data block is now full */
|
||||
|
||||
if (remaining <= 0)
|
||||
if (nbytesleft <= 0)
|
||||
{
|
||||
/* The data block is full, write the block to FLASH */
|
||||
|
||||
@ -502,8 +503,9 @@ static inline ssize_t nxffs_zappend(FAR struct nxffs_volume_s *volume,
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return nbytestoclear;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@ -642,6 +644,7 @@ errout:
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __NO_TRUNCATE_SUPPORT__
|
||||
int nxffs_wrextend(FAR struct nxffs_volume_s *volume,
|
||||
FAR struct nxffs_wrfile_s *wrfile, off_t length)
|
||||
{
|
||||
@ -709,6 +712,7 @@ int nxffs_wrextend(FAR struct nxffs_volume_s *volume,
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxffs_wrreserve
|
||||
|
Loading…
Reference in New Issue
Block a user