|
45 | 45 | #include "py/gc.h"
|
46 | 46 | #include "py/objstr.h"
|
47 | 47 | #include "py/cstack.h"
|
| 48 | +#include "py/mperrno.h" |
48 | 49 | #include "py/mphal.h"
|
49 | 50 | #include "py/mpthread.h"
|
50 | 51 | #include "extmod/misc.h"
|
@@ -548,7 +549,14 @@ MP_NOINLINE int main_(int argc, char **argv) {
|
548 | 549 | MP_OBJ_NEW_QSTR(MP_QSTR__slash_),
|
549 | 550 | };
|
550 | 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. |
551 | 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 | + } |
552 | 560 | }
|
553 | 561 | #endif
|
554 | 562 |
|
@@ -803,3 +811,22 @@ void nlr_jump_fail(void *val) {
|
803 | 811 | fprintf(stderr, "FATAL: uncaught NLR %p\n", val);
|
804 | 812 | exit(1);
|
805 | 813 | }
|
| 814 | + |
| 815 | +#if MICROPY_VFS_ROM_IOCTL |
| 816 | + |
| 817 | +static uint8_t romfs_buf[4] = { 0xd2, 0xcd, 0x31, 0x00 }; // empty ROMFS |
| 818 | +static const MP_DEFINE_MEMORYVIEW_OBJ(romfs_obj, 'B', 0, sizeof(romfs_buf), romfs_buf); |
| 819 | + |
| 820 | +mp_obj_t mp_vfs_rom_ioctl(size_t n_args, const mp_obj_t *args) { |
| 821 | + switch (mp_obj_get_int(args[0])) { |
| 822 | + case MP_VFS_ROM_IOCTL_GET_NUMBER_OF_SEGMENTS: |
| 823 | + return MP_OBJ_NEW_SMALL_INT(1); |
| 824 | + |
| 825 | + case MP_VFS_ROM_IOCTL_GET_SEGMENT: |
| 826 | + return MP_OBJ_FROM_PTR(&romfs_obj); |
| 827 | + } |
| 828 | + |
| 829 | + return MP_OBJ_NEW_SMALL_INT(-MP_EINVAL); |
| 830 | +} |
| 831 | + |
| 832 | +#endif |
0 commit comments