3 ms·
The Maildir format, however, barely uses any tricky filesystem features. In order, all the semantics you need to support are: - atomic file create with content
by q3k 7y ago
The Maildir format, however, barely uses any tricky filesystem features. In order, all the semantics you need to support are:
- atomic file create with content
- atomic directory create
- atomic file move
- atomic file delete
- single-level file enumeration
No file modification in place which is the actual hard path. Not even appending to existing files.
Incidentally, reliable databases tend to also not rely on file modification, opting for a log-and-compact strategy instead.
It's when you start modifying existing data that 'just use a filesystem' becomes unviable.
- blattimwind 7y ago> - atomic file create with content No FS guarantees this. You can emulate this by writing to a tmp location, syncing and performing a move.
- gizmo686 7y agoWhen you use rename to overwrite a file, it guarentees that at any point in time, newpath will refer to either the original file, or the new file. This is atomic enough to give you effectivly atomic file creation with contents. It is not technically atomic, because there is a period where oldpath and newpath both refer to the same file, but I don't think that is an issue for this usecase.
- manwe150 7y agoLinux has the O_TMPFILE flag to open, for which this is one of the use cases described in the man page. I can’t say about “guaranteed” though. I assume Microsoft Transactional NTFS (TxF) also had (or has) this capability—but deprecated.
- blattimwind 7y agoTxF is a corner stone of Windows Update, I can't really imagine them removing it. I always assumed they marked it deprecated to avoid supporting it towards customers.