X-Spam-Check-By: sourceware.org To: cygwin AT cygwin DOT com From: Eric Blake Subject: Re: New rename(2) function Date: Fri, 3 Aug 2007 14:24:35 +0000 (UTC) Lines: 42 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit User-Agent: Loom/3.14 (http://gmane.org/) X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: 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 Eric Blake byu.net> writes: > > "If the old argument and the new argument resolve to the same existing file, > rename() shall return successfully and perform no other action." Looks like this part works in the latest snapshot. Thanks for the implementation. However, there is still a bug: $ mkdir d1 d2 $ touch d1/f $ mv -T d1 d2 # forces the call of rename("d1", "d2"), in coreutils 6.0+ mv: cannot move `d1' to `d2': Permission denied $ oops - on Linux, this correctly removes the empty directory d2, then renames d1 to d2, so that you now have d2/f. (Here's an example of a similar sequence that triggers the rename of a non- empty directory to overwrite an existing empty directory; this sequence is tested on Solaris, so it doesn't rely on non-POSIX -T, nor does it trip the mv - T bug present in coreutils prior to 6.0: # mkdir -p a b/a # touch a/f # /bin/mv a b # ls b/a/f b/a/f ) Also, the SUSv3 check could use one more slight optimization - the check for whether the old file has more than one hardlink is more likely to trigger for directories than files (hard links aren't that common for files, but all directories have multiple links); but since Windows (and thus cygwin) does not allow directories to be hardlinked, you might as well skip querying the file id if the old path was a directory. -- Eric Blake -- 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/