* @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
| 2262 | * @note If RT_USING_PAGECACHE is enabled, the page cache will be flushed first |
| 2263 | */ |
| 2264 | int 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 |
nothing calls this directly
no test coverage detected