Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!ukma!tut.cis.ohio-state.edu!osu-cis!att!lzaz!hutch From: hutch@lzaz.ATT.COM (R.HUTCHISON) Newsgroups: comp.unix.questions Subject: Re: System V file/record locking? Message-ID: <408@lzaz.ATT.COM> Date: 8 Feb 89 13:36:55 GMT References: <477@maxim.ERBE.SE> Organization: AT&T ISL Lincroft NJ USA Lines: 41 From article <477@maxim.ERBE.SE>, by prc@maxim.ERBE.SE (Robert Claeson): ... } 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)? Yes, lockf() uses fcntl(). I believe it was added at the prompting of /usr/group. They wanted a standard way of locking files. } } 2. lockf always uses "exclusive" locks. Does this mean that it sets } a write lock on the file segment? Yes. It's a shame that it doesn't let you place read (non-exclusive) locks. } } 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? Yes. Same rules apply as for lseek(). } } 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? It doesn't do anything although the header file hints that it might. Perhaps in file systems other than system V it might be used. } -- } Robert Claeson, ERBE DATA AB, P.O. Box 77, S-175 22 Jarfalla, Sweden } "No problems." -- Alf } Tel: +46 758-202 50 EUnet: rclaeson@ERBE.SE uucp: uunet!erbe.se!rclaeson } Fax: +46 758-197 20 Internet: rclaeson@ERBE.SE BITNET: rclaeson@ERBE.SE I'm surprised that there weren't any questions on mandatory locking. Bob Hutchison att!lzaz!hutch