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 <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Thiago Macieira 2023-09-22 20:04:11 -07:00
parent df8514a764
commit cad7164ee2

View File

@ -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)