littlefs-project / littlefs

A little fail-safe filesystem designed for microcontrollers
BSD 3-Clause "New" or "Revised" License
4.9k stars 770 forks source link

When are file attributes finally written to "disk"? #956

Open RalfEsy opened 3 months ago

RalfEsy commented 3 months ago

When using _lfssetattr() it seems the attribute data are not immediately written to "disk" (the corresponding file was not open).

During the call of lfs_setattr() there was no call to the "program" function (_lfsconfig::prog) and after a restart of the system the file attribute is not available.

I wonder how I can enforce littlefs to perform the write to "disk"?

RalfEsy commented 3 months ago

I'm not sure if this is an issue on my side - I'll have to investigate this further...

geky commented 3 months ago

During the call of lfs_setattr() there was no call to the "program" function

This certainly shouldn't happen. Progs in littlefs may be cached sometimes, but not when metadata changes are involved. lfs_setattr is a small wrapper over lfs_dir_commit, which flushes and syncs the new metadata to disk.