Skip to contentSkip to conversation

allow rename to "--bind"-mounted filesystem

PATCH New Eric Lammerts 1 participant 1 message Jan 18, 2003 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 allow rename to "--bind"-mounted filesystem

Hi,
I just discovered that rename(2) does not allow you to rename a file within the same filesystem if there is a "--bind" in the way. For example:

# mkdir mydir
# mount --bind . mydir
# touch myfile
# strace -erename perl -e 'rename "myfile", "mydir/myfile2"'
rename("myfile", "mydir/myfile2") = -1 EXDEV (Invalid cross-device link)

IMHO it should be possible to do a rename in this situation.

I propose to remove the check in do_rename() altogether. It shouldn't be necessary, since there's also a check for a cross-device rename in vfs_rename_dir() and vfs_rename_other().

Patch below has been tested.

Eric

fs/namei.c renamed from fs/namei.c.orig +0 -4
@@ -1860,10 +1860,6 @@
 	if (error)
 		goto exit1;
 
-	error = -EXDEV;
-	if (oldnd.mnt != newnd.mnt)
-		goto exit2;
-
 	old_dir = oldnd.dentry;
 	error = -EBUSY;
 	if (oldnd.last_type != LAST_NORM)