QStorageInfo: get the label properly if the mounted device is a symlink
This happens for me with LVM: $ ls -l /dev/mapper/system-root /dev/system/root /dev/disk/by-label/* lrwxrwxrwx 1 root root 10 Nov 17 22:45 /dev/disk/by-label/system -> ../../dm-1 lrwxrwxrwx 1 root root 7 Nov 17 22:45 /dev/mapper/system-root -> ../dm-1 lrwxrwxrwx 1 root root 7 Nov 17 22:45 /dev/system/root -> ../dm-1 The mounted device according to /etc/mtab (/proc/self/mounts) is /dev/mapper/system-root. Change-Id: I3e15a26e0e424169ac2bffff1417b96779d84246 Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
d9f6b6d1f8
commit
4aba3dbcb3
@ -475,11 +475,14 @@ static inline QString retrieveLabel(const QByteArray &device)
|
||||
#ifdef Q_OS_LINUX
|
||||
static const char pathDiskByLabel[] = "/dev/disk/by-label";
|
||||
|
||||
QFileInfo devinfo(QFile::decodeName(device));
|
||||
QString devicePath = devinfo.canonicalFilePath();
|
||||
|
||||
QDirIterator it(QLatin1String(pathDiskByLabel), QDir::NoDotAndDotDot);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
QFileInfo fileInfo(it.fileInfo());
|
||||
if (fileInfo.isSymLink() && fileInfo.symLinkTarget().toLocal8Bit() == device)
|
||||
if (fileInfo.isSymLink() && fileInfo.symLinkTarget() == devicePath)
|
||||
return fileInfo.fileName();
|
||||
}
|
||||
#elif defined Q_OS_HAIKU
|
||||
|
Loading…
x
Reference in New Issue
Block a user