[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Windows XP "Access denied" svn_io_rename

From: Branko Čibej <brane_at_xbc.nu>
Date: 2003-10-27 18:42:34 CET

Luke Blanshard wrote:

> Branko Čibej wrote:
>
>> Luke Blanshard wrote:
>>
>>
>>> It is of course a pity that Windows doesn't share Unix's approach to
>>> atomicity in the filesystem.
>>>
>>
>> The operation that's failing isn't atomic on Unix, either...
>>
> Really? The operation that's failing is a rename -- isn't it? That's
> (at least usually) atomic on Unix -- right?

No, the operation that's failing is "write temp+delete orig+rename temp
to orig", which is not atomic on any system I know of. Rename itself is
atomic on Windows, but it fails because another proces opens (and
implicitly locks) the file between the close after the write and the rename.

Which suggests a simple solution, using the following (Windows-specific)
algorithm:

   1. open temp (no sharing)
   2. write contents to temp
   3. delete orig
   4. rename temp to orig
   5. close temp

This would prevent virus scanners etc. from grabbing our file between
the close and the rename. Unfortunately we can't do that with the
functionality offered by APR. We'd have to introduce a new function with
a Win32-specific implementation, yuck.

-- 
Brane Čibej   <brane_at_xbc.nu>   http://www.xbc.nu/brane/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Oct 27 18:45:50 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.