rename()

Nick Burrett nick at sqrt.co.uk
Fri Aug 13 02:07:10 PDT 2004


Stefan Bellon wrote:
> Nick Burrett wrote:
> 
>>Stefan Bellon said:
> 
> 
>>>On RISC OS, rename(a, b) fails if b already exists. On GNU/Linux,
>>>rename(a, b) just overwrites b if it already exists.
>>>
>>>Is there any way to make rename() on RISC OS behave the same. And
>>>moreover, is it possible to make it an atomar operation, i.e. not
>>>just doing unlink(b); rename(a, b)?
>>>
>>>It's all about race conditions of concurrent processes.
> 
> 
>>Both of these are possible.  I would be interested to know how the
>>SCL's rename function performs here.  Does it fail or does it
>>overwrite 'b' ?

> I'd be interested in how you think you can make rename() behave like
> e.g. the Single Unix Specification says. How can this be done in an
> atomar operation on RISC OS?

Within the environmet of pthreads, this could be done.  But I've just 
realised you said concurrent processes, not threads.  I don't suppose 
there is any function to lock a file system.  Mind you if there was, 
then the way applications are written, they'd fail and probably terminate.

I'm not sure.

Nick.



More information about the gcc mailing list