Email List: Xaustin-group-lX
[All Lists]

RE: rename suggestion from Andries Brouwer

To: "'Jim Meyering'" <yyy@xxxxxxxxxxxx>, yyyyyyyyyyyyyy@xxxxxxxxxxxxx
Subject: RE: rename suggestion from Andries Brouwer
From: "Seeds, Glen" <yyyyyyyyyy@xxxxxxxxxx>
Date: Wed, 2 Apr 2003 13:29:20 -0500
Cc: yyyyyyyyyyyyyyy@xxxxxx

Looks like we goofed on that one! I think it could be easily fixed, though, by using the term "existing directory entry" instead of "existing file". That's what the intent was.

 /glen

-----Original Message-----
From: Jim Meyering [mailto:jim@meyering.net]
Sent: April 2, 2003 12:33 PM
To: austin-group-l@opengroup.org
Cc: Andries.Brouwer@cwi.nl
Subject: rename suggestion from Andries Brouwer


I've just found that many rename implementations
(all I've checked except that of NetBSD 1.6)
exhibit surprising behavior, possibly as a result of
this wording from the specification for rename:

  If the old argument and the new argument
  resolve to the same existing file, rename( ) shall return successfully
  and perform no other action.

But then, in the rationale it says this:

  The specification that if old and new refer to the same file is intended
  to guarantee that: rename("x", "x"); does not remove the file.

Andries Brouwer already noticed the ambiguity and filed this, back in 1999:

  http://www.opengroup.org/austin/mailarchives/austin-review-l/msg00048.html

I did not find a follow-up to that message.  Was there one?

The ambiguity is when old and new are distinct links to the same inode.
In that case, I think it makes sense to allow rename to unlink old.
----------------
To see what I mean, try this:

  touch a; perl -e 'link "a", "b"; rename "a", "b" or die "$!"'; ls a b

On most systems, you'll see that both `a' and `b' remain.
On NetBSD, however, rename does what I'd expect and unlinks a.

Andries' proposal would allow a rename implementation to
unlink the file corresponding to the first argument e.g.,
when old and new correspond to distinct directory entries.

This message may contain privileged and/or confidential information.  If you have received this e-mail in error or are not the intended recipient, you may not use, copy, disseminate or distribute it; do not open any attachments, delete it immediately from your system and notify the sender promptly by e-mail that you have done so.  Thank you.

<Prev in Thread] Current Thread [Next in Thread>