fs/lfs: lfs_file_sync() when littlefs_open

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
Change-Id: I8935f7aee414580174141f4b114b5faf03ffafd5
This commit is contained in:
Xiang Xiao 2021-02-24 13:26:58 +08:00 committed by Abdelatif Guettouche
parent 6cac6c50d1
commit ac528203fe

View File

@ -55,7 +55,7 @@ struct littlefs_mountpt_s
FAR struct inode *drv; FAR struct inode *drv;
struct mtd_geometry_s geo; struct mtd_geometry_s geo;
struct lfs_config cfg; 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); littlefs_semgive(fs);
/* Attach the private date to the struct file instance */ /* Attach the private date to the struct file instance */