Borg: Why did you choose mkdir for locking and not touch?

Created on 22 Jul 2017  路  3Comments  路  Source: borgbackup/borg

Just a curious question: Why did you chose mkdir for locking and not touch, i.e. why do you lock with a directory and not an empty file? Is there any reason behind it or was it just by chance?

question

All 3 comments

open(2) with O_CREAT|O_EXCL and mkdir(2) are very similar for this purpose. open(2) without O_EXCL does of course not work.

I believe mkdir became the preferred way due to some bugs in networked FSs (directories and files are handled very differently due to different caching strategies, I think apart from that Linux had some bugs as well).

Note: there is a mailing list as well.

attic had posix locking, but that is problematic even on UNIX platforms (and does not exist on windows filesystems). there were numerous issues on the attic issue tracker due to it. and "issue" basically meant "game over".

I looked around for locking libraries and checked how they do it.
I found a handful, but nothing looked like we could just use it.

So, reinvented the wheel again (rounder version) and just took the mkdir locking as seen in some others for its cross-platform compatibility and simplicity.

Thanks for you reply. I don't like mailing lists, but GitHub issues tagged with "question" are also okay, IMHO.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

phdoerfler picture phdoerfler  路  6Comments

tconstans picture tconstans  路  5Comments

anarcat picture anarcat  路  4Comments

rugk picture rugk  路  4Comments

pierreozoux picture pierreozoux  路  4Comments