Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changing devices/filesystems has multiple issues #45

Open
A-Dunstan opened this issue May 11, 2024 · 0 comments
Open

changing devices/filesystems has multiple issues #45

A-Dunstan opened this issue May 11, 2024 · 0 comments

Comments

@A-Dunstan
Copy link

A-Dunstan commented May 11, 2024

Seeing a few issues with MTP if you want to physically remove a device and re-insert a different one:

  • Calling only MTP.send_StoreRemovedEvent() and MTP.send_StoreAddedEvent(), like MTP_SD_Callback does, is very inadequate. All it does is send events to the host without notifying MTPStorage, so all the previously indexed content from the previous card remains and gets reused for the new card...
  • There's no method on the main MTP object to completely remove a filesystem. There is MTPStorage.removeFilesystem() so you can do MTP.storage()->removeFilesystem(x) but you need the store id for that.
  • The index file is by default created on the first storage object. Bad Things Happen if that storage object goes away.
  • MTPStorage.file_ may be left open from a previous operation by the host. The next time OpenFileByIndex is called, it will try to close file_ and may blow up because the filesystem that the File uses no longer exists / has been replaced. This is especially obvious when the "old" SD card is FAT16/FAT32 and gets replaced by an EXFAT card, because the FAT/EXFAT volumes have very different structure but occupy the same memory in the SD object.

It's also a bit annoying that MTPStorage has a public method to register a class loop callback, but the fstype parameter (for this function, MTP.addFilesystem and several others) is an enum - meaning it's limited to the values already defined in the header rather than user-defined custom values. So if a user wants to add their own filesystem types with loop callbacks, they have to hijack one of the pre-defined values...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant