summaryrefslogtreecommitdiff
path: root/nuttx/fs/smartfs
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-09-22 09:33:58 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-09-22 09:33:58 -0600
commit1568fdfbd9677d6e303daab5ffe9838578d350b9 (patch)
treecd6ffb1fc00fe34b1a75f5e764d692b73d655d5c /nuttx/fs/smartfs
parent57f8ffec646b0b923bd609bb7798b77403933fb7 (diff)
downloadnuttx-1568fdfbd9677d6e303daab5ffe9838578d350b9.tar.gz
nuttx-1568fdfbd9677d6e303daab5ffe9838578d350b9.tar.bz2
nuttx-1568fdfbd9677d6e303daab5ffe9838578d350b9.zip
SMART FS update from Ken Pettit
Diffstat (limited to 'nuttx/fs/smartfs')
-rw-r--r--nuttx/fs/smartfs/smartfs_smart.c50
1 files changed, 28 insertions, 22 deletions
diff --git a/nuttx/fs/smartfs/smartfs_smart.c b/nuttx/fs/smartfs/smartfs_smart.c
index d58c0f0e5..f221b49f6 100644
--- a/nuttx/fs/smartfs/smartfs_smart.c
+++ b/nuttx/fs/smartfs/smartfs_smart.c
@@ -710,19 +710,22 @@ static ssize_t smartfs_write(FAR struct file *filep, const char *buffer,
/* Now perform the write. */
- ret = FS_IOCTL(fs, BIOC_WRITESECT, (unsigned long) &readwrite);
- if (ret < 0)
+ if (readwrite.count > 0)
{
- fdbg("Error %d writing sector %d data\n", ret, sf->currsector);
- goto errout_with_semaphore;
- }
+ ret = FS_IOCTL(fs, BIOC_WRITESECT, (unsigned long) &readwrite);
+ if (ret < 0)
+ {
+ fdbg("Error %d writing sector %d data\n", ret, sf->currsector);
+ goto errout_with_semaphore;
+ }
- /* Update our control variables */
+ /* Update our control variables */
- sf->filepos += readwrite.count;
- sf->curroffset += readwrite.count;
- buflen -= readwrite.count;
- byteswritten += readwrite.count;
+ sf->filepos += readwrite.count;
+ sf->curroffset += readwrite.count;
+ buflen -= readwrite.count;
+ byteswritten += readwrite.count;
+ }
/* Test if we wrote to the end of the current sector */
@@ -771,21 +774,24 @@ static ssize_t smartfs_write(FAR struct file *filep, const char *buffer,
/* Perform the write */
- ret = FS_IOCTL(fs, BIOC_WRITESECT, (unsigned long) &readwrite);
- if (ret < 0)
+ if (readwrite.count > 0)
{
- fdbg("Error %d writing sector %d data\n", ret, sf->currsector);
- goto errout_with_semaphore;
- }
+ ret = FS_IOCTL(fs, BIOC_WRITESECT, (unsigned long) &readwrite);
+ if (ret < 0)
+ {
+ fdbg("Error %d writing sector %d data\n", ret, sf->currsector);
+ goto errout_with_semaphore;
+ }
- /* Update our control variables */
+ /* Update our control variables */
- sf->entry.datlen += readwrite.count;
- sf->byteswritten += readwrite.count;
- sf->filepos += readwrite.count;
- sf->curroffset += readwrite.count;
- buflen -= readwrite.count;
- byteswritten += readwrite.count;
+ sf->entry.datlen += readwrite.count;
+ sf->byteswritten += readwrite.count;
+ sf->filepos += readwrite.count;
+ sf->curroffset += readwrite.count;
+ buflen -= readwrite.count;
+ byteswritten += readwrite.count;
+ }
/* Test if we wrote a full sector of data */