File locking ... need info

Bill Medland billmedland at mercuryspeed.com
Mon Dec 30 12:18:20 CST 2002


On December 28, 2002 05:08 pm, Mike Robinson wrote:
> [Please reply e-mail; I don't yet subscribe.]
>
> I am interested in support for file-locking and locking of specified
> regions of a file, in order to support databases such as MS-Access and
> Paradox.
>

I expect Alexandre will get back to you on this.  Anyway here's my input.

> But as I ponder the various likely-looking segments of the source-code, I
> really do not know where to begin ... nor what has been done in this area
> before.

Basically much of it has been done before but hasn't made it to the CVS.
Way back, Alexandre Julliard implemented it in the Corel source tree.
Back in November 2001 I tried reworking the code to fit into the current tree 
and submitted it (with a few bugs I am sure) but it was not accepted.  
Alexandre had it on his list of things to do but I don't know where it stands 
currently.

>
> It is clear that an implementation of locking must work on SMB-shares and
> that it should "actually lock things" in that other Windows users should
> see the locks as they are placed and removed.  It's also clear that
> implementing timeouts on these locks could be "problematic," since the Unix
> impl. of file locking is not quite the same as Windows expects.
>
> Pointers?  Comments?  War-stories?  Advice?  "Someone already did that"s?

If you do intend working on it then you are going to have to address some of 
the following issues:
1. Windows region locking has different behaviour with regard to merging 
regions etc. than Unix.
2. Remember that fcntl locks are on the actual file, not on the handle; and 
closing one handle drops all the locks on all other handles to the same file.  
(I am being almost criminally lax with my wording here but it will do for 
now).
3. The timeouts are going to be an interesting task.  However the structure of 
the wine server should help immensely
4. To the best of my knowledge SMB file systems don't handle it.  No one has 
yet told me differenly on the several occasions I have tried to ask.  (I know 
that Samba serves out locks to Windows machines successfully but if you put 
an fcntl lock on a file on a SMB share to the best of my knowledge it doesn't 
translate to an SMB lock request).
5. The whole issue of advisory and mandatory locking.

Our software depends quite significantly on region locking but we don't need 
the full semantics and we can make guarantees such as only one handle open on 
a file by a process so what we have done is to use winelib and create builtin 
dlls for our own ones but that use the native fcntl locking.

Get back to me if you want further details.

-- 
Bill Medland
ACCPAC International, Inc.
medbi01 at accpac.com
Corporate: www.accpac.com
Hosted Services: www.accpaconline.com



More information about the wine-devel mailing list