Merge pull request #953 from dhalbert/allow-mount-slash
Allow mounting '/' on '/'
This commit is contained in:
commit
5ae8094747
|
@ -135,7 +135,7 @@ DRESULT disk_read (
|
||||||
if (nlr_push(&nlr) == 0) {
|
if (nlr_push(&nlr) == 0) {
|
||||||
mp_obj_t ret = mp_call_method_n_kw(2, 0, vfs->readblocks);
|
mp_obj_t ret = mp_call_method_n_kw(2, 0, vfs->readblocks);
|
||||||
nlr_pop();
|
nlr_pop();
|
||||||
if (mp_obj_get_int(ret) != 0) {
|
if (ret != mp_const_none && MP_OBJ_SMALL_INT_VALUE(ret) != 0) {
|
||||||
return RES_ERROR;
|
return RES_ERROR;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -180,7 +180,7 @@ DRESULT disk_write (
|
||||||
if (nlr_push(&nlr) == 0) {
|
if (nlr_push(&nlr) == 0) {
|
||||||
mp_obj_t ret = mp_call_method_n_kw(2, 0, vfs->writeblocks);
|
mp_obj_t ret = mp_call_method_n_kw(2, 0, vfs->writeblocks);
|
||||||
nlr_pop();
|
nlr_pop();
|
||||||
if (mp_obj_get_int(ret) != 0) {
|
if (ret != mp_const_none && MP_OBJ_SMALL_INT_VALUE(ret) != 0) {
|
||||||
return RES_ERROR;
|
return RES_ERROR;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -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.
|
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.
|
// Check that there's no file or directory with the same name as the mount point.
|
||||||
nlr_buf_t nlr;
|
// But it's ok to mount '/' in any case.
|
||||||
if (nlr_push(&nlr) == 0) {
|
if (strcmp(vfs->str, "/") != 0) {
|
||||||
common_hal_os_stat(mount_path);
|
nlr_buf_t nlr;
|
||||||
nlr_pop();
|
if (nlr_push(&nlr) == 0) {
|
||||||
// Something with the same name exists.
|
common_hal_os_stat(mount_path);
|
||||||
mp_raise_OSError(MP_EEXIST);
|
nlr_pop();
|
||||||
|
// Something with the same name exists.
|
||||||
|
mp_raise_OSError(MP_EEXIST);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check that the destination mount point is unused
|
// check that the destination mount point is unused
|
||||||
|
|
Loading…
Reference in New Issue