Support for "generic" attributes
josesimoes opened this issue · 5 comments
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.
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:
- Get the main
lfs
object. - Get the correct mutexs so it's all threadsafe.
- 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.
I see... so... what is missing is a "proxy" call in the VFS API to make the bridge, correct?
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.
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.
@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.