Can you guarantee integrity of an mmap'd file under SVR4?

kendall at saber.com kendall at saber.com
Fri Mar 22 07:31:00 AEST 1991


My application would like to mmap an NFS-mounted file read-only and be
guaranteed of the integrity of its data; that is, if someone overwrites
the file, I'd like my application to keep seeing the original data.  This
is for SunOS or SVR4.

Of course, this could be implemented by making a copy of the file, but
that is too slow and takes up too much disk or swap space.  I want mmap's
wonderful performance behavior: lazy reading, and no swap space used.

My understanding is that what I want is impossible under SVR4.  So I'm
reluctantly willing to guarantee that only other instances of my
application will be anyone trying to overwrite the file, so they can
cooperate.

This reduces the problem to advisory file locking, more or less.  SunOS
documents two kinds of file locking.  Only one (lockf(3)) is supposed to
work across a network, and when I tried reasonable things it hung my
processes for a while.  From this experience, and from talking to people,
I get the feeling that nobody uses lockf because it doesn't work very
well.  I need this locking to be a reliable service available at all
customer sites without much trouble on the customers' part.

My questions are: Has anyone made a system that guarantees this behavior?
More specifically, is there a reliable advisory file locking service
available, either a fixed lockf(3) or a 3rd party equivalent?  Any other
advice?

   Please reply by mail.

Sam Kendall			       		       kendall at Saber.COM
Saber Software, Inc.			             uunet!saber!kendall
(617) 876-7636



More information about the Comp.sys.sun mailing list