Unix VM file locking?

Miron Brezuleanu mbrezu at gmail.com
Sat Jan 26 12:54:27 UTC 2008


Hmmm, not sure if that works. flock is process based, and the process
is the VM here -- so I'm guessing that the snippet in the first email
in this thread will still have the broken behavior.

On Jan 26, 2008 2:28 PM, Igor Stasenko <siguctua at gmail.com> wrote:
> 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.
>
>



-- 
Miron Brezuleanu



More information about the Squeak-dev mailing list