Specifically give a better error message for setlabel on RO fs

This commit is contained in:
Jeff Epler 2018-03-27 21:28:19 -05:00
parent fe7f405fc7
commit 9c47fd9c13
1 changed files with 3 additions and 0 deletions

View File

@ -335,6 +335,9 @@ static mp_obj_t vfs_fat_setlabel(mp_obj_t self_in, mp_obj_t label_in) {
const char *label_str = mp_obj_str_get_str(label_in);
FRESULT res = f_setlabel(&self->fatfs, label_str);
if (res != FR_OK) {
if(res == FR_WRITE_PROTECTED) {
mp_raise_msg(&mp_type_OSError, "Read-only filesystem");
}
mp_raise_OSError(fresult_to_errno_table[res]);
}
return mp_const_none;