fix vfs_fat build errors

This commit is contained in:
Jeff Epler 2023-09-22 13:38:46 -05:00
parent 23ad19fc5c
commit 886285cedc
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE
3 changed files with 8 additions and 7 deletions

View File

@ -361,7 +361,7 @@ mp_obj_t mp_vfs_getcwd(void) {
if (!(cwd[0] == '/' && cwd[1] == 0)) { if (!(cwd[0] == '/' && cwd[1] == 0)) {
vstr_add_str(&vstr, cwd); vstr_add_str(&vstr, cwd);
} }
return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); return mp_obj_new_str_from_vstr(&vstr);
} }
MP_DEFINE_CONST_FUN_OBJ_0(mp_vfs_getcwd_obj, mp_vfs_getcwd); MP_DEFINE_CONST_FUN_OBJ_0(mp_vfs_getcwd_obj, mp_vfs_getcwd);

View File

@ -136,6 +136,7 @@ STATIC MP_DEFINE_CONST_STATICMETHOD_OBJ(fat_vfs_mkfs_obj, MP_ROM_PTR(&fat_vfs_mk
typedef struct _mp_vfs_fat_ilistdir_it_t { typedef struct _mp_vfs_fat_ilistdir_it_t {
mp_obj_base_t base; mp_obj_base_t base;
mp_fun_1_t iternext; mp_fun_1_t iternext;
mp_fun_1_t finaliser;
bool is_str; bool is_str;
FF_DIR dir; FF_DIR dir;
} mp_vfs_fat_ilistdir_it_t; } mp_vfs_fat_ilistdir_it_t;

View File

@ -205,7 +205,7 @@ STATIC mp_obj_t fat_vfs_open(mp_obj_t self_in, mp_obj_t path_in, mp_obj_t mode_i
const mp_obj_type_t *type = &mp_type_vfs_fat_textio; const mp_obj_type_t *type = &mp_type_vfs_fat_textio;
int mode = 0; int mode = 0;
const char *mode_s = mp_obj_str_get_str(args[1].u_obj); const char *mode_s = mp_obj_str_get_str(mode_in);
uint32_t rwxa_count = 0; uint32_t rwxa_count = 0;
uint32_t bt_count = 0; uint32_t bt_count = 0;
uint32_t plus_count = 0; uint32_t plus_count = 0;
@ -252,8 +252,8 @@ STATIC mp_obj_t fat_vfs_open(mp_obj_t self_in, mp_obj_t path_in, mp_obj_t mode_i
mp_arg_error_invalid(MP_QSTR_mode); mp_arg_error_invalid(MP_QSTR_mode);
} }
assert(vfs != NULL); assert(self != NULL);
if ((mode & FA_WRITE) != 0 && !filesystem_is_writable_by_python(vfs)) { if ((mode & FA_WRITE) != 0 && !filesystem_is_writable_by_python(self)) {
mp_raise_OSError(MP_EROFS); mp_raise_OSError(MP_EROFS);
} }
@ -261,11 +261,11 @@ STATIC mp_obj_t fat_vfs_open(mp_obj_t self_in, mp_obj_t path_in, mp_obj_t mode_i
pyb_file_obj_t *o = m_new_obj_with_finaliser(pyb_file_obj_t); pyb_file_obj_t *o = m_new_obj_with_finaliser(pyb_file_obj_t);
o->base.type = type; o->base.type = type;
const char *fname = mp_obj_str_get_str(args[0].u_obj); const char *fname = mp_obj_str_get_str(path_in);
FRESULT res = f_open(&vfs->fatfs, &o->fp, fname, mode); FRESULT res = f_open(&self->fatfs, &o->fp, fname, mode);
if (res != FR_OK) { if (res != FR_OK) {
m_del_obj(pyb_file_obj_t, o); m_del_obj(pyb_file_obj_t, o);
mp_raise_OSError_errno_str(fresult_to_errno_table[res], args[0].u_obj); mp_raise_OSError_errno_str(fresult_to_errno_table[res], path_in);
} }
// CIRCUITPY does fast seek. // CIRCUITPY does fast seek.
// If we're reading, turn on fast seek. // If we're reading, turn on fast seek.