Unix VM file locking?

Andreas Raab andreas.raab at gmx.de
Sat Jan 26 01:12:39 UTC 2008


Colin Putney wrote:
> 
> On 25-Jan-08, at 10:38 AM, Andreas Raab wrote:
> 
>> etc. Is there an easy way to patch the Unix file code to avoid this, 
>> e.g., behave like Windows in such that it would disallow opening the 
>> same file for multiple writes?
> 
> I've been bitten by this as well, but in reverse. Code that works great 
> on Unix is totally broken on Windows because you can't open the same 
> file for writing twice.

Easy to change. In sqWin32FilePrims.c function sqFileOpen() modify:

   h = CreateFileW(win32Path,
         writeFlag ? (GENERIC_READ | GENERIC_WRITE) : GENERIC_READ,
         writeFlag ? FILE_SHARE_READ : (FILE_SHARE_READ | FILE_SHARE_WRITE),
       "... etc ..."

to read:

   h = CreateFileW(win32Path,
         writeFlag ? (GENERIC_READ | GENERIC_WRITE) : GENERIC_READ,
         FILE_SHARE_READ | FILE_SHARE_WRITE,
       "... etc ..."

So what's the equivalent change for Unix?

Cheers,
   - Andreas



More information about the Squeak-dev mailing list