From dbf1a2f7d55c8fc80df699c3a5792a29c46ea3e2 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 21 Jun 2018 09:24:40 -0400 Subject: allow '/' to be mounted on '/' from Python code --- shared-module/storage/__init__.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'shared-module') diff --git a/shared-module/storage/__init__.c b/shared-module/storage/__init__.c index cc10ebd5a..edce286b1 100644 --- a/shared-module/storage/__init__.c +++ b/shared-module/storage/__init__.c @@ -65,12 +65,15 @@ void common_hal_storage_mount(mp_obj_t vfs_obj, const char* mount_path, bool rea args[1] = mp_const_false; // Don't make the file system automatically when mounting. // Check that there's no file or directory with the same name as the mount point. - nlr_buf_t nlr; - if (nlr_push(&nlr) == 0) { - common_hal_os_stat(mount_path); - nlr_pop(); - // Something with the same name exists. - mp_raise_OSError(MP_EEXIST); + // But it's ok to mount '/' in any case. + if (strcmp(vfs->str, "/") != 0) { + nlr_buf_t nlr; + if (nlr_push(&nlr) == 0) { + common_hal_os_stat(mount_path); + nlr_pop(); + // Something with the same name exists. + mp_raise_OSError(MP_EEXIST); + } } // check that the destination mount point is unused -- cgit v1.2.3