Re: File locking in Linux?

Steven N. Hirsch (shirsch@adelphia.net)
Tue, 20 Oct 1998 18:07:00 -0400 (EDT)


On Tue, 20 Oct 1998, David Bristow wrote:

> What is dot locking?

It's an old method of cooperative locking. In short, the first process
which desires a resource "foo" checks for a file called ".foo_lock" in a
well-known location. If it finds the file, then the file contains the pid
of the process which currently owns foo. If the file isn't found, the
first process creates the file and places its own pid in it, trusting this
keep others at bay.

Enumerating the varied race hazards is left as an exercise for the student
<g>.

Steve

> >Linux supports all three kinds of file locking I'm aware of, and has for
> >too many years to remember.
> >
> >Check the man pages for flock and fcntl.
> >
> >(dot-locking of course doesn't have a man page ;)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/