diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2023-10-12 15:58:34 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2023-10-21 15:21:39 -0700 |
commit | feb67bbdd202ac708cbf41f5698c4e2246ad4232 (patch) | |
tree | 228dd0e80ce5b5ff868e880e9a22b30d6a33adf7 /src/corelib | |
parent | 39843b65f4b04a5d92d5a867131ba83cd3b92a02 (diff) |
QStorageInfo/Unix: exclude invalid volumes from mountedVolumes()
Invalid are usually those mounted on a filesystem we can't access:
$ df /run/user/0/gvfs
df: /run/user/0/gvfs: Permission denied
$ ./qstorageinfo /run/user/0/gvfs
Could not get info on /run/user/0/gvfs
df already doesn't include it by default:
$ df | grep -c gvfs
0
But we were:
$./qstorageinfo | sed -n '1p;/gvfs/p'
Filesystem (Type) Size Available BSize Label Mounted on
gvfsd-fuse (fuse.gvfsd-fuse) RW 0 0 0 /run/user/0/gvfs
Note also how this is showing a total size of 0, which is usually the
type of filesystem we exclude. It's actually -1 but got rounded down to
0 when we divided by 1024.
Pick-to: 6.6
Change-Id: I8f3ce163ccc5408cac39fffd178d7e4f9dc13b24
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/io/qstorageinfo_linux.cpp | 2 | ||||
-rw-r--r-- | src/corelib/io/qstorageinfo_unix.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/io/qstorageinfo_linux.cpp b/src/corelib/io/qstorageinfo_linux.cpp index 2910a4bfa3..e1f7fe65ac 100644 --- a/src/corelib/io/qstorageinfo_linux.cpp +++ b/src/corelib/io/qstorageinfo_linux.cpp @@ -259,7 +259,7 @@ QList<QStorageInfo> QStorageInfoPrivate::mountedVolumes() for (MountInfo &info : infos) { QStorageInfoPrivate d(std::move(info)); d.retrieveVolumeInfo(); - if (d.bytesTotal == 0 && d.rootPath != u'/') + if (d.bytesTotal <= 0 && d.rootPath != u'/') continue; if (info.stDev != deviceIdForPath(d.rootPath)) continue; // probably something mounted over this mountpoint diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index af65823b1d..75d83a58d6 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -476,7 +476,7 @@ QList<QStorageInfo> QStorageInfoPrivate::mountedVolumes() info.d->device = it.device(); info.d->fileSystemType = it.fileSystemType(); info.d->subvolume = it.subvolume(); - if (info.bytesTotal() == 0 && info != root()) + if (info.bytesTotal() <= 0 && info != root()) continue; volumes.append(info); } |