@@ -549,7 +549,14 @@ MP_NOINLINE int main_(int argc, char **argv) {
549
549
MP_OBJ_NEW_QSTR (MP_QSTR__slash_ ),
550
550
};
551
551
mp_vfs_mount (2 , args , (mp_map_t * )& mp_const_empty_map );
552
+
553
+ // Make sure the root that was just mounted is the current VFS (it's always at
554
+ // the end of the linked list). Can't use chdir('/') because that will change
555
+ // the current path within the VfsPosix object.
552
556
MP_STATE_VM (vfs_cur ) = MP_STATE_VM (vfs_mount_table );
557
+ while (MP_STATE_VM (vfs_cur )-> next != NULL ) {
558
+ MP_STATE_VM (vfs_cur ) = MP_STATE_VM (vfs_cur )-> next ;
559
+ }
553
560
}
554
561
#endif
555
562
@@ -805,6 +812,21 @@ void nlr_jump_fail(void *val) {
805
812
exit (1 );
806
813
}
807
814
815
+ #if defined(MICROPY_UNIX_COVERAGE )
816
+ static uint8_t romfs_buf [4 ] = { 0xd2 , 0xcd , 0x31 , 0x00 }; // empty ROMFS
817
+ static const MP_DEFINE_MEMORYVIEW_OBJ (romfs_obj , 'B ', 0, sizeof(romfs_buf), romfs_buf);
818
+ #endif
819
+
808
820
mp_obj_t mp_vfs_rom_ioctl (size_t n_args , const mp_obj_t * args ) {
821
+ #if defined(MICROPY_UNIX_COVERAGE )
822
+ switch (mp_obj_get_int (args [0 ])) {
823
+ case MP_VFS_ROM_IOCTL_GET_NUMBER_OF_SEGMENTS :
824
+ return MP_OBJ_NEW_SMALL_INT (1 );
825
+
826
+ case MP_VFS_ROM_IOCTL_GET_SEGMENT :
827
+ return MP_OBJ_FROM_PTR (& romfs_obj );
828
+ }
829
+ #endif
830
+
809
831
return MP_OBJ_NEW_SMALL_INT (- MP_EINVAL );
810
832
}
0 commit comments