Unix’s file durability problem
A good solution is to use SQLite.  It addresses the issues (pretty much by doing all the fsync etc mentioned including on directories) and has a very comprehensive test suite.  It is also used very widely on desktops, mobile devices, applications etc.  <a href="https://www.sqlite.org/whentouse.html" rel="nofollow">https://www.sqlite.org/whentouse.html</a><p>A notable quote: SQLite does not compete with client/server databases. SQLite competes with fopen().