@@ -206,22 +206,24 @@ static mp_obj_t mp_vfs_autodetect(mp_obj_t bdev_obj) {
206
206
}
207
207
208
208
mp_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 };
210
210
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 } },
211
213
{ MP_QSTR_readonly , MP_ARG_KW_ONLY | MP_ARG_OBJ , {.u_rom_obj = MP_ROM_FALSE } },
212
214
{ MP_QSTR_mkfs , MP_ARG_KW_ONLY | MP_ARG_OBJ , {.u_rom_obj = MP_ROM_FALSE } },
213
215
};
214
216
215
217
// parse args
216
218
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 );
218
220
219
221
// get the mount point
220
222
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 );
222
224
223
225
// 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 ;
225
227
mp_obj_t dest [2 ];
226
228
mp_load_method_maybe (vfs_obj , MP_QSTR_mount , dest );
227
229
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
238
240
vfs -> next = NULL ;
239
241
240
242
// 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 );
242
246
243
247
// check that the destination mount point is unused
244
248
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 );
246
250
if (existing_mount != MP_VFS_NONE && existing_mount != MP_VFS_ROOT ) {
247
251
if (vfs -> len != 1 && existing_mount -> len == 1 ) {
248
252
// 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
266
270
267
271
return mp_const_none ;
268
272
}
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 );
270
274
271
275
mp_obj_t mp_vfs_umount (mp_obj_t mnt_in ) {
272
276
// remove vfs from the mount table
0 commit comments