fs: Add file system API to flush cache of an open file
This API flushes the cached data of an open file to the storage media. This can be called after writes to avoid data loss if power is removed unexpectedly. Jira: ZEP-767 Change-Id: I0f99f2f34126aa8e6a43f69c7a1b6d903937de11 Signed-off-by: Ramesh Thomas <ramesh.thomas@intel.com>
This commit is contained in:
parent
524004d54b
commit
97d8fd1748
@ -194,6 +194,15 @@ int fs_truncate(ZFILE *zfp, off_t length)
|
||||
return translate_error(res);
|
||||
}
|
||||
|
||||
int fs_sync(ZFILE *zfp)
|
||||
{
|
||||
FRESULT res = FR_OK;
|
||||
|
||||
res = f_sync(&zfp->fp);
|
||||
|
||||
return translate_error(res);
|
||||
}
|
||||
|
||||
int fs_mkdir(const char *path)
|
||||
{
|
||||
FRESULT res;
|
||||
|
||||
16
include/fs.h
16
include/fs.h
@ -233,6 +233,22 @@ off_t fs_tell(ZFILE *zfp);
|
||||
*/
|
||||
int fs_truncate(ZFILE *zfp, off_t length);
|
||||
|
||||
/**
|
||||
* @brief Flushes any cached write of an open file
|
||||
*
|
||||
* This function can be used to flush the cache of an open file. This can
|
||||
* be called to ensure data gets written to the storage media immediately.
|
||||
* This may be done to avoid data loss if power is removed unexpectedly.
|
||||
* Note that closing a file will cause caches to be flushed correctly so it
|
||||
* need not be called if the file is being closed.
|
||||
*
|
||||
* @param zfp Pointer to the file object
|
||||
*
|
||||
* @retval 0 Success
|
||||
* @retval -ERRNO errno code if error
|
||||
*/
|
||||
int fs_sync(ZFILE *zfp);
|
||||
|
||||
/**
|
||||
* @brief Directory create
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user