Subject: bug#25930: optimize mv for multiple bind mounts

From: Sven Joachim <[email-masked]>
Date: Sat, 04 Mar 2017 09:01:14 +0100

On 2017-03-02 13:16 -0800, L A Walsh wrote:

> Sven Joachim wrote:
>> ,----
>> |   EXDEV  oldpath and newpath are not on the same mounted filesystem.
>> |          (Linux  permits  a  filesystem  to  be  mounted at multiple
>> |          points, but rename() does not work across  different  mount
>> |          points, even if the same filesystem is mounted on both.)
>>   
> ----
>    That's unfortunate, as Windows recognizes moves between
> the same device and does a rename vs. a copy (i.e. it doesn't
> matter if the mounted object from the mount is different, as
> long as the rename happens between the same devices).

Linux used to do the same in kernel 2.2, but changed the behavior when
bind mounts were introduced in 2.4.0.  In other words, it's deliberate.

>    Anyone know why Linux doesn't do detection by device vs.
> by mount point?  Both pieces of info have their use, but for rename
> seems that 'by device' would be optimal.

It is meant as a security measure, bind mounts give you the option to
confine file renames and hard links to a directory subtree even if that
directory does not live on its own filesystem.  See this mail by Al Viro
on that matter: http://yarchive.net/comp/linux/bind_mounts.html.

Cheers,
       Sven