Browse Source

extmod/modos: Only sync FAT filesystems using disk_ioctl.

Eventually this needs to be made a generic call to the underlying VFS.  But
for now this prevents `disk_ioctl()` crashing on non-FAT filesystems.

Signed-off-by: Damien George <damien@micropython.org>
pull/15134/head
Damien George 5 months ago
parent
commit
c0a25a69eb
  1. 5
      extmod/modos.c

5
extmod/modos.c

@ -76,8 +76,9 @@
static mp_obj_t mp_os_sync(void) { static mp_obj_t mp_os_sync(void) {
#if MICROPY_VFS_FAT #if MICROPY_VFS_FAT
for (mp_vfs_mount_t *vfs = MP_STATE_VM(vfs_mount_table); vfs != NULL; vfs = vfs->next) { for (mp_vfs_mount_t *vfs = MP_STATE_VM(vfs_mount_table); vfs != NULL; vfs = vfs->next) {
// this assumes that vfs->obj is fs_user_mount_t with block device functions if (mp_obj_is_type(vfs->obj, &mp_fat_vfs_type)) {
disk_ioctl(MP_OBJ_TO_PTR(vfs->obj), CTRL_SYNC, NULL); disk_ioctl(MP_OBJ_TO_PTR(vfs->obj), CTRL_SYNC, NULL);
}
} }
#endif #endif
return mp_const_none; return mp_const_none;

Loading…
Cancel
Save