Date: Tue, 14 Nov 1995 08:27:34 +0100 (MET) From: J Wunsch <j@uriah.heep.sax.de> To: bmk@dtr.com Cc: roberto@keltia.freenix.fr, geoff@ginsu.com, bsd@ee.petra.ac.id, questions@freebsd.org, freebsd-hackers@freebsd.org Subject: Re: elm problem :) Message-ID: <199511140727.IAA00168@uriah.heep.sax.de> In-Reply-To: <199511132326.PAA07428@dtr.com> from "bmk@dtr.com" at Nov 13, 95 03:26:12 pm
next in thread | previous in thread | raw e-mail | index | archive | help
As bmk@dtr.com wrote:
>
> I've always had to use flock style locking
> - fcntl always seemed to cause the symptoms the original complaint
> described.
That's quite surprising since both functions share a rather large part
of their implementation inside the kernel. flock() is basically an
fcntl-style lock spanning the entire file:
/* ARGSUSED */
int
flock(p, uap, retval)
struct proc *p;
register struct flock_args *uap;
int *retval;
{
...
lf.l_whence = SEEK_SET;
lf.l_start = 0;
lf.l_len = 0;
if (uap->how & LOCK_UN) {
...
return (VOP_ADVLOCK(vp, (caddr_t)fp, F_UNLCK, &lf, F_FLOCK));
}
...
return (VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, F_FLOCK|F_WAIT));
}
and:
/* ARGSUSED */
int
fcntl(p, uap, retval)
struct proc *p;
register struct fcntl_args *uap;
int *retval;
{
...
switch (uap->cmd) {
...
case F_SETLK:
...
if (fl.l_whence == SEEK_CUR)
fl.l_start += fp->f_offset;
switch (fl.l_type) {
case F_RDLCK:
if ((fp->f_flag & FREAD) == 0)
return (EBADF);
p->p_flag |= P_ADVLOCK;
return (VOP_ADVLOCK(vp, (caddr_t)p, F_SETLK, &fl, flg));
...
...
}
--
cheers, J"org
joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199511140727.IAA00168>
