Skip to content

[BUG] Cannot move to Trash inside a nested btrfs subvolume (Dolphin works) #269

Backlog

Description

@Ruivalim

What happened?

Moving a file to Trash fails for any file inside a nested btrfs subvolume, for example ~/Downloads when it is its own subvolume inside @home (a common setup to keep big, disposable folders out of snapper snapshots). Plain permissions are fine and permanent delete works; only Trash fails.

Dolphin trashes the same files without problems, because KIO falls back to the home trash (~/.local/share/Trash) when it cannot use a per-mount trash, copying across devices if needed. Luciole calls g_file_trash() (src/operations/trash_service.cpp) and just surfaces the GIO error:

Trashing on system internal mounts is not supported

Same error from the CLI:

$ touch ~/Downloads/test && gio trash ~/Downloads/test
gio: file:///home/<user>/Downloads/test: Trashing on system internal mounts is not supported

Why it happens (GLib 2.90.1, gio/glocalfile.c)

  1. A nested btrfs subvolume has its own st_dev, different from $HOME:

    $ stat -c '%d %n' ~ ~/Downloads
    51 /home/<user>
    102 /home/<user>/Downloads
    
  2. So g_local_file_trash() does not use the home trash. It walks up until the device changes (find_mountpoint_for), which gives ~/Downloads as topdir, then calls ignore_trash_path(topdir).

  3. ignore_trash_path() looks up a mount entry at that path. A nested subvolume is not mounted, so there is no entry and it returns TRUE, which produces the error above.

  4. Even if the subvolume is mounted explicitly at the same path, the entry is reported as is_system_internal = TRUE (it is btrfs on the same device as / and /home), so it is still refused. Also, /proc/self/mountinfo reports 0:35 for every btrfs mount, so it cannot be matched by device number anyway.

Creating ~/Downloads/.Trash-1000 (mode 0700) does not help on its own, since the refusal happens before GIO looks for it.

Workaround that works

Mount the subvolume explicitly through fstab with x-gvfs-trash. For system-internal mounts, ignore_trash_mount() re-reads the fstab entry and honors that option:

UUID=<fs-uuid> /home/<user>/Downloads btrfs subvol=/@home/<user>/Downloads,defaults,noatime,compress=zstd:1,nofail,x-gvfs-trash 0 0

After that, gio trash and Luciole both work, and trashed files go to ~/Downloads/.Trash-1000. Passing x-gvfs-trash only to mount(8) was not enough here: the option lands in /run/mount/utab with ROOT=/, which does not match the subvolume root in mountinfo, so libmount drops it.

Suggestion

When g_file_trash() fails with G_IO_ERROR_NOT_SUPPORTED on a local file, Luciole could fall back to the home trash the way KIO does (move or copy into $XDG_DATA_HOME/Trash/files plus a .trashinfo), or at least offer a permanent delete in the error dialog. This may also cover #190 (ntfs-3g), which looks like the same class of problem: no usable per-mount trash.

How can we reproduce it?

  1. On btrfs, create a nested subvolume inside your home, e.g. btrfs subvolume create ~/trashtest (or move a folder into one).
  2. Put a file in it and press Delete in Luciole.
  3. Trash fails with "Trashing on system internal mounts is not supported". Dolphin trashes the same file fine.

Luciole version

luciole 0.1.0 (27d64dc)

System details

Distribution: CachyOS (Arch based), kernel 7.3.5
GLib: 2.90.1
Filesystem: btrfs, @home mounted at /home, nested subvolumes inside it

Investigated and written with Claude Code.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions