linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [QUESTION] question about the errno of rename the parent dir to a subdir of a specified directory
@ 2019-12-25 13:16 zhangyi (F)
  2019-12-25 16:27 ` Al Viro
  0 siblings, 1 reply; 3+ messages in thread
From: zhangyi (F) @ 2019-12-25 13:16 UTC (permalink / raw)
  To: viro, linux-fsdevel; +Cc: linux-kernel, miaoxie, zhangtianci1

Hi,

If we rename the parent-dir to a sub-dir of a specified directory, the
rename() syscall return -EINVAL because lock_rename() in lock_rename()
checks the relations of the sorece and dest dirs. But if the 'parent'
dir is a mountpoint, the rename() syscall return -EXDEV instead because
it checks the parent dir's mountpoint of the sorece and dest dirs.

For example:
Case 1: rename() return -EINVAL
# mkdir -p parent/dir
# rename parent parent/dir/subdir parent
rename: parent: rename to parent/dir/subdir failed: Invalid argument

Case 2: rename() return -EXDEV
# mkdir parent
# mount -t tmpfs test parent
# mkdir parent/dir
# rename parent parent/dir/subdir parent
rename: parent: rename to parent/dir/subdir failed: Invalid cross-device link

In case 2, although 'parent' directory is a mountpoint, it acted as a root
dir of the "test tmpfs", so it should belongs to the same mounted fs of
'dir' directoty, so I think it shall return -EINVAL.

Is it a bug or just designed as this ?

Thanks,
Yi.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-12-27 12:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-25 13:16 [QUESTION] question about the errno of rename the parent dir to a subdir of a specified directory zhangyi (F)
2019-12-25 16:27 ` Al Viro
2019-12-27 12:47   ` zhangyi (F)

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).