From cad7164ee24bb7b8b9ddf1ae8171a0098af7b0d7 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 22 Sep 2023 20:04:11 -0700 Subject: [PATCH] QStorageInfo/Linux: include QDir::Hidden in the search for labels There's nothing wrong with device labels starting with a dot. Whether udev would encode those as \x2e is unknown, but we may as well not tempt fate in case it has changed or changes in the future. Also including QDir::System in case udev places the actual device nodes in /dev/disks/by-label instead of a symlink. As a nice and intentional side-effect, QDirIterator no longer performs a stat() in each of the entries, removing the double stat'ing that started happening with the previous commit. Pick-to: 6.6 Change-Id: I9d43e5b91eb142d6945cfffd1787681b4cf2bb58 Reviewed-by: Ahmad Samir Reviewed-by: Thiago Macieira --- src/corelib/io/qstorageinfo_linux.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qstorageinfo_linux.cpp b/src/corelib/io/qstorageinfo_linux.cpp index 1a27ac060ba..99143a5975e 100644 --- a/src/corelib/io/qstorageinfo_linux.cpp +++ b/src/corelib/io/qstorageinfo_linux.cpp @@ -68,7 +68,8 @@ static inline QString retrieveLabel(const QByteArray &device) if (devicePath.isEmpty()) return QString(); - QDirIterator it(QLatin1StringView(pathDiskByLabel), QDir::NoDotAndDotDot); + auto filter = QDir::AllEntries | QDir::System | QDir::Hidden | QDir::NoDotAndDotDot; + QDirIterator it(QLatin1StringView(pathDiskByLabel), filter); while (it.hasNext()) { QFileInfo fileInfo = it.nextFileInfo(); if (fileInfo.symLinkTarget() == devicePath)