Skip to content

[QUESTION] What is the file state upon power down? #1164

@amgross

Description

@amgross

Hi,
I understand that power down in middle of file write not corrupts the file system, and that every file that syncd/closed will be exist after the power down.

From my experience, if I open file which creates it and write to it and then power down happens - the file will be exist but without any data.
Is this really the case and always? (full revert of any writes done without explicit call to sync, but created files exist although wasn't synced/closed. not matter how much was written and if inline etc.).

If indeed, it is surprising because it mean the file metadata is written twice - upon creation and upon close. And also it is very not convenient as if I see file after power down I need to check if it has content (can't assume that if it exist then its data written already).

The only documentation I found is:

littlefs/README.md

Lines 14 to 16 in adad0fb

**Power-loss resilience** - littlefs is designed to handle random power
failures. All file operations have strong copy-on-write guarantees and if
power is lost the filesystem will fall back to the last known good state.

The term 'last known good state' is not clear enough to me

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions