QStorageInfo/Linux: fix mountedVolumes() for paths mounted over
This fixes a similar problem as the previous commit. Because Linux allows one to mount over non-empty paths, it's possible to make mountpoints unreachable, and yet they will still be present in the /proc/self/mountinfo listing. Because we have the device ID from the scan, we can confirm that the mountpoint matches the MountInfo. # mkdir -p /tmp/foo/bar # mount -t tmpfs /tmp/foo/bar # mount -t tmpfs -o size=1M /tmp/foo # mkdir /tmp/foo/bar $ ./tests/manual/qstorageinfo/qstorageinfo | awk 'NR==1 || /tmp\/foo/' Filesystem (Type) Size Available BSize Label Mounted on tmpfs RW 1024 1024 4096 /tmp/foo Change-Id: I79e700614d034281bf55fffd178f8b99b10a8b69 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
1cd6c6c69e
commit
ddc39eb3a4
@ -178,6 +178,8 @@ QList<QStorageInfo> QStorageInfoPrivate::mountedVolumes()
|
||||
d.retrieveVolumeInfo();
|
||||
if (d.bytesTotal == 0 && d.rootPath != u'/')
|
||||
continue;
|
||||
if (info.stDev != deviceIdForPath(d.rootPath))
|
||||
continue; // probably something mounted over this mountpoint
|
||||
d.name = retrieveLabel(d.device);
|
||||
volumes.emplace_back(QStorageInfo(*new QStorageInfoPrivate(std::move(d))));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user