From 61f07e4661c81a174a91232e70515694929d02c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ada=20Gottenstr=C3=A4ter?= Date: Thu, 1 Jun 2023 15:49:10 +0200 Subject: [PATCH] Implement fflush for FAT VFS --- include/filesys/fatfs/fatfs.cc | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/include/filesys/fatfs/fatfs.cc b/include/filesys/fatfs/fatfs.cc index 5771dbc50..0bb9d34f2 100644 --- a/include/filesys/fatfs/fatfs.cc +++ b/include/filesys/fatfs/fatfs.cc @@ -420,6 +420,24 @@ int v_open(vfs_file_t *fil, const char *name, int flags) return 0; } +int v_flush(vfs_file_t *fil) { + FAT_FIL *vf = fil->vfsdata; + FIL *f = &vf->fil; + int result; + + if (!f) { + return _seterror(EBADF); + } +#ifdef DEBUG + __builtin_printf("v_flush() "); +#endif + result = f_sync(f); +#ifdef DEBUG + __builtin_printf("result=%d\n", result); +#endif + return _set_dos_error(result); +} + /* initialize (do first mount) */ /* for now this is a dummy function, but eventually some of the work * in _vfs_open_sdcardx could be done here @@ -449,7 +467,7 @@ static struct vfs fat_vfs = &v_lseek, &v_ioctl, - 0, /* no flush function */ + &v_flush, 0, /* vfs_data */ 0, /* reserved2 */