This is the mail archive of the
mailing list for the Cygwin project.
Re: New rename(2) function
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
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
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.
--- origsrc/coreutils-6.9/lib/same.c 2006-09-14 00:38:14.000000000 +0200
+++ src/coreutils-6.9/lib/same.c 2007-08-10 23:18:46.265625000 +0200
@@ -37,6 +37,10 @@
# define _POSIX_NAME_MAX 14
@@ -53,6 +57,7 @@
same_name (const char *source, const char *dest)
/* Compare the basenames. */
char const *source_basename = last_component (source);
char const *dest_basename = last_component (dest);
@@ -123,4 +128,12 @@
+#else /* __CYGWIN__ */
+ char wsource[PATH_MAX], wdest[PATH_MAX];
+ cygwin_conv_to_full_win32_path (source, wsource);
+ cygwin_conv_to_full_win32_path (dest, wdest);
+ return !strcmpi (wsource, wdest);
+#endif /* __CYGWIN__ */