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

Add support for attributes in VFS (IDFGH-13326) #14248

Open
josesimoes opened this issue Jul 25, 2024 · 4 comments
Open

Add support for attributes in VFS (IDFGH-13326) #14248

josesimoes opened this issue Jul 25, 2024 · 4 comments
Labels
Status: Opened Issue is new Type: Feature Request Feature request for IDF

Comments

@josesimoes
Copy link
Contributor

Is your feature request related to a problem?

Currently virtual file system doesn't provide support for attributes, which is something rather "basic" in a file system.

Describe the solution you'd like.

This doesn't need to be anything fancy, simple ones like hidden, read-only, system would be quite enough.
All file systems that VFS tapps into offer this: FatFS, littlefs, SPIFFS.

Describe alternatives you've considered.

No response

Additional context.

Stumbled into this when making the migration from SPIFFs to littlefs for the flash storage in .NET nanoFramework nanoframework/nf-interpreter#2911.

Already discussed it with the author of littlefs for ESP extension. Please see issue here joltwallet/esp_littlefs#196.
It seems that there is path forward, still I believe it would be nice to have a couple of API to get and set attributes.

@josesimoes josesimoes added the Type: Feature Request Feature request for IDF label Jul 25, 2024
@github-actions github-actions bot changed the title Add support for attributes in VFS Add support for attributes in VFS (IDFGH-13326) Jul 25, 2024
@espressif-bot espressif-bot added the Status: Opened Issue is new label Jul 25, 2024
@igrr
Copy link
Member

igrr commented Jul 25, 2024

@josesimoes what would be the equivalent API you would use on a POSIX platform for this purpose?

@josesimoes
Copy link
Contributor Author

I suppose the more suitable one would be chmod, right?
Still, hidden files would be missing because the current implementation lacks support for . started filenames, as stated in the docs.

I would suggest a more generic approach, such as providing setattr and getattr that accepts (or returns) an uint32 and then it's up to the file system to store and retrieve that number. It's up to the application layer to use as it sees fit.

@haberturdeur
Copy link
Collaborator

haberturdeur commented Dec 12, 2024

Just a note:

Still, hidden files would be missing because the current implementation lacks support for . started filenames, as stated in the docs.

That part only refers to using . as a reference to the "current" directory, not files starting with .. These will be treated as any other file.

POSIX itself does not specify that file operations such as readdir() should treat names starting with . in any special way either, it is up to the application (such as ls to do so.

The problem is that there is no "standardised" way to work with arbitrary user attributes, the closes thing is probably either stat or linux's xattr.

xattr would require storing "large" amounts of data (at least relatively to memory size of ESP32).

stat would be better in the size regard, but there might be problems with the linux target (also it is readonly).
(You could probably hack support for this using the st_mode field, if you had to, because it allows for implementation defined flags, with some restrictions)

(In theory you could also abuse fcntl and ioctl, since both of those are passed to the underlying FS (but that would require creating constants that would be unique across all filesystems...)

I would be hesitant to implement custom solution for the sake of portability.

PS: @josesimoes you mentioned that both FatFS and SPIFFS have support for attributes, did you mean the stat function? If not could you link the documentation for those please?

@josesimoes
Copy link
Contributor Author

@haberturdeur here they are:

littlefs has lfs_getattr

FatFS has chmod

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Opened Issue is new Type: Feature Request Feature request for IDF
Projects
None yet
Development

No branches or pull requests

4 participants