Unix’s file durability problem
I&#x27;ve suggested an approach to this before.  There should be several types of files.<p>- &quot;Unit&quot; files commit when closed properly (this does not include a program exit without close), and then replace the old version of the file.  The file system should guarantee that, after a crash, you have either the old version or the new complete version. This should be the default when a file is opened via &quot;creat()&quot;<p>- &quot;Temp&quot; files always go away completely after a crash.  This should be the default for designated temp directories.<p>- &quot;Log&quot; files can only be appended. Writers cannot seek. The file system guarantees that after a crash, the end of the file is at the end of some write; the file may not tail off into junk.  This should be the default for files opened for append.<p>- &quot;Managed&quot; files are for structured databases.  They have an additional API. &quot;writemanaged()&quot; has a callback parameter.  It returns when the data has been queued, but in addition, the writer gets a callback when the write has committed to disk. The file system must guarantee that a write for which the callback has been made will survive a crash.  This provides fine-grained information of when data has been committed to disk, which is what a database needs.  It improves performance by not blocking waiting for disk commit to take place.  The database can have several I&#x2F;O operations going at once in different parts of the file without blocking.