summaryrefslogtreecommitdiffstatshomepage
path: root/extmod
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2020-09-22 15:05:00 +1000
committerDamien George <damien@micropython.org>2020-09-23 16:23:35 +1000
commit71adf506ce43b55b859f81f191ac0826928bbdd5 (patch)
tree21e4910d2befb39f483dab861eb727f374105095 /extmod
parent3e16763201d879cfdd58fdf269fbe03a3d326675 (diff)
downloadmicropython-71adf506ce43b55b859f81f191ac0826928bbdd5.tar.gz
micropython-71adf506ce43b55b859f81f191ac0826928bbdd5.zip
extmod/vfs: Fix lookup of entry in root dir so it fails correctly.
Prior to this commit, uos.chdir('/') followed by uos.stat('noexist') would succeed that stat even though the entry did not exist (some other functions like listdir would have similar issues). This is because, if the current directory was the root and the path was relative, mp_vfs_lookup_path would return success for bad paths. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'extmod')
-rw-r--r--extmod/vfs.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/extmod/vfs.c b/extmod/vfs.c
index d1291068ad..3cb7af1b43 100644
--- a/extmod/vfs.c
+++ b/extmod/vfs.c
@@ -83,12 +83,8 @@ mp_vfs_mount_t *mp_vfs_lookup_path(const char *path, const char **path_out) {
}
}
- // if we get here then there's nothing mounted on /
-
- if (is_abs) {
- // path began with / and was not found
- return MP_VFS_NONE;
- }
+ // if we get here then there's nothing mounted on /, so the path doesn't exist
+ return MP_VFS_NONE;
}
// a relative path within a mounted device