@@ -66,31 +66,31 @@ STATIC mp_obj_t pyb_mount(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *
6666 }
6767
6868 // create new object
69- MP_STATE_PORT (fs_user_mount ) = m_new_obj (fs_user_mount_t );
70- MP_STATE_PORT (fs_user_mount )-> str = mnt_str ;
71- MP_STATE_PORT (fs_user_mount )-> len = mnt_len ;
69+ fs_user_mount_t * vfs ;
70+ MP_STATE_PORT (fs_user_mount ) = vfs = m_new_obj (fs_user_mount_t );
71+ vfs -> str = mnt_str ;
72+ vfs -> len = mnt_len ;
7273
7374 // load block protocol methods
74- mp_load_method (device , MP_QSTR_readblocks , MP_STATE_PORT ( fs_user_mount ) -> readblocks );
75- mp_load_method_maybe (device , MP_QSTR_writeblocks , MP_STATE_PORT ( fs_user_mount ) -> writeblocks );
76- mp_load_method_maybe (device , MP_QSTR_sync , MP_STATE_PORT ( fs_user_mount ) -> sync );
77- mp_load_method (device , MP_QSTR_count , MP_STATE_PORT ( fs_user_mount ) -> count );
75+ mp_load_method (device , MP_QSTR_readblocks , vfs -> readblocks );
76+ mp_load_method_maybe (device , MP_QSTR_writeblocks , vfs -> writeblocks );
77+ mp_load_method_maybe (device , MP_QSTR_sync , vfs -> sync );
78+ mp_load_method (device , MP_QSTR_count , vfs -> count );
7879
7980 // Read-only device indicated by writeblocks[0] == MP_OBJ_NULL.
8081 // User can specify read-only device by:
8182 // 1. readonly=True keyword argument
8283 // 2. nonexistent writeblocks method (then writeblocks[0] == MP_OBJ_NULL already)
8384 if (args [0 ].u_bool ) {
84- MP_STATE_PORT ( fs_user_mount ) -> writeblocks [0 ] = MP_OBJ_NULL ;
85+ vfs -> writeblocks [0 ] = MP_OBJ_NULL ;
8586 }
8687
8788 // mount the block device
88- FRESULT res = f_mount (& MP_STATE_PORT (fs_user_mount )-> fatfs , MP_STATE_PORT (fs_user_mount )-> str , 1 );
89-
89+ FRESULT res = f_mount (& vfs -> fatfs , vfs -> str , 1 );
9090 // check the result
9191 if (res == FR_OK ) {
9292 } else if (res == FR_NO_FILESYSTEM && args [1 ].u_bool ) {
93- res = f_mkfs (MP_STATE_PORT ( fs_user_mount ) -> str , 1 , 0 );
93+ res = f_mkfs (vfs -> str , 1 , 0 );
9494 if (res != FR_OK ) {
9595 nlr_raise (mp_obj_new_exception_msg (& mp_type_OSError , "can't mkfs" ));
9696 }
@@ -99,15 +99,15 @@ STATIC mp_obj_t pyb_mount(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *
9999 }
100100
101101 /*
102- if (MP_STATE_PORT(fs_user_mount) ->writeblocks[0] == MP_OBJ_NULL) {
102+ if (vfs ->writeblocks[0] == MP_OBJ_NULL) {
103103 printf("mounted read-only");
104104 } else {
105105 printf("mounted read-write");
106106 }
107107 DWORD nclst;
108108 FATFS *fatfs;
109- f_getfree(MP_STATE_PORT(fs_user_mount) ->str, &nclst, &fatfs);
110- printf(" on %s with %u bytes free\n", MP_STATE_PORT(fs_user_mount) ->str, (uint)(nclst * fatfs->csize * 512));
109+ f_getfree(vfs ->str, &nclst, &fatfs);
110+ printf(" on %s with %u bytes free\n", vfs ->str, (uint)(nclst * fatfs->csize * 512));
111111 */
112112 }
113113 return mp_const_none ;
0 commit comments