From owner-freebsd-current Fri Jul 31 17:34:35 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id RAA01867 for freebsd-current-outgoing; Fri, 31 Jul 1998 17:34:35 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from pop.uniserve.com (pop.uniserve.com [204.244.156.3]) by hub.freebsd.org (8.8.8/8.8.8) with SMTP id RAA01862 for ; Fri, 31 Jul 1998 17:34:34 -0700 (PDT) (envelope-from tom@uniserve.com) Received: from shell.uniserve.ca [204.244.186.218] by pop.uniserve.com with smtp (Exim 1.82 #4) id 0z2Pcw-00036s-00; Fri, 31 Jul 1998 17:34:26 -0700 Date: Fri, 31 Jul 1998 17:34:24 -0700 (PDT) From: Tom X-Sender: tom@shell.uniserve.ca To: Brian Feldman cc: freebsd-current@FreeBSD.ORG Subject: Re: flock(2) problem & fix In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="0-247509216-901931664=:29794" Content-ID: Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. --0-247509216-901931664=:29794 Content-Type: TEXT/PLAIN; CHARSET=US-ASCII Content-ID: On Fri, 31 Jul 1998, Brian Feldman wrote: > Our flock(2) doesn't seem to do the right thing all the time. It seems > that any user with read access to a file is allowed exclusive locking of > it, which I think is wrong (does everyone agree?), and that a shared lock I disagree. The flock() method is advisory anyway. In fact, the file may exist for the sole purpose of flock'ing it. I know several programs that use lock files (which are always zero length) for locking purposes. Also, silently converting a exclusive lock request to a non-exclusive lock is VERY bad. Many programs will break. Tom --0-247509216-901931664=:29794 Content-Type: TEXT/PLAIN; CHARSET=US-ASCII; NAME="flock.diff" Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: LS0tIGtlcm5fZGVzY3JpcC5jLm9sZAlGcmkgSnVsI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dC5zdF9naWQpIHsNCisJCQlvayA9IDE7DQor CQkJYnJlYWs7DQorCQl9CQ0KKwl9DQorCWlmIChvaykgew0KIAlmcC0+Zl9m bGFnIHw9IEZIQVNMT0NLOw0KIAlpZiAodWFwLT5ob3cgJiBMT0NLX05CKQ0K IAkJcmV0dXJuIChWT1BfQURWTE9DSyh2cCwgKGNhZGRyX3QpZnAsIEZfU0VU TEssICZsZiwgRl9GTE9DSykpOw0KIAlyZXR1cm4gKFZPUF9BRFZMT0NLKHZw LCAoY2FkZHJfdClmcCwgRl9TRVRMSywgJmxmLCBGX0ZMT0NLfEZfV0FJVCkp Ow0KKwl9IGVsc2UNCisJCXJldHVybiAoRVBFUk0pOw0KIH0NCiANCiAvKg0K --0-247509216-901931664=:29794-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message