System V file/record locking?

Robert Claeson prc at maxim.ERBE.SE
Thu Feb 2 04:23:00 AEST 1989


I was reading through the UNIX System V Programmer's Reference the other
night (excellent reading if you can't sleep -- it never fails :-). While
reading about file and record locking, the following questions appeared,
and I couldn't find any good answers for them in my manuals. If there's
someone who knows, please e-mail me.

1. What's the difference between the lockf(3) function and the locking
   calls to the fcntl(2) system call? Since lockf is a function in the
   standard library, one would expect it to be implemented using fcntl.
   If this is not so, does the NFS locking protocol work on fcntl-style
   locks as well (it works on lockf locks)?

2. lockf always uses "exclusive" locks. Does this mean that it sets
   a write lock on the file segment?

3. What is the "l_whence" field used for in the flock struct (used as
   argument to the locking functions of fcntl)? The same thing as in
   the lseek system call?

4. The documentation mentions a "F_CHKFL" function of fcntl in the man
   page for fcntl(5). What does this function do and how do I use it?
-- 
Robert Claeson, ERBE DATA AB, P.O. Box 77, S-175 22 Jarfalla, Sweden
"No problems." -- Alf
Tel: +46 758-202 50  EUnet:    rclaeson at ERBE.SE  uucp:   uunet!erbe.se!rclaeson
Fax: +46 758-197 20  Internet: rclaeson at ERBE.SE  BITNET: rclaeson at ERBE.SE



More information about the Comp.unix.questions mailing list