News for hackers. Stuff that matters.
Re:Files Are Hard (2015) by q3k on Sunday December 01, 2019 @09:15AM (#21675562)
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.

Re:Files Are Hard (2015) by blattimwind on Sunday December 01, 2019 @10:39AM (#21675934)
> - atomic file create with content

No FS guarantees this. You can emulate this by writing to a tmp location, syncing and performing a move.

Re:Files Are Hard (2015) by gizmo686 on Sunday December 01, 2019 @10:48AM (#21675976)
When 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.

Re:Files Are Hard (2015) by manwe150 on Sunday December 01, 2019 @03:38PM (#21677656)
Linux 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.
Re:Files Are Hard (2015) by blattimwind on Tuesday December 03, 2019 @08:10AM (#21691953)
TxF 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.