diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2018-06-26 10:50:15 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-06-26 10:50:15 -0700 |
| commit | dc9e9317ca038facb21710831c0219d00e27eb00 (patch) | |
| tree | 3e692c6ed838e9340620589420179c70604a9e08 | |
| parent | c1924f375d5398586887fc68b778080c420f9d4c (diff) | |
| parent | a7d3053049908c16424b2df17a484a99f9be4e9f (diff) | |
Merge pull request #962 from dhalbert/3.x_to_master-1
3.x to master 1
| -rw-r--r-- | extmod/vfs_fat_diskio.c | 4 | ||||
| -rw-r--r-- | shared-module/storage/__init__.c | 15 |
2 files changed, 11 insertions, 8 deletions
diff --git a/extmod/vfs_fat_diskio.c b/extmod/vfs_fat_diskio.c index 43c390a11..a147d601a 100644 --- a/extmod/vfs_fat_diskio.c +++ b/extmod/vfs_fat_diskio.c @@ -135,7 +135,7 @@ DRESULT disk_read ( if (nlr_push(&nlr) == 0) { mp_obj_t ret = mp_call_method_n_kw(2, 0, vfs->readblocks); nlr_pop(); - if (mp_obj_get_int(ret) != 0) { + if (ret != mp_const_none && MP_OBJ_SMALL_INT_VALUE(ret) != 0) { return RES_ERROR; } } else { @@ -180,7 +180,7 @@ DRESULT disk_write ( if (nlr_push(&nlr) == 0) { mp_obj_t ret = mp_call_method_n_kw(2, 0, vfs->writeblocks); nlr_pop(); - if (mp_obj_get_int(ret) != 0) { + if (ret != mp_const_none && MP_OBJ_SMALL_INT_VALUE(ret) != 0) { return RES_ERROR; } } else { 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 |
