Skip to content

Commit 8f1185f

Browse files
itsXuStdeepin-bot[bot]
authored andcommitted
fix: block model shows 'UnKnow'
cannot obtain model info from either smartctl nor lshw commands, try with udevadm command to obtain ID_MODEL field. Log: fix block model missing. Bug: https://pms.uniontech.com/bug-view-322579.html
1 parent db3d1ce commit 8f1185f

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

service/diskoperation/DeviceStorage.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,20 @@ void DeviceStorage::getDiskInfoModel(const QString &devicePath, QString &model)
504504
}
505505
}
506506

507+
cmd = "udevadm info " + devicePath + " | grep ID_MODEL=";
508+
proc.start("bash", QStringList() << "-c" << cmd);
509+
proc.waitForFinished(-1);
510+
outPut = proc.readAllStandardOutput();
511+
if (!outPut.isEmpty()) {
512+
auto idModel = outPut.split("=", QString::SkipEmptyParts);
513+
if (idModel.count() > 1)
514+
model = idModel.at(1).trimmed();
515+
if (!model.isEmpty())
516+
return;
517+
}
518+
519+
qWarning() << "tried a lot but got nothing about model for" << devicePath;
520+
507521
// 若未获取到型号名,返回未知
508522
model = "UnKnow";
509523
return;

0 commit comments

Comments
 (0)