From owner-freebsd-questions Mon Nov 13 23:49:57 1995 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id XAA06465 for questions-outgoing; Mon, 13 Nov 1995 23:49:57 -0800 Received: from irz301.inf.tu-dresden.de (irz301.inf.tu-dresden.de [141.76.1.11]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id XAA06401 ; Mon, 13 Nov 1995 23:49:10 -0800 Received: from sax.sax.de by irz301.inf.tu-dresden.de (8.6.12/8.6.12-s1) with ESMTP id IAA29034; Tue, 14 Nov 1995 08:48:24 +0100 Received: by sax.sax.de (8.6.11/8.6.12-s1) with UUCP id IAA25537; Tue, 14 Nov 1995 08:48:05 +0100 Received: (from j@localhost) by uriah.heep.sax.de (8.6.12/8.6.9) id IAA00168; Tue, 14 Nov 1995 08:27:35 +0100 From: J Wunsch Message-Id: <199511140727.IAA00168@uriah.heep.sax.de> Subject: Re: elm problem :) To: bmk@dtr.com Date: Tue, 14 Nov 1995 08:27:34 +0100 (MET) Cc: roberto@keltia.freenix.fr, geoff@ginsu.com, bsd@ee.petra.ac.id, questions@freebsd.org, freebsd-hackers@freebsd.org Reply-To: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch) In-Reply-To: <199511132326.PAA07428@dtr.com> from "bmk@dtr.com" at Nov 13, 95 03:26:12 pm X-Phone: +49-351-2012 669 X-Mailer: ELM [version 2.4 PL23] MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Content-Length: 1541 Sender: owner-questions@freebsd.org Precedence: bulk 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. ;-)