New rename(2) function

Christian Franke Christian.Franke@t-online.de
Fri Aug 10 21:34:00 GMT 2007


Eric Blake wrote:
> [adding coreutils, since this may be an upstream problem; this stems from
> an attempt to make cygwin's rename(2) more POSIX-compliant]
>
> According to Christian Franke on 8/10/2007 2:37 PM:
>   
> ...
>>
>> But be aware: If there are hard links, things get really worse:
>>
>> $ touch Foo
>>
>> $ ln Foo Fool
>>
>> $ mv -v Foo foo
>> removed `Foo'
>>     
>
> Ouch.  Coreutils decided that since Foo and foo represent the same file
> (and on a case-insensitive system, they do), and since Foo has more than
> one link, that it was safe to unlink Foo because the data would be left in
> foo.  But how is coreutils supposed to know when a file system is
> case-insensitive, such that unlinking Foo is the wrong action?  In other
> words, how do you distinguish between two spellings of the same directory
> entry, which is a different matter than two directory entries to the same
> inode?
>
>   

This is probably impossible in the general case, when only POSIX 
compliant OS functions can be used.

For Cygwin, the attached patch for same_name() fixes the above problem. 
Should also work on managed mounts.

But it may break other things, I don't know.

Christian

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: coreutils-6.9-same_name.patch.txt
URL: <http://cygwin.com/pipermail/cygwin-developers/attachments/20070810/f8b0ae2b/attachment.txt>


More information about the Cygwin-developers mailing list