You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ag...@apache.org on 2021/02/26 10:45:07 UTC

[incubator-nuttx] 01/02: fs/lfs: lfs_file_sync() when littlefs_open

This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit ac528203fea423731df48861e918a856bc33d78f
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Wed Feb 24 13:26:58 2021 +0800

    fs/lfs: lfs_file_sync() when littlefs_open
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
    Signed-off-by: ligd <li...@xiaomi.com>
    Change-Id: I8935f7aee414580174141f4b114b5faf03ffafd5
---
 fs/littlefs/lfs_vfs.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fs/littlefs/lfs_vfs.c b/fs/littlefs/lfs_vfs.c
index ffaa5a2..4cc41c4 100644
--- a/fs/littlefs/lfs_vfs.c
+++ b/fs/littlefs/lfs_vfs.c
@@ -55,7 +55,7 @@ struct littlefs_mountpt_s
   FAR struct inode     *drv;
   struct mtd_geometry_s geo;
   struct lfs_config     cfg;
-  lfs_t                 lfs;
+  struct lfs            lfs;
 };
 
 /****************************************************************************
@@ -279,6 +279,12 @@ static int littlefs_open(FAR struct file *filep, FAR const char *relpath,
         }
     }
 
+  /* Sync here in case of O_TRUNC haven't actually done immediately,
+   * e.g. total 8M, fileA 6M, O_TRUNC re-wrting fileA 6M, meet error.
+   */
+
+  lfs_file_sync(&fs->lfs, priv);
+
   littlefs_semgive(fs);
 
   /* Attach the private date to the struct file instance */