#1207·littlefs

Custom attribute changes won't trigger metadata commit unless file data is written

Author: i-g-g-yCreated May 14, 2026Updated May 18, 2026

Hello.

I noticed that littleFS will not commit an attribute change to filesystem disk unless the file data is dirty.

Is this by design?

The user attributes are used to store file crc and another 8-bit attribute for various flags (say a file dirty flag, which is supposed to get cleared when the file is closed or a flag to signal to system to track file statistics).

I like this design, as it requires a minimal intervention by littleFS, for instance, metadata is often written when appending data to file, so this principle simply adds this attribute data with no additonal penalty. But the "file dirty flag", which resided in my second attribute, does not necessarily follow this as an attribute can get changed withouth any data written to a file, and also a file can be closed after sync with the attribute being updated but no data being written in between the two.

Is there anything I could do to trigger the metadata update some other way to avoid additional potential flash operations?

Source: littlefs-project/littlefs