diff --git a/src/applib/smartctl_json_ata_parser.cpp b/src/applib/smartctl_json_ata_parser.cpp index 8844968..0fa79c1 100644 --- a/src/applib/smartctl_json_ata_parser.cpp +++ b/src/applib/smartctl_json_ata_parser.cpp @@ -213,6 +213,21 @@ hz::ExpectedVoid SmartctlJsonAtaParser::parse_section_info( } }, + {"device/protocol", _("Smartctl Device Protocol"), // NVMe, ... + [](const nlohmann::json& root_node, const std::string& key, const std::string& displayable_name) + -> hz::ExpectedValue + { + if (auto jval = get_node_data(root_node, "device/protocol"); jval.has_value()) { + StorageProperty p; + p.set_name(key, key, displayable_name); + p.value = jval.value(); + p.show_in_ui = false; + return p; + } + return hz::Unexpected(SmartctlParserError::KeyNotFound, std::format("Error getting key {} from JSON data.", key)); + } + }, + {"model_family", _("Model Family"), string_formatter()}, {"model_name", _("Device Model"), string_formatter()}, {"serial_number", _("Serial Number"), string_formatter()}, diff --git a/src/applib/smartctl_json_basic_parser.cpp b/src/applib/smartctl_json_basic_parser.cpp index 415bfea..539018f 100644 --- a/src/applib/smartctl_json_basic_parser.cpp +++ b/src/applib/smartctl_json_basic_parser.cpp @@ -90,6 +90,21 @@ hz::ExpectedVoid SmartctlJsonBasicParser::parse_section_bas } }, + {"device/protocol", _("Smartctl Device Protocol"), // NVMe, ... + [](const nlohmann::json& root_node, const std::string& key, const std::string& displayable_name) + -> hz::ExpectedValue + { + if (auto jval = get_node_data(root_node, "device/protocol"); jval.has_value()) { + StorageProperty p; + p.set_name(key, key, displayable_name); + p.value = jval.value(); + p.show_in_ui = false; + return p; + } + return hz::Unexpected(SmartctlParserError::KeyNotFound, std::format("Error getting key {} from JSON data.", key)); + } + }, + {"vendor", _("Vendor"), string_formatter()}, // Flash drive {"scsi_vendor", _("Vendor"), string_formatter()}, // Flash drive diff --git a/src/applib/smartctl_json_nvme_parser.cpp b/src/applib/smartctl_json_nvme_parser.cpp index b06fc70..5416d5a 100644 --- a/src/applib/smartctl_json_nvme_parser.cpp +++ b/src/applib/smartctl_json_nvme_parser.cpp @@ -129,6 +129,21 @@ hz::ExpectedVoid SmartctlJsonNvmeParser::parse_section_info } }, + {"device/protocol", _("Smartctl Device Protocol"), // NVMe, ... + [](const nlohmann::json& root_node, const std::string& key, const std::string& displayable_name) + -> hz::ExpectedValue + { + if (auto jval = get_node_data(root_node, "device/protocol"); jval.has_value()) { + StorageProperty p; + p.set_name(key, key, displayable_name); + p.value = jval.value(); + p.show_in_ui = false; + return p; + } + return hz::Unexpected(SmartctlParserError::KeyNotFound, std::format("Error getting key {} from JSON data.", key)); + } + }, + {"model_name", _("Device Model"), string_formatter()}, {"serial_number", _("Serial Number"), string_formatter()}, {"firmware_version", _("Firmware Version"), string_formatter()}, diff --git a/src/applib/storage_device.cpp b/src/applib/storage_device.cpp index 1595f51..c697765 100644 --- a/src/applib/storage_device.cpp +++ b/src/applib/storage_device.cpp @@ -597,6 +597,11 @@ void StorageDevice::detect_drive_type_from_properties(const StoragePropertyRepos // Note: USB flash drives in non-scsi mode do not have this property. const auto& smartctl_type = device_type_prop.get_value(); + std::string lowercase_protocol; + if (auto device_protocol_prop = property_repo.lookup_property("device/protocol"); !device_protocol_prop.empty()) { + lowercase_protocol = hz::string_to_lower_copy(device_protocol_prop.get_value()); + } + if (smartctl_type == "scsi") { // USB flash in scsi mode, optical, scsi, etc. if (BuildEnv::is_kernel_linux() && get_device_base().starts_with("sr")) { set_detected_type(StorageDeviceDetectedType::CdDvd); @@ -616,9 +621,13 @@ void StorageDevice::detect_drive_type_from_properties(const StoragePropertyRepos } else if (smartctl_type == "nvme") { // NVMe SSD set_detected_type(StorageDeviceDetectedType::Nvme); + // Try protocol (type may be a USB bridge name) + } else if (lowercase_protocol == "nvme") { // nvme behind USB bridge like "sntrealtek" + set_detected_type(StorageDeviceDetectedType::Nvme); + } else { // TODO Detect unsupported RAID - debug_out_warn("app", "Unsupported type " << smartctl_type << " reported by smartctl for " << get_device_with_type() << "\n"); + debug_out_warn("app", "Unsupported type " << smartctl_type << " (protocol: " << lowercase_protocol << ") reported by smartctl for " << get_device_with_type() << "\n"); } }