Bug 349617 - Clicking on device of which a subdir is bound opens that bound subdir instead of the device's root
Summary: Clicking on device of which a subdir is bound opens that bound subdir instead...
Status: RESOLVED FIXED
Alias: None
Product: frameworks-solid
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.83.0
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Lukáš Tinkl
URL:
Keywords:
: 352179 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-06-26 10:40 UTC by Sybren Stüvel
Modified: 2021-06-25 13:01 UTC (History)
11 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.84


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sybren Stüvel 2015-06-26 10:40:08 UTC
In Dolphin, file dialogs, etc. there is a list of devices. For me, this list includes the device "Linux-HD-NEW", which is (you guessed it) my new harddisk partition I devoted to Linux. My OS and home directory are stored on a SSD, which has limited capacity. To save some space I have moved some directories from my homedir to my new harddisk, including my Steam directory /home/sybren/.steam. To make Steam blissfully unaware of this, I bind /media/linux-hd-new/DOTsteam to /home/sybren/.steam with the following lines in /etc/fstab:

  /dev/disk/by-label/Linux-HD-NEW /media/linux-hd-new ext4 errors=remount-ro 1 2
  /media/linux-hd-new/DOTsteam /home/sybren/.steam      none bind,user

Back to the list of devices in Dolphin. When I click on "Linux-HD-NEW", I would expect Dolphin to open /media/linux-hd-new. Instead, it opens /home/sybren/.steam.


Reproducible: Always

Steps to Reproduce:
1. mount a disk at /media/example
2. bind a directory in of that disk somewhere else; mount --bind /media/example/subdir /home/yourname/otherdir
3. click the device name in Dolphin


Actual Results:  
I see a subdirectory of the device, /home/yourname/otherdir


Expected Results:  
I expect to see the root directory of that device, /media/example

Kubuntu 15.04
KDE platform version 4.14.6 (The Version field in the bug tracker only went up to 4.14.1, hence I selected "unspecified" and specified it here.)
Comment 1 g9879242 2015-09-02 20:28:11 UTC
This bug exists in Kubuntu 15.10 too:
Dolphin 15.07.90
KDE Frameworks 5.13.0
KDE Plasma 5.3.95

Steps to reproduce:
boot kubuntu live dvd
sudo su
mkdir /mnt/test
mount -t auto /dev/sda1 /mnt/test
mkdir /home/kubuntu/test
mount /mnt/test/somedir /home/kubuntu/test -o bind
open Dolphin
clicking on the device opens /home/kubuntu/test (/mnt/test/somedir) instead of /mnt/test

This is most likely due to the fact that libsolid only can handle 1 mountpoint per device (and does not check if it is a bound mount): There is a "FIXME" in the source code of libsolid ;-)
Comment 2 solazs 2015-09-18 13:23:05 UTC
This bug is present on Kubuntu 15.04 and Arch Linux as well
Comment 3 soltesz.balazs.91 2015-12-14 20:56:27 UTC
still an issue in kubuntu 5.5.0
Comment 4 solazs 2016-05-19 12:08:25 UTC
Still an issue.
Comment 5 Brian Frick 2016-11-21 22:14:29 UTC
Please confirm this bug. I've noticed it since 5.2 or earlier, and I think the reason there are so few comments here is because it's difficult to word correctly to get a result in Google.
I can confirm it is still present in 5.7 on Fedora 24. Clicking on the device name in the Dolphin sidebar will move the user to the last directory bound to the device in fstab rather than the device root.
Comment 6 solazs 2016-11-22 09:47:10 UTC
This bug is still present in KDE.
+1 for Brian, please confirm this bug. It is 100% reproduceable.
Versions:
plasma: 5.8.3
KDE Frameworks: 5.27.0
Qt: 5.7.0
On Arch Linux x86_64, kernel 4.8.7
Comment 7 Krzysztof Marczak 2017-01-22 08:18:27 UTC
It still happen in KDE Frameworks 5.28
I use following binds in fstab (to save space and reduce traffic on SSD drive):
/media/data/var  /var   none bind  0 0
/media/data/tmp  /tmp   none bind  0 0
It produces the same problem as reported here. When I try to open "data" in Dolphin (from devices list), it goes to /media/data/tmp instead of /media/data
Comment 8 pmargeti34 2017-03-08 15:25:41 UTC
*** This bug has been confirmed by popular vote. ***
Comment 9 bugreporter42 2017-12-18 19:49:17 UTC
It's still broken. This looks non-trivial to fix, the udisks2 interfaces don't appear to have the required information in a reasonably digestable form.

org.freedesktop.UDisks2.Filesystem has a MountPoints property that returns an alphabetically sorted list of mountpoints for a block device, including bind mounts. As far as I can tell, it's impossible to tell which of the mountpoints in the list is the mount point where the device was mounted using the udisks2 interfaces.

(You can do a 'udisksctl dump' to get the info udisks2 provides.)
Comment 10 bugreporter42 2017-12-18 21:37:32 UTC
udisks2 bug report:
https://github.com/storaged-project/udisks/issues/478
Comment 11 Brian Frick 2017-12-20 22:17:16 UTC
Thank you for that command. I store media on a separate partition that I can share with my Windows boot, and bind those folders to the respective home directories. So `udiskctl dump` shows

org.freedesktop.UDisks2.Filesystem:
  MountPoints:        /home/frick/Music
                      /home/frick/Pictures
                      /home/frick/Videos
                      /mnt/Share

When clicking on the device in the sidebar, Dolphin will open Music (first in MountPoints, not last in fstab as I had thought).

But (just me guessing) I think most desktop users using bind mounts are going to configure them in fstab, and that adds a "Configuration" dictionary at the top of the block with a 'dir' element storing the original device's mount point (for me, that's 'dir': <b'/mnt/Share'>). If the udisks issue isn't fixed, I think taking the path from 'dir', or, if not found, the shortest path from MountPoints would cover most cases.
Comment 12 pmargeti34 2017-12-21 10:24:42 UTC
(In reply to Brian Frick from comment #11)
> Thank you for that command. I store media on a separate partition that I can
> share with my Windows boot, and bind those folders to the respective home
> directories. So `udiskctl dump` shows
> 
> org.freedesktop.UDisks2.Filesystem:
>   MountPoints:        /home/frick/Music
>                       /home/frick/Pictures
>                       /home/frick/Videos
>                       /mnt/Share
> 
> When clicking on the device in the sidebar, Dolphin will open Music (first
> in MountPoints, not last in fstab as I had thought).
> 
> But (just me guessing) I think most desktop users using bind mounts are
> going to configure them in fstab, and that adds a "Configuration" dictionary
> at the top of the block with a 'dir' element storing the original device's
> mount point (for me, that's 'dir': <b'/mnt/Share'>). If the udisks issue
> isn't fixed, I think taking the path from 'dir', or, if not found, the
> shortest path from MountPoints would cover most cases.

Good points made here, my use case for bind mounts is indeed fstab setup for xdg_dirs on a shared ntfs mount.

My workaround for this bug was creating an additional bind mount for the drive itself pointing to a hidden folder in my home directory. This correctly opens drive root in dolphin et al but it's hacky and I'd much rather see a proper solution in the form of fstab being parsed like Brian Frick suggested.
Comment 13 Bug Janitor Service 2021-05-21 14:29:13 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/solid/-/merge_requests/37
Comment 14 Ahmad Samir 2021-05-21 15:18:45 UTC
*** Bug 352179 has been marked as a duplicate of this bug. ***
Comment 15 Ahmad Samir 2021-06-23 18:37:14 UTC
Git commit ef0b0dfa00b1de70c6d8e6913bbfdb79e7d3d1b6 by Ahmad Samir.
Committed on 23/06/2021 at 09:16.
Pushed by ahmadsamir into branch 'master'.

Find the base mount point of a partition that has bind mounts

With bind mounts on Linux, UDisks returns a 'MountPoints' property that could
include several paths, try to get the actual mount point of the partition
and ignore bind mounts.

Inspired by the approach used by GNOME's gio, use libmount to parse
"/proc/self/mountinfo" and check the path returned by mnt_fs_get_root(), for
the base partition this should return "/", for bind mounts it returns a dir
e.g. /mnt/dirA/.

This fixes a bug where clicking a Device icon in the Places panel could open
the path of one of the bind mounts instead of the actual/base partition mount
point, which is confusing to say the least.

For more details:
https://invent.kde.org/frameworks/solid/-/merge_requests/37

https://gitlab.gnome.org/GNOME/glib/-/issues/1271#note_352412
https://gitlab.gnome.org/GNOME/glib/-/commit/e1fa5ffb91e74376394fe17612015d44fec82366
https://github.com/storaged-project/udisks/issues/478
FIXED-IN: 5.84

M  +5    -0    CMakeLists.txt
M  +4    -0    src/solid/devices/backends/udisks2/CMakeLists.txt
M  +53   -8    src/solid/devices/backends/udisks2/udisksstorageaccess.cpp
M  +2    -0    src/solid/devices/config-solid.h.cmake

https://invent.kde.org/frameworks/solid/commit/ef0b0dfa00b1de70c6d8e6913bbfdb79e7d3d1b6
Comment 16 Sybren Stüvel 2021-06-24 08:41:38 UTC
Thank you Ahmad for fixing this!
Comment 17 Ahmad Samir 2021-06-25 13:01:44 UTC
The bug report was very informative, i.e. the bug reporters investigated the issue pretty well ;)