Skip to content

Support for dynamic BLOCK_COUNT #2

Open

Description

@jonas-schievink

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.

Activity

  1. nickray commented on Mar 3, 2020

    @nickray
    Member

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

  2. nickray commented on Mar 5, 2020

    @nickray
    Member
  3. added a commit that references this issue on Apr 12, 2023
  4. TheTechRobo commented on Jan 19, 2025

    @TheTechRobo

    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!

  5. robin-nitrokey commented on Jan 20, 2025

    @robin-nitrokey
    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.

  6. TheTechRobo commented on Jan 20, 2025

    @TheTechRobo

    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.

  7. robin-nitrokey commented on Jan 20, 2025

    @robin-nitrokey
    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?

  8. TheTechRobo commented on Jan 20, 2025

    @TheTechRobo

    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.

  9. Dominaezzz commented on Mar 17, 2025

    @Dominaezzz

    Would a PR for this be accepted? To turn all the consts in the trait into non-const functions?

  10. Dominaezzz commented on Mar 17, 2025

    @Dominaezzz

    Oh someone has made a PR already #101

  11. TheEnbyperor commented on Aug 23, 2025

    @TheEnbyperor

    Any indication of when this might be supported? I've just ran into the same problem developing for the ESP32 - where the parition table tells me how long the filesystem is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions