linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <matthew@wil.cx>
To: John Muir <muirj@nortel.com>
Cc: linux-fsdevel@vger.kernel.org
Subject: Re: Rename file over another with the same inode number fails silently.
Date: Thu, 8 Feb 2007 10:14:50 -0700	[thread overview]
Message-ID: <20070208171450.GK13101@parisc-linux.org> (raw)
In-Reply-To: <45CB5450.6050604@nortel.com>

On Thu, Feb 08, 2007 at 11:48:16AM -0500, John Muir wrote:
> The attached test program creates a file, and then some hard links to
> that file (file0 - fileN).
> The test program then attempts to rename(fileN, file) for every hard
> link created.
> 
> My expectation is that the hard links file0 - fileN would simply
> disappear, or that rename would respond with an error result and an
> appropriate errno value indicating the problem.
> 
> My observation is that the hard links file0 to fileN do not in fact
> disappear and rename returns 0.
> 
> Do I have the wrong expectations? If so, why should I have to stat the
> files to determine if they are the same inode before I rename?

This is a POSIX requirement.  See

http://www.opengroup.org/onlinepubs/009695399/functions/rename.html

where it says,

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

There's not really much point in discussing whether your expectations
are wrong or whether the extra work you have to do is silly ... POSIX
says so, so we have to behave this way.

Personally, I think this is an unexpected oversight on POSIX's part.
The rationale refers to 'rename("x", "x");', and doesn't discuss hard
links.  Possibly something to raise with the POSIX ctte, but I doubt
they'd be interested in changing this now ... perhaps if you can find
some other unices which behave differently, you might have a shot.

      reply	other threads:[~2007-02-08 17:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-08 16:48 Rename file over another with the same inode number fails silently John Muir
2007-02-08 17:14 ` Matthew Wilcox [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070208171450.GK13101@parisc-linux.org \
    --to=matthew@wil.cx \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=muirj@nortel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).