@@ -206,22 +206,24 @@ static mp_obj_t mp_vfs_autodetect(mp_obj_t bdev_obj) {
206206}
207207
208208mp_obj_t mp_vfs_mount (size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
209- enum { ARG_readonly , ARG_mkfs };
209+ enum { ARG_fsobj , ARG_mount_point , ARG_readonly , ARG_mkfs };
210210 static const mp_arg_t allowed_args [] = {
211+ { MP_QSTR_ , MP_ARG_REQUIRED | MP_ARG_OBJ , {.u_obj = MP_OBJ_NULL } },
212+ { MP_QSTR_ , MP_ARG_REQUIRED | MP_ARG_OBJ , {.u_obj = MP_OBJ_NULL } },
211213 { MP_QSTR_readonly , MP_ARG_KW_ONLY | MP_ARG_OBJ , {.u_rom_obj = MP_ROM_FALSE } },
212214 { MP_QSTR_mkfs , MP_ARG_KW_ONLY | MP_ARG_OBJ , {.u_rom_obj = MP_ROM_FALSE } },
213215 };
214216
215217 // parse args
216218 mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
217- mp_arg_parse_all (n_args - 2 , pos_args + 2 , kw_args , MP_ARRAY_SIZE (allowed_args ), allowed_args , args );
219+ mp_arg_parse_all (n_args , pos_args , kw_args , MP_ARRAY_SIZE (allowed_args ), allowed_args , args );
218220
219221 // get the mount point
220222 size_t mnt_len ;
221- const char * mnt_str = mp_obj_str_get_data (pos_args [ 1 ] , & mnt_len );
223+ const char * mnt_str = mp_obj_str_get_data (args [ ARG_mount_point ]. u_obj , & mnt_len );
222224
223225 // see if we need to auto-detect and create the filesystem
224- mp_obj_t vfs_obj = pos_args [ 0 ] ;
226+ mp_obj_t vfs_obj = args [ ARG_fsobj ]. u_obj ;
225227 mp_obj_t dest [2 ];
226228 mp_load_method_maybe (vfs_obj , MP_QSTR_mount , dest );
227229 if (dest [0 ] == MP_OBJ_NULL ) {
@@ -238,11 +240,13 @@ mp_obj_t mp_vfs_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args
238240 vfs -> next = NULL ;
239241
240242 // call the underlying object to do any mounting operation
241- mp_vfs_proxy_call (vfs , MP_QSTR_mount , 2 , (mp_obj_t * )& args );
243+ mp_arg_val_t * proxy_args = & args [ARG_readonly ];
244+ size_t proxy_args_len = MP_ARRAY_SIZE (args ) - ARG_readonly ;
245+ mp_vfs_proxy_call (vfs , MP_QSTR_mount , proxy_args_len , (mp_obj_t * )proxy_args );
242246
243247 // check that the destination mount point is unused
244248 const char * path_out ;
245- mp_vfs_mount_t * existing_mount = mp_vfs_lookup_path (mp_obj_str_get_str (pos_args [ 1 ] ), & path_out );
249+ mp_vfs_mount_t * existing_mount = mp_vfs_lookup_path (mp_obj_str_get_str (args [ ARG_mount_point ]. u_obj ), & path_out );
246250 if (existing_mount != MP_VFS_NONE && existing_mount != MP_VFS_ROOT ) {
247251 if (vfs -> len != 1 && existing_mount -> len == 1 ) {
248252 // if root dir is mounted, still allow to mount something within a subdir of root
@@ -266,7 +270,7 @@ mp_obj_t mp_vfs_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args
266270
267271 return mp_const_none ;
268272}
269- MP_DEFINE_CONST_FUN_OBJ_KW (mp_vfs_mount_obj , 2 , mp_vfs_mount );
273+ MP_DEFINE_CONST_FUN_OBJ_KW (mp_vfs_mount_obj , 0 , mp_vfs_mount );
270274
271275mp_obj_t mp_vfs_umount (mp_obj_t mnt_in ) {
272276 // remove vfs from the mount table
0 commit comments