System V file/record locking?
R.HUTCHISON
hutch at lzaz.ATT.COM
Wed Feb 8 23:36:55 AEST 1989
>From article <477 at maxim.ERBE.SE>, by prc at 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 at ERBE.SE uucp: uunet!erbe.se!rclaeson
} Fax: +46 758-197 20 Internet: rclaeson at ERBE.SE BITNET: rclaeson at ERBE.SE
I'm surprised that there weren't any questions on mandatory locking.
Bob Hutchison
att!lzaz!hutch
More information about the Comp.unix.questions
mailing list