Date: Fri, 31 Jul 1998 17:34:24 -0700 (PDT) From: Tom <tom@uniserve.com> To: Brian Feldman <green@zone.baldcom.net> Cc: freebsd-current@FreeBSD.ORG Subject: Re: flock(2) problem & fix Message-ID: <Pine.BSF.3.96.980731173220.29794C-200000@shell.uniserve.ca> In-Reply-To: <Pine.BSF.4.02.9807311954190.25645-200000@zone.baldcom.net>
next in thread | previous in thread | raw e-mail | index | archive | help
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: <Pine.BSF.3.96.980731173220.29794E@shell.uniserve.ca> 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: <Pine.BSF.4.02.9807312005191.25645@zone.baldcom.net> Content-Description: LS0tIGtlcm5fZGVzY3JpcC5jLm9sZAlGcmkgSnVsIDMxIDE4OjI4OjMwIDE5 OTgNCisrKyBrZXJuX2Rlc2NyaXAuYwlGcmkgSnVsIDMxIDE5OjMxOjI2IDE5 OTgNCkBAIC05ODYsNiArOTg2LDkgQEANCiAJcmVnaXN0ZXIgc3RydWN0IGZp bGUgKmZwOw0KIAlzdHJ1Y3Qgdm5vZGUgKnZwOw0KIAlzdHJ1Y3QgZmxvY2sg bGY7DQorCXN0cnVjdCBzdGF0IGZzdDsNCisJc2hvcnQgZ3I7DQorCWJvb2xl YW5fdCBvayA9IDA7DQogDQogCWlmICgod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MSywgJmxmLCBGX0ZMT0NLfEZfV0FJVCkp Ow0KKwl9IGVsc2UNCisJCXJldHVybiAoRVBFUk0pOw0KIH0NCiANCiAvKg0K --0-247509216-901931664=:29794-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.96.980731173220.29794C-200000>