Re: flock
Ingo Weinhold <bonefish-CFLBMwTPW48UNGrzBIF7/[email protected]>
| Newsgroups | gmane.os.openbeos.kernel.devel |
|---|---|
| Message-ID | <[email protected]> |
On 2006-11-21 at 00:56:31 [+0100], Axel Dörfler <[email protected]> wrote: I had a bit of trouble with receiving mail recently, so the reply's a bit late. But I had worse ones... ;-) > "François Revol" <[email protected]> wrote: > > > a while ago, I implemented advisory locking support to the VFS. > > > However, I didn't add the non-POSIX flock() function; this locking > > > functionality is only available using the POSIX defined fcntl(..., > > > F_SETLK, ...) method. > > > Should we add flock() as well even though it's not part of POSIX? > > Beware, though fcntl(F_SETLK) uses a struct flock, this one has > > nothing > > to do and is not compatible with it, and has a different semantic > > (for > > ex one removes the lock on exec or a close, the other doesn't). I > > scratched my head several days on them. > > This one is a BSDism, but I think several apps wants it (samba ?). > > We should collect the differences and implement flock() and F_SETLK > correctly, then. It's actually as simple as this: flock() locks are bound to file descriptors numbers, fcntl(F_SETLK) locks to file descriptors. Meaning, if you acquire a lock on FD number 4 via flock(), dup2() 4 to 8, you can't unlock 8. And after fork() the child process won't have a lock on FD 4 either. fcntl(F_SETLK) has the expected semantics with respect to dup()/fork(). > If possible, I would prefer to have flock() done via F_SETLK, and if > it's only the COE behaviour, I'm sure we can fix that :) I suppose it should be possible, I only wonder, if it's worth the trouble. At least the automake/autoconf infected packages using file locking I've seen so far usually support both methods, fcntl(F_SETLK) being the preferred one. CU, Ingo ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV