Mounted filesystems USB write protection #10648
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
storage.mount(filesystem=, ...)argument to ensure it is aVfsFatobject.mount. But elsewhere in the code there are assumptions it is anfs_user_mount_t, which is a `VfsFat.#if 0for that reason, instead of just deleting this.stop_mp()unmounts user-mounted Vfs filesystems on VM shutdown. This used to assume that the user-mounted filesystems all came last. I think that is currently the case, but made this code more robust in case they are intermixed with non-user-mounted ones. Tested on a Fruit Jam with automounted filesystems and on an nRF52840 with a user-mounted SD card.#define PLAT_PRINTF(...) mp_printf(&mp_plat_print, __VA_ARGS__)incircuitpy_mpconfig.h. There are similar macros elsewhere, but only in specific files. I got tired of typing&mp_plat_print. I chose the name for minimal typing for auto-completion.@tannewt we discussed that
open()was not callingfilesystem_lock(), etc. I looked at adding these but it's not clear to me that the file objects are properly finalized on VM shutdown, etc., so the locks may not go back to their initial state. Given that this does not actually seem to be a problem right now, I am leaving it alone, to be fixed later when we make more objects have finalizers. This addition is the critical one for fixing the issue