Implement proper SMART on/off switch support detection.

This commit is contained in:
Alexander Shaduri
2024-05-14 15:55:12 +04:00
parent 537ea258ca
commit ac2d3d6b33
3 changed files with 18 additions and 1 deletions
+11
View File
@@ -681,6 +681,17 @@ StorageDevice::Status StorageDevice::get_smart_status() const
bool StorageDevice::get_smart_switch_supported() const
{
const bool supported = get_smart_status() != Status::Unsupported;
// NVMe does not support on/off
const bool is_nvme = get_detected_type() == StorageDeviceDetectedType::Nvme;
return !get_is_virtual() && supported && !is_nvme;
}
StorageDevice::Status StorageDevice::get_aodc_status() const
{
// smart-disabled drives are known to print some garbage, so
+3
View File
@@ -129,6 +129,9 @@ class StorageDevice {
/// Get SMART status
[[nodiscard]] Status get_smart_status() const;
/// Get if SMART on/off is supported
[[nodiscard]] bool get_smart_switch_supported() const;
/// Get AODC status
[[nodiscard]] Status get_aodc_status() const;
+4 -1
View File
@@ -638,6 +638,9 @@ void GscMainWindow::on_action_enable_smart_toggled(Gtk::ToggleAction* action)
if (!drive || drive->get_is_virtual() || drive->get_test_is_active())
return;
if (!drive->get_smart_switch_supported())
return;
StorageDevice::Status status = drive->get_smart_status();
if (status == StorageDevice::Status::Unsupported) // this shouldn't happen
return;
@@ -848,7 +851,7 @@ void GscMainWindow::set_drive_menu_status(const StorageDevicePtr& drive)
if ((action = actiongroup_device_->get_action(APP_ACTION_NAME(action_remove_virtual_device))))
action->set_visible(drive && is_virtual);
if ((action = actiongroup_device_->get_action(APP_ACTION_NAME(action_enable_smart)))) {
action->set_sensitive(smart_status != StorageDevice::Status::Unsupported);
action->set_sensitive(drive && drive->get_smart_switch_supported());
}
if ((action = actiongroup_device_->get_action(APP_ACTION_NAME(action_enable_aodc))))
action->set_sensitive(aodc_status != StorageDevice::Status::Unsupported);