QStorageInfo/Linux: re-work the mountedVolumes() check for mounted-overs
Commit ddc39eb3a4 ("QStorageInfo/Linux:
fix mountedVolumes() for paths mounted over") added a clever check that
did stat() on the path to figure out if it was the device that we'd just
found on /proc/self/mountinfo. But if the same device was mounted on top
again, we may have got the wrong answer.
More importantly, since kernel 6.9, btrfs subvolume mounts no longer
report the subvolume's block ID in /proc/self/mountinfo, which would
lead us to conclude every single subvolume has been mounted-over.
So let's revert back to string-matching later lines to see if any is a
parent path.
https://lore.kernel.org/linux-btrfs/2548140.Uh0CODmnKu@tjmaciei-mobl5/T/
Fixes: QTBUG-125721
Pick-to: 6.7
Change-Id: If3345151ddf84c43a4f1fffd17d3d59fef4446dd
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
bb10
parent
f6cd286e66
commit
ad968d3602
|
|
@ -271,14 +271,21 @@ QList<QStorageInfo> QStorageInfoPrivate::mountedVolumes()
|
|||
};
|
||||
|
||||
QList<QStorageInfo> volumes;
|
||||
for (MountInfo &info : infos) {
|
||||
volumes.reserve(infos.size());
|
||||
for (auto it = infos.begin(); it != infos.end(); ++it) {
|
||||
MountInfo &info = *it;
|
||||
// Scan the later lines to see if any is a parent to this
|
||||
auto isParent = [&info](const MountInfo &maybeParent) {
|
||||
return isParentOf(maybeParent.mountPoint, info.mountPoint);
|
||||
};
|
||||
if (std::find_if(it + 1, infos.end(), isParent) != infos.end())
|
||||
continue;
|
||||
|
||||
const auto infoStDev = info.stDev;
|
||||
QStorageInfoPrivate d(std::move(info));
|
||||
d.retrieveVolumeInfo();
|
||||
if (d.bytesTotal <= 0 && d.rootPath != u'/')
|
||||
continue;
|
||||
if (infoStDev != deviceIdForPath(d.rootPath))
|
||||
continue; // probably something mounted over this mountpoint
|
||||
d.name = labelForDevice(d, infoStDev);
|
||||
volumes.emplace_back(QStorageInfo(*new QStorageInfoPrivate(std::move(d))));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue