Unable to delete files to trash in a bind-mounted filesystem

bindmounttrash

I'm trying to set up shared home directory for two Linux installations and thus I'm using bind-mounts. My user is named dbz and his home directory is /home/dbz. I also have shared directory /home/shared where I store my shared files (this folder is also owned by user dbz).

I mount another directories from this shared directory into my home directory using binding:

mount -B /home/shared/work /home/dbz/work

This solution solves my needs and the only issue I have and don't know how to resolve is – when I'm trying to delete a file or directory from mounted directory I cannot delete it to trash, only permanent deletion is possible.
For example:

  • deleting file /home/shared/work/test.txt: OK, because deleting right from the directory where the file test.txt resides;
  • deleting file /home/dbz/work/test.txt: CAN'T, because… by the way, because what? do bind-mounts have some restrictions on file deletion?

Finally an issue submitted to bugzilla.kernel.org

Best Answer

This is a linux kernel issue. It's not looking at the true super-block of the source and destination filesystems:

17926 rename("d1/foo", "d2/foo")        = -1 EXDEV (Invalid cross-device link)

Looks like the issue is in do_rename() (fs/namei.c):

    error = -EXDEV;
    if (oldnd.mnt != newnd.mnt)
            goto exit2;

*sigh*

Related Question