Skip to content

KMountPoint: Avoid fstatat() when enumerating possible mount points

Emmanuel Pescosta requested to merge work/emmanuelp/kmountpoint_avoid_stat into master

On Linux the list of possible mountpoints is read from fstab. Fstab may contain automountable (in my case x-systemd.automount) but temporarily invalid entries, e.g., when a drive has been removed or when the network share is currently unreachable.

When enumerating fstab entries, fstatat() will cause that all entries are mounted. For all entries which cannot be mounted, fstatat() will block as seen in the following back trace:

0  0x00007fa07e457d8e in fstatat64 () from /usr/lib/
1  0x00007fa0804e283c in KMountPoint::possibleMountPoints(QFlags<KMountPoint::DetailsNeededFlag>) () from /usr/lib/
2  0x00007fa0804f5abe in ?? () from /usr/lib/
3  0x00007fa0804f62f0 in ?? () from /usr/lib/
4  0x00007fa0804f7639 in ?? () from /usr/lib/
5  0x00007fa080aa92d1 in DolphinView::setUrl(QUrl const&) () from /usr/lib/
6  0x00005573fbc6ba59 in ?? ()
7  0x00007fa07ea3b76b in ?? () from /usr/lib/
8  0x00007fa080980986 in KUrlNavigator::urlChanged(QUrl const&) () from /usr/lib/
9  0x00007fa080984d98 in KUrlNavigator::setLocationUrl(QUrl const&) () from /usr/lib/

Another bad side effect of using fstatat() during enumeration of possible mount points is, that all entries are mounted even if unused. Given that KMountPoint::possibleMountPoints() is called everytime when the URL in Dolphin changes, this will break the automatic unmount of idle mounts (see x-systemd.idle-timeout).

fstatat() has been added in commit f2b53eaf

Edited by Emmanuel Pescosta

Merge request reports