feat: add sync() to vfs

新增sync方法,该方法每次调用,会遍历系统内所有的mount点,调用各个文件系统注册
的sync方法,完成对所有已挂载文件系统的sync操作。

close #I480HV

Signed-off-by: Guangyao Ma <guangyao.ma@outlook.com>
Change-Id: I57ced9c3f7685a448defd17ae56c842796b5668f
This commit is contained in:
Guangyao Ma
2021-08-31 15:50:00 +08:00
parent de8257bc82
commit f67c4dae51
7 changed files with 29 additions and 27 deletions

View File

@@ -34,6 +34,7 @@
#include "ff.h"
#include "disk_pri.h"
#include "diskio.h"
#include "fs/file.h"
#include "fs/fs.h"
#include "fs/dirent_fs.h"
#include "fs/mount.h"
@@ -1297,6 +1298,29 @@ int fatfs_umount(struct Mount *mnt, struct Vnode **blkdriver)
return 0;
}
int fatfs_sync_adapt(struct Mount *mnt)
{
(void)mnt;
int ret = 0;
#ifdef LOSCFG_FS_FAT_CACHE
struct Vnode *dev = NULL;
los_part *part = NULL;
if (mnt == NULL) {
return -EINVAL;
}
dev = mnt->vnodeDev;
part = los_part_find(dev);
if (part == NULL) {
return -EINVAL;
}
ret = OsSdSync(part->disk_id);
#endif
return ret;
}
int fatfs_statfs(struct Mount *mnt, struct statfs *info)
{
FATFS *fs = (FATFS *)mnt->data;
@@ -2207,6 +2231,7 @@ struct MountOps fatfs_mops = {
.Mount = fatfs_mount,
.Unmount = fatfs_umount,
.Statfs = fatfs_statfs,
.Sync = fatfs_sync_adapt,
};
struct file_operations_vfs fatfs_fops = {