diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2023-10-19 08:24:36 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2023-10-21 15:21:23 -0700 |
commit | ddc39eb3a46d699c23d39f0e914978199eb98cc6 (patch) | |
tree | 360f66d5e16f354faa9d1e3a84daf4bb983740ed /src/corelib/io | |
parent | 1cd6c6c69e9813c791f8bebb6c0c9214ce765060 (diff) |
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>
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qstorageinfo_linux.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/io/qstorageinfo_linux.cpp b/src/corelib/io/qstorageinfo_linux.cpp index fab5a44fad..840cb845a5 100644 --- a/src/corelib/io/qstorageinfo_linux.cpp +++ b/src/corelib/io/qstorageinfo_linux.cpp @@ -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)))); } |