Re: Rename file over another with the same inode number fails silently.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux