feat(storage): add MMC storage vendor identification via sysfs#702
Conversation
Read manfid/oemid/name from sysfs for MMC storage devices and resolve vendor names using MANFID/OEMID lookup tables. Add safeReadSysFsFile() utility with path traversal protection. Log: 添加MMC存储设备厂商识别功能,通过sysfs读取manfid/oemid识别厂商 PMS: BUG-368319 Influence: MMC/eMMC存储设备的厂商信息不再为空,可正确显示对应厂商名称
deepin pr auto review★ 总体评分:88分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // DeviceStorage.cpp:修复空值覆盖逻辑缺陷
if (m_Driver.contains("mmcblk")) {
QString sysfsDeviceLink = mapInfo.value("SysFS Device Link");
if (!sysfsDeviceLink.isEmpty())
{
if (!sysfsDeviceLink.startsWith("/sys/"))
{
sysfsDeviceLink = "/sys" + sysfsDeviceLink;
}
QString err;
QString name = Common::safeReadSysFsFile(sysfsDeviceLink, "name", err);
// 增加对读取内容非空的校验,防止空字符串覆盖 hwinfo 已解析的有效数据
if (err.isEmpty() && !name.isEmpty()) {
m_Name = name;
}
QString manfIdRaw = Common::safeReadSysFsFile(sysfsDeviceLink, "manfid", err);
if (err.isEmpty() && !manfIdRaw.isEmpty()) {
QString manfName = getManfName(manfIdRaw);
if (!manfName.isEmpty()) {
m_Vendor = manfName;
}
}
QString oemIdRaw = Common::safeReadSysFsFile(sysfsDeviceLink, "oemid", err);
if (err.isEmpty() && !oemIdRaw.isEmpty()) {
if (m_Vendor.isEmpty()) {
m_Vendor = getOemName(oemIdRaw);
}
}
}
}
// DeviceStorage.h:建议补充 const 修饰符
// QString getManfName(const QString &rawManfId) const;
// QString getOemName(const QString &rawOemId) const;
// DeviceStorage.cpp:建议补充 const 修饰符
// QString DeviceStorage::getManfName(const QString &rawManfId) const
// QString DeviceStorage::getOemName(const QString &rawOemId) const |
|
/merge |
|
This pr cannot be merged! (status: blocked) |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos, lzwind The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/merge |
Read manfid/oemid/name from sysfs for MMC storage devices and resolve vendor names using MANFID/OEMID lookup tables. Add safeReadSysFsFile() utility with path traversal protection.
Log: 添加MMC存储设备厂商识别功能,通过sysfs读取manfid/oemid识别厂商
PMS: BUG-368319
Influence: MMC/eMMC存储设备的厂商信息不再为空,可正确显示对应厂商名称