System V file/record locking?

was-John McMillan jcm at mtunb.ATT.COM
Sat Feb 4 01:09:16 AEST 1989


In article <477 at maxim.ERBE.SE> prc at maxim.ERBE.SE (Robert Claeson) writes:
...
>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.

	LOCKF, indeed, uses FCNTL.  It just saves your management
	of the 'flock' struct, and generalizes the error returns
	(into EDEADLK).

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

>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.

>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?

	(^; NOMEX ON ;^)  I believe it's an abstraction of
	FSS which is un-utilized in fs/s5.  Ie., it's a hook for
	FUTURE features, future types of alien-file-system <-> UNIX
	manglings.  ...But then, even I don't trust MY beliefs....
	
jc mcmillan	-- att!mtunb!jcm	-- Speaking for 'self, not THEM.



More information about the Comp.unix.questions mailing list