* @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: *
| 1634 | * about data persistence on storage media |
| 1635 | */ |
| 1636 | int 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 |
no test coverage detected