SafeFile: use atomic rename-with-overwrite, rather than non-atomic delete-then-rename #9296
+2
−10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Debugging the same "loses
long_name,short_name" bug as #9248 led me to find thatSafeFilewas breaking atomic guarantees inLittleFS, creating a window of opportunity where there is no/prefs/device.protoeven though it was opened withfullAtomic == true.LittleFS promises:
Previously:
Remove-then-rename means that any reboot that takes place after the
removefinishes and before therenamefinishes will cause a missing/prefs/device.proto.With this PR:
A reboot at any time will result in either the old or the new version of
/prefs/device.protoexisting. That's atomic.(Note that
ARCH_NRF52bypasses this.)Testers wanted
Especially on non-ESP32 devices!
🤝 Attestations