Re: Bug moving file over link?

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

 



Cameron Simpson <cs@zip.com.au> wrote:
>
> | Can someone explain to me what is happening here:
> | 
> | ~ $ touch foo
> | ~ $ ln foo bar
> | ~ $ ls foo bar
> | bar  foo
> | ~ $ mv foo bar
> | ~ $ ls foo bar
> | bar  foo
> | 
> | I try to move a file over a hard linked copy of itself and the move
> | fails, but there is no error.  Is this the intended behavior?

Yes, it is.

int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
	       struct inode *new_dir, struct dentry *new_dentry)
{
	int error;
	int is_dir = S_ISDIR(old_dentry->d_inode->i_mode);

	if (old_dentry->d_inode == new_dentry->d_inode)
 		return 0;

The Open Group base specification 6 says:

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

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



_______________________________________________

Ext3-users@redhat.com
https://listman.redhat.com/mailman/listinfo/ext3-users

[Index of Archives]         [Linux RAID]     [Kernel Development]     [Red Hat Install]     [Video 4 Linux]     [Postgresql]     [Fedora]     [Gimp]     [Yosemite News]

  Powered by Linux