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>
This commit is contained in:
@@ -74,6 +74,14 @@ print(uos.statvfs("/")[9] >= 32)
|
||||
# getcwd when in root dir
|
||||
print(uos.getcwd())
|
||||
|
||||
# test operations on the root directory with nothing mounted, they should all fail
|
||||
for func in ("chdir", "listdir", "mkdir", "remove", "rmdir", "stat"):
|
||||
for arg in ("x", "/x"):
|
||||
try:
|
||||
getattr(uos, func)(arg)
|
||||
except OSError:
|
||||
print(func, arg, "OSError")
|
||||
|
||||
# basic mounting and listdir
|
||||
uos.mount(Filesystem(1), "/test_mnt")
|
||||
print(uos.listdir())
|
||||
|
||||
Reference in New Issue
Block a user