Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion extmod/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ static mp_obj_t mp_vfs_autodetect(mp_obj_t bdev_obj) {
mp_vfs_blockdev_init(&blockdev, bdev_obj);
uint8_t buf[44];
for (size_t block_num = 0; block_num <= 1; ++block_num) {
mp_vfs_blockdev_read_ext(&blockdev, block_num, 8, sizeof(buf), buf);
if (mp_vfs_blockdev_read_ext(&blockdev, block_num, 8, sizeof(buf), buf) != 0) {
continue;
}
#if MICROPY_VFS_LFS1
if (memcmp(&buf[32], "littlefs", 8) == 0) {
// LFS1
Expand Down
17 changes: 17 additions & 0 deletions tests/extmod/vfs_blockdev_invalid.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,23 @@ def test(vfs_class, test_data):
assert error_read is not None
assert (type(e), str(e)) == error_read

# Try mounting this block device
#
# Failing mount operation will return EIO rather than EINVAL, but otherwise
# the result should match error_open
error_mount = ERROR_EIO if error_open == ERROR_EINVAL else error_open
try:
vfs.mount(bdev, "/test_ram")
assert error_mount is None
except Exception as e:
assert error_mount is not None
assert (type(e), str(e)) == error_mount
finally:
try:
vfs.umount("/test_ram")
except OSError:
pass


try:
test(
Expand Down
Loading