X-Spam-Check-By: sourceware.org Message-ID: <440F5C73.7050300@ukf.net> Date: Wed, 08 Mar 2006 22:36:35 +0000 From: Max Bowsher Reply-To: cygwin AT cygwin DOT com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050923 Thunderbird/1.0.7 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: [BUG] rename("symlink", "regular_file") has weird results OpenPGP: id=C0F2C580 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Suppose "foo.tmp" is a symlink, and "foo" is a regular file. Calling rename("foo.tmp", "foo") results in the very bizarre situation where, as far as Cygwin is concerned, there are TWO files called "foo" within the same directory. Below is a small C program to reproduce this state of affairs. Max. ===================================================================== #include #include #include #include #include #include #include #include #define M1BAD(x) if ((x) == -1) { handle_error(#x); } #define ZOK(x) if ((x) != 0) { handle_error(#x); } static void handle_error(char *op) { fprintf(stderr, "E: %s: %s\n", op, strerror(errno)); exit(1); } int main(void) { int fd; M1BAD(fd = open("foo", O_CREAT, 0644)); ZOK(close(fd)); ZOK(symlink("nonexistent", "foo.tmp")); ZOK(rename("foo.tmp", "foo")); return 0; } -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Cygwin) iD8DBQFED1xzfFNSmcDyxYARAt9aAKCYNk2A4N0PNNv/Xi42WEE0h5ZJGgCfYfa/ F/Rm9fGDC1vQJKooGL/cYcs= =+BiT -----END PGP SIGNATURE----- -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/