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 "generic" attributes #196

Open
josesimoes opened this issue Jul 23, 2024 · 5 comments
Open

Support for "generic" attributes #196

josesimoes opened this issue Jul 23, 2024 · 5 comments

Comments

@josesimoes
Copy link

Any chance to add an API to get/set attributes?
A simple byte will suffice to hold the simple (and usual ones) like hidden, read-only, system.
littlefs has this and I've noticed this already being used to store a time stamp.

@BrianPugh
Copy link
Member

I haven't had too much of a chance to think about this, but it might be kind of complicated to expose. Lets say we want two functions:

esp_err_t esp_littlefs_getattr(const char *path, uint8_t type, void *buffer, size_t size);
esp_err_t esp_littlefs_setattr(const char *path, uint8_t type, void *buffer, size_t size);

We need to get the esp_littlefs_t context from the path. Normally, this is handled by esp-idf's VFS and passed along to a bunch of hooks that we register. Just skimming the vfs page, I don't see a function that goes from path to context. This is to:

  1. Get the main lfs object.
  2. Get the correct mutexs so it's all threadsafe.
  3. Get the correct path (vfs removes the mounting point prefix for you).

So if we have a way to do that, I can add this functionality.

@josesimoes
Copy link
Author

I see... so... what is missing is a "proxy" call in the VFS API to make the bridge, correct?

@BrianPugh
Copy link
Member

pretty much. We basically need to translate/lookup the path to the esp_littlefs_context and relative path. E.g. /my_partition/my_folder/my_file.txt to esp_littlefs_t *efs and /my_folder/my_file.txt. If we have that, we can add this feature without much effort.

@BrianPugh
Copy link
Member

There are the private get_vfs_for_path and translate_path functions that do exactly what we need, but I'd be a bit hesitant to reach in and use those.

@josesimoes
Copy link
Author

@BrianPugh that looks like a good path forward. Understood those are private, still... 😉
Following this I took the liberty to suggest adding API to get/set attributes in VFS. Please follow the issue here espressif/esp-idf#14248.

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

2 participants