[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.
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.
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?
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 wrote:
If you do intend working on it then you are going to have to address some of the following issues:
- 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.
Ah, yes, file locking. I was one of the folks who advised Sun as they were bringing file locking to Java (in "JSR-51"), and we had some fun discussions about how to define file locking in Java so it would map properly onto either Windows or Unix.
One thing I recall is that W. Richard Stevens has a nice discussion of Unix locking in chapter 12 of "Advanced Programming in the Unix environment", published 1993. It aged fairly well, I think, and provides a bit of insight into how locking evolved -- and some problems with mandatory locking (e.g. mandatory locking didn't prevent ed from editing a file!) Note that mandatory locking is not part of Posix (http://www.opengroup.org/onlinepubs/007904975/toc.htm).
JSR-51 decided to map Java file locks to mandatory locks on Windows, and advisory locks on Unix. I'm afraid that's about the only real option.
- Dan
It sounds to me like the file-locking code I am looking for has "already been done" and/or "was rejected" at some time in the past.
I'm probably not the best qualified to do this if it has already been done.
But in order to run databases on Wine, I need it.
Please advise.
[personal reply because I don't subscribe yet.]