Unix VM file locking?

Igor Stasenko siguctua at gmail.com
Sat Jan 26 12:28:11 UTC 2008


You can use flock/fcntl for placing an exclusive lock on file descriptor.

http://linux.die.net/man/2/flock

On 26/01/2008, Andreas Raab <andreas.raab at gmx.de> wrote:
> 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
>
>


-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list