From owner-freebsd-current Tue Apr 25 18:48:29 1995 Return-Path: current-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id SAA29539 for current-outgoing; Tue, 25 Apr 1995 18:48:29 -0700 Received: from cs.weber.edu (cs.weber.edu [137.190.16.16]) by freefall.cdrom.com (8.6.10/8.6.6) with SMTP id SAA29533 for ; Tue, 25 Apr 1995 18:48:16 -0700 Received: by cs.weber.edu (4.1/SMI-4.1.1) id AA03577; Tue, 25 Apr 95 19:41:42 MDT From: terry@cs.weber.edu (Terry Lambert) Message-Id: <9504260141.AA03577@cs.weber.edu> Subject: Re: fcntl F_SETLK backward compatibility hack implemented To: syssgm@devetir.qld.gov.au (Stephen McKay) Date: Tue, 25 Apr 95 19:41:42 MDT Cc: current@FreeBSD.org, syssgm@devetir.qld.gov.au In-Reply-To: <199504250815.SAA15397@pandora.devetir.qld.gov.au> from "Stephen McKay" at Apr 25, 95 06:15:37 pm X-Mailer: ELM [version 2.4dev PL52] Sender: current-owner@FreeBSD.org Precedence: bulk > Well, since nobody objected :-) I went and implemented my proposed fix to > fcntl locking. Here are patches to sys/fcntl.h and kern/kern_descrip.c > plus two test programs. The 'break' program demonstrates how the scheme > can fail, and allows you to look at the pretty console warnings. > The ftest program sets a few random locks and checks for clashes. If any > console messages turn up, it has failed. I compile it on a 1.1.5 system > and a 2.0 system then run it like: > > $ ./ftest.1.1.5 & ./ftest.2.0 ; sleep 3 > 048901919: 374: OK F_WRLCK SEEK_CUR -3722 6989 == 2201 to 9189 > 048937427: 375: NO F_WRLCK SEEK_SET 6048 3952 == 6048 to 9999 > 048940850: 375: -> F_WRLCK SEEK_SET 2201 6989 == 2201 to 9189 PID:374 > 050970752: 375: OK F_WRLCK SEEK_SET 6048 3952 == 6048 to 9999 > 051003186: 374: OK F_WRLCK SEEK_CUR 33 1554 == 4191 to 5744 > ... > > This shows a microsecond timestamp, the pid, success/failure/reason, and > the expanded flock structure. > > I think the patch works well, and since it changes the real fcntl lock code > so little, it won't make things any worse! Coolness, Parker. 8-) 8-). If you're still in the neighborhood, could you add a long of 'sysid' to the flock structure, pass 0 for the local machine, and use the number to preterb the pid hash and lookup and compare it where you compare the pid? You should force the sysid to 0 for the F_SETLK, F_SETLKW, and F_GETLK calls, and implement F_RSETLK, F_RSETLKW, and F_RGETLK, which fail for non-root users and respect the passed 'sysid' for root users? This would be a good step towards lockd support. If it's too much of a pain, forget it and I'll probably hit it at some indefinite future date myself. Regards, Terry Lambert terry@cs.weber.edu --- Any opinions in this posting are my own and not those of my present or previous employers.