libfilo - A library for file locking
Aboutlibfilo is a small portable library to do userspace file locking, like fcntl(), lockf() or flock(), but within threads.
If you want multiple threads to access a file simultaneously, you will probably need some kind of locking to avoid them stepping on each other and corrupting everything. Currently, there is no standard way of doing this:
- fcntl() ignores threads, and only works between processes.
- flock() is not really standard and doesn't work well over NFS.
- lockf(), while it is documented in POSIX, is often implemented using fcntl() so it's also useless.
So this library allows you to do read/write file locking with byte granularity
and fcntl-like semantics, within threads.
It's written in C, in about 600 lines of code, and has no dependencies on external libraries. It's based on the traditional POSIX API and follows the Single UNIX Specification, so it should be portable to all major UNIX variants without problems; however it's developed under Linux, so please let me know if you try it somewhere else.
It's open source, published under the Open Software License 2.1, so you can link the library with anything you want (even if it's propietary, GPLd, or whatever license you choose; pretty much like LGPL).
DocumentationYou can find an html version of the manpage.
DownloadThe current version is 0.11 (released on 2005-04-27): all released files.
git clone git://blitiri.com.ar/libfilo
Alberto Bertogli (email@example.com) - Last updated 10/Nov/2012