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

Support for dynamic BLOCK_COUNT #2

Open
jonas-schievink opened this issue Mar 2, 2020 · 7 comments
Open

Support for dynamic BLOCK_COUNT #2

jonas-schievink opened this issue Mar 2, 2020 · 7 comments

Comments

@jonas-schievink
Copy link

Currently the user has to statically know the device size since BLOCK_COUNT is an associated constant. It would be useful if it would be possible to dynamically determine the device size instead.

@nickray
Copy link
Member

nickray commented Mar 3, 2020

I agree, mount should read it from the metadata (where I believe it's stored), and format should take it as parameter.

@nickray
Copy link
Member

nickray commented Mar 5, 2020

Missing upstream: littlefs-project/littlefs#349

sosthene-nitrokey pushed a commit to sosthene-nitrokey/littlefs2 that referenced this issue Apr 12, 2023
@TheTechRobo
Copy link

Is it possible to pass the block count to the function at runtime if I know it, even if littlefs doesn't? Currently it seems I have to hardcode the volume size. I am developing for ESP32, and littlefs is using one partition of the flash. I can read the partition table, which gets me the length, and using that would make me feel much better than hardcoding the size.

If I've missed something please let me know!

@robin-nitrokey
Copy link
Member

Unfortunately this is currently not possible. We could remove all associated constants from the Storage trait and pass them to Allocation::new instead. The only downside is that the storage implementation could be called with unexpected offsets and block sizes, but it should probably validate those anyway.

@TheTechRobo
Copy link

That seems like a good idea to me. It would allow for reading any filesystem discovered at runtime, rather than just ones the developer thought of.

It is not a serious issue in my case: I came up with a workaround where the app reads the partition table and makes sure the hardcoded values are correct, which is robust enough for me. But it would be a nice feature.

The only downside is that the storage implementation could be called with unexpected offsets and block sizes, but it should probably validate those anyway.

Maybe constants vital to the Storage implementation (like block size) could be put in the trait? That would remove some flexibility, though.

@robin-nitrokey
Copy link
Member

Maybe constants vital to the Storage implementation (like block size) could be put in the trait?

Isn’t that what we have right now?

@TheTechRobo
Copy link

I meant the ones that are hardware-dependent, like block size. But rethinking it, yeah, it should probably be all or nothing, and force the Storage implementer to do validation.

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

4 participants