delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/08/03/10:25:20

X-Spam-Check-By: sourceware.org
To: cygwin AT cygwin DOT com
From: Eric Blake <ebb9 AT byu DOT net>
Subject: Re: New rename(2) function
Date: Fri, 3 Aug 2007 14:24:35 +0000 (UTC)
Lines: 42
Message-ID: <loom.20070803T160617-952@post.gmane.org>
References: <loom DOT 20070801T164915-207 AT post DOT gmane DOT org>
Mime-Version: 1.0
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: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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 <ebb9 <at> 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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019