diff options
| author | Bernard Xiong <[email protected]> | 2015-07-16 10:35:42 +0800 |
|---|---|---|
| committer | Bernard Xiong <[email protected]> | 2015-07-16 10:35:42 +0800 |
| commit | 52e0d3ce0f4af4b689e3c63cff5c83a2158f143c (patch) | |
| tree | 66ebb64f015d23295aba6551872854c85e3883d7 /components/dfs | |
| parent | eb29a6877f39b540b69c649c47f5b4a365e44915 (diff) | |
[DFS] Add fsync function
Diffstat (limited to 'components/dfs')
| -rw-r--r-- | components/dfs/src/dfs_posix.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/components/dfs/src/dfs_posix.c b/components/dfs/src/dfs_posix.c index c1a6a5beb6..250f6eaf7f 100644 --- a/components/dfs/src/dfs_posix.c +++ b/components/dfs/src/dfs_posix.c @@ -375,6 +375,36 @@ int fstat(int fildes, struct stat *buf) RTM_EXPORT(fstat); /** + * this function is a POSIX compliant version, which shall request that all data + * for the open file descriptor named by fildes is to be transferred to the storage + * device associated with the file described by fildes. + * + * @param fildes the file description + * + * @return 0 on successful completion. Otherwise, -1 shall be returned and errno + * set to indicate the error. + */ +int fsync(int fildes) +{ + int ret; + struct dfs_fd *d; + + /* get the fd */ + d = fd_get(fildes); + if (d == RT_NULL) + { + rt_set_errno(-DFS_STATUS_EBADF); + return -1; + } + + ret = dfs_file_flush(d); + + fd_put(d); + return ret; +} +RTM_EXPORT(fsync); + +/** * this function is a POSIX compliant version, which will return the * information about a mounted file system. * |
