Commit f4ab9d9247 inadvertently broke some
Python block devices, for example esp32 and stm32 SDCard classes. Those
classes return a bool from their `readblocks` and `writeblocks` methods
instead of an integer errno code. With that change, both `False` and
`True` return values are now be interpreted as non-zero and hence the block
device call fails.
The fix in this commit is to allow a bool and explicitly convert `True` to
0 and `False` to `-MP_EIO`.
Signed-off-by: Damien George <damien@micropython.org>
- Code size saving as all of these functions are very similar.
- Resolves the "TODO" of the plain read and write functions not propagating
errors. An error in the underlying block device now causes VFatFs to
return EIO, for example.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
A positive result here can result in eventual memory corruption
as littlefs expects the result of a cache read/write function to be
0 or a negative integer for an error.
Closes#13046
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit adds helper functions to call readblocks/writeblocks with a
fourth argument, the byte offset within a block.
Although the mp_vfs_blockdev_t struct has grown here by 2 machine words, in
all current uses of this struct within this repository it still fits within
the same number of GC blocks.