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

Function dfs_file_fsync

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

* @brief Synchronize file data to storage device * * This function flushes all modified file data and metadata to the underlying storage device. * It ensures data integrity by: * - Flushing page cache if enabled (RT_USING_PAGECACHE) * - Calling filesystem-specific flush operation * * @param[in] file Pointer to the file structure to synchronize * * @return int Operation result: *

Source from the content-addressed store, hash-verified

1634 * about data persistence on storage media
1635 */
1636int dfs_file_fsync(struct dfs_file *file)
1637{
1638 int ret = -EBADF;
1639
1640 if (file)
1641 {
1642 if (file->fops->flush)
1643 {
1644 if (dfs_is_mounted(file->vnode->mnt) == 0)
1645 {
1646#ifdef RT_USING_PAGECACHE
1647 if (file->vnode->aspace)
1648 {
1649 dfs_aspace_flush(file->vnode->aspace);
1650 }
1651#endif
1652 ret = file->fops->flush(file);
1653 }
1654 else
1655 {
1656 ret = -EINVAL;
1657 }
1658 }
1659 }
1660
1661 return ret;
1662}
1663
1664/**
1665 * @brief Delete a file or directory entry from the filesystem

Callers 1

fsyncFunction · 0.85

Calls 2

dfs_is_mountedFunction · 0.85
dfs_aspace_flushFunction · 0.85

Tested by

no test coverage detected