From: "zhangyi (F)" <yi.zhang@huawei.com>
To: <viro@zeniv.linux.org.uk>, <linux-fsdevel@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <miaoxie@huawei.com>,
<zhangtianci1@huawei.com>
Subject: [QUESTION] question about the errno of rename the parent dir to a subdir of a specified directory
Date: Wed, 25 Dec 2019 21:16:09 +0800 [thread overview]
Message-ID: <4c54c1f0-fe9a-6dea-1727-6898e8dd85ef@huawei.com> (raw)
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.
next reply other threads:[~2019-12-25 13:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-25 13:16 zhangyi (F) [this message]
2019-12-25 16:27 ` Al Viro
2019-12-27 12:47 ` zhangyi (F)
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=4c54c1f0-fe9a-6dea-1727-6898e8dd85ef@huawei.com \
--to=yi.zhang@huawei.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miaoxie@huawei.com \
--cc=viro@zeniv.linux.org.uk \
--cc=zhangtianci1@huawei.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
all inboxes | Powered by JetHome®