From 972a96f1a08f85b0a73680e33c02fe5c6c2593df Mon Sep 17 00:00:00 2001 From: Ondrej Mikle Date: Wed, 28 Aug 2019 15:55:39 +0200 Subject: [PATCH] core/modtrezorio: raise error when no space left on FAT FS --- core/embed/extmod/modtrezorio/modtrezorio-fatfs.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/embed/extmod/modtrezorio/modtrezorio-fatfs.h b/core/embed/extmod/modtrezorio/modtrezorio-fatfs.h index cdc3649f7..ea72f532b 100644 --- a/core/embed/extmod/modtrezorio/modtrezorio-fatfs.h +++ b/core/embed/extmod/modtrezorio/modtrezorio-fatfs.h @@ -184,6 +184,10 @@ STATIC mp_obj_t mod_trezorio_FatFSFile_write(mp_obj_t self, mp_obj_t data) { if (res != FR_OK) { mp_raise_OSError(fresult_to_errno_table[res]); } + if (written != buf.len) { + /* no space left on device or free clusters recorded in FSInfo fell to 0 */ + mp_raise_OSError(MP_ENOSPC); + } return mp_obj_new_int_from_uint(written); } STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_trezorio_FatFSFile_write_obj, mod_trezorio_FatFSFile_write);