MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / dfs_file_flush

Function dfs_file_flush

components/dfs/dfs_v2/src/dfs_file.c:2264–2298  ·  view source on GitHub ↗

* @brief Flush file buffers to storage device * * This function forces any buffered data to be written to the underlying storage device. * * @param[in,out] file Pointer to the file structure to flush (both input and output) * * @return int Operation result: * - 0 on success * -EBADF if invalid file descriptor * -ENOSYS if flush operation not supported * -E

Source from the content-addressed store, hash-verified

2262 * @note If RT_USING_PAGECACHE is enabled, the page cache will be flushed first
2263 */
2264int dfs_file_flush(struct dfs_file *file)
2265{
2266 int ret = 0;
2267
2268 if (file)
2269 {
2270 if (file->fops->flush)
2271 {
2272 if (dfs_is_mounted(file->vnode->mnt) == 0)
2273 {
2274#ifdef RT_USING_PAGECACHE
2275 if (file->vnode->aspace)
2276 {
2277 dfs_aspace_flush(file->vnode->aspace);
2278 }
2279#endif
2280 ret = file->fops->flush(file);
2281 }
2282 else
2283 {
2284 ret = -EINVAL;
2285 }
2286 }
2287 else
2288 {
2289 ret = -ENOSYS;
2290 }
2291 }
2292 else
2293 {
2294 ret = -EBADF;
2295 }
2296
2297 return ret;
2298}
2299
2300/**
2301 * @brief Read directory entries

Callers

nothing calls this directly

Calls 2

dfs_is_mountedFunction · 0.85
dfs_aspace_flushFunction · 0.85

Tested by

no test coverage detected