diff --git a/gsmartcontrol/TODO b/gsmartcontrol/TODO index 1191dbd..3f0e92e 100644 --- a/gsmartcontrol/TODO +++ b/gsmartcontrol/TODO @@ -36,14 +36,22 @@ Bugs / patches: TODO: -Add debian/ubuntu's su-to-root support to gsmartcontrol-root. +Add debian/ubuntu's su-to-root support to gsmartcontrol-root. Set tooltips wherever we have "No description available". - !!! Allow quitting when test is running (ask first). ++"Add Device" window needs tooltips on both labels and entries. ++ Don't mention -d 3ware on windows in the tooltip. ++ Both points go for the preferences window as well. + ++Fixed usb drive re-detection with scsi. ++Fixed invalid regexps in tw_cli parsing. ++Added support for "Product" field of USB drives (used instead of Device in newer smartctl) + + Testing: If ETA time has elapsed, but it's still only at 10% completion, diff --git a/gsmartcontrol/src/applib/smartctl_executor.cpp b/gsmartcontrol/src/applib/smartctl_executor.cpp index f6f4e30..7f42c71 100644 --- a/gsmartcontrol/src/applib/smartctl_executor.cpp +++ b/gsmartcontrol/src/applib/smartctl_executor.cpp @@ -109,11 +109,11 @@ std::string execute_smartctl(const std::string& device, const std::string& devic if (!smartctl_ex->execute() || !smartctl_ex->get_error_msg().empty()) { debug_out_warn("app", DBG_FUNC_MSG << "Error while executing smartctl binary.\n"); - std::string output = smartctl_ex->get_stdout_str(); + smartctl_output = smartctl_ex->get_stdout_str(); // check if it's a device permission error. // Smartctl open device: /dev/sdb failed: Permission denied - if (app_pcre_match("/Smartctl open device.+Permission denied/mi", output)) { + if (app_pcre_match("/Smartctl open device.+Permission denied/mi", smartctl_output)) { return "Permission denied while opening device."; } diff --git a/gsmartcontrol/src/applib/storage_detector_win32.cpp b/gsmartcontrol/src/applib/storage_detector_win32.cpp index 4b1a8bc..ef76124 100644 --- a/gsmartcontrol/src/applib/storage_detector_win32.cpp +++ b/gsmartcontrol/src/applib/storage_detector_win32.cpp @@ -116,8 +116,8 @@ std::string get_scan_open_multiport_devices(std::vector& dr // /dev/sda -d sat # /dev/sda [SAT], ATA device // we only pick the ones with ports - pcrecpp::RE port_re = app_pcre_re("/^(\\/dev/\\[a-z0-9]),([0-9])+[ \\t]+-d[ \\t]+([^\\t\\n]+)/i"); - pcrecpp::RE dev_re = app_pcre_re("/^\\/dev\\/sd([a-z])$/"); + pcrecpp::RE port_re = app_pcre_re("/^(/dev/[a-z0-9]),([0-9])+[ \\t]+-d[ \\t]+([^\\t\\n]+)/i"); + pcrecpp::RE dev_re = app_pcre_re("/^/dev/sd([a-z])$/"); for (std::size_t i = 0; i < lines.size(); ++i) { std::string dev, port_str, type; diff --git a/gsmartcontrol/src/applib/storage_device.cpp b/gsmartcontrol/src/applib/storage_device.cpp index 216686f..814459c 100644 --- a/gsmartcontrol/src/applib/storage_device.cpp +++ b/gsmartcontrol/src/applib/storage_device.cpp @@ -228,7 +228,7 @@ std::string StorageDevice::parse_basic_data(bool do_set_properties, bool emit_si if (app_pcre_match("/^Device Model:[ \\t]*(.*)$/mi", info_output_, &model)) { // HD's and cdroms model_name_ = hz::string_remove_adjacent_duplicates_copy(hz::string_trim_copy(model), ' '); - } else if (app_pcre_match("/^Device:[ \\t]*(.*)$/mi", info_output_, &model)) { // usb flash drives + } else if (app_pcre_match("/^(?:Device|Product):[ \\t]*(.*)$/mi", info_output_, &model)) { // usb flash drives model_name_ = hz::string_remove_adjacent_duplicates_copy(hz::string_trim_copy(model), ' '); } diff --git a/gsmartcontrol/src/gsc_add_device_window.cpp b/gsmartcontrol/src/gsc_add_device_window.cpp index 3eb26be..856a5d8 100644 --- a/gsmartcontrol/src/gsc_add_device_window.cpp +++ b/gsmartcontrol/src/gsc_add_device_window.cpp @@ -38,18 +38,33 @@ GscAddDeviceWindow::GscAddDeviceWindow(BaseObjectType* gtkcobj, const app_ui_res APP_UI_RES_AUTO_CONNECT(device_name_browse_button, clicked); - Glib::ustring device_name_tooltip = "Device name, e.g. %s."; -#ifdef _WIN32 - device_name_tooltip = hz::string_sprintf(device_name_tooltip.c_str(), "\"pd0\" for the first physical drive"); -#else - device_name_tooltip = hz::string_sprintf(device_name_tooltip.c_str(), "\"/dev/sda\" or \"/dev/twa0\""); + Glib::ustring device_name_tooltip = "Device name"; +#if defined CONFIG_KERNEL_FAMILY_WINDOWS + device_name_tooltip = "Device name (for example, use \"pd0\" for the first physical drive)"; +#elif defined CONFIG_KERNEL_LINUX + device_name_tooltip = "Device name (for example, /dev/sda or /dev/twa0)"; #endif - Gtk::Label* device_name_label = lookup_widget("device_name_label"); - app_gtkmm_set_widget_tooltip(*device_name_label, device_name_tooltip); - + if (Gtk::Label* device_name_label = lookup_widget("device_name_label")) { + app_gtkmm_set_widget_tooltip(*device_name_label, device_name_tooltip); + } Gtk::Entry* device_name_entry = 0; APP_UI_RES_AUTO_CONNECT(device_name_entry, changed); + if (device_name_entry) { + app_gtkmm_set_widget_tooltip(*device_name_entry, device_name_tooltip); + } + + + Glib::ustring device_type_tooltip = "Smartctl -d option parameter"; +#if defined CONFIG_KERNEL_LINUX + device_type_tooltip = "Smartctl -d option parameter. For example, use 3ware,1 for a second drive behind a 3ware RAID controller."; +#endif + if (Gtk::Label* device_type_label = lookup_widget("device_type_label")) { + app_gtkmm_set_widget_tooltip(*device_type_label, device_type_tooltip); + } + if (Gtk::Entry* device_type_entry = lookup_widget("device_type_entry")) { + app_gtkmm_set_widget_tooltip(*device_type_entry, device_type_tooltip); + } // Accelerators @@ -61,7 +76,7 @@ GscAddDeviceWindow::GscAddDeviceWindow(BaseObjectType* gtkcobj, const app_ui_res } -#ifndef _WIN32 +#ifdef _WIN32 // "Browse" doesn't make sense in win32, hide it. if (device_name_browse_button) { device_name_browse_button->hide(); diff --git a/gsmartcontrol/src/gsc_preferences_window.cpp b/gsmartcontrol/src/gsc_preferences_window.cpp index f3b0d3a..3f24827 100644 --- a/gsmartcontrol/src/gsc_preferences_window.cpp +++ b/gsmartcontrol/src/gsc_preferences_window.cpp @@ -240,20 +240,39 @@ GscPreferencesWindow::GscPreferencesWindow(BaseObjectType* gtkcobj, const app_ui Gtk::Button* device_options_remove_device_button = 0; APP_UI_RES_AUTO_CONNECT(device_options_remove_device_button, clicked); + Gtk::Entry* device_options_device_entry = 0; APP_UI_RES_AUTO_CONNECT(device_options_device_entry, changed); - Glib::ustring device_options_tooltip = "Device name, e.g. %s."; -#ifdef _WIN32 - device_options_tooltip = hz::string_sprintf(device_options_tooltip.c_str(), "\"pd0\" for the first physical drive"); -#else - device_options_tooltip = hz::string_sprintf(device_options_tooltip.c_str(), "\"/dev/sda\""); + + Glib::ustring device_options_tooltip = "Device name"; +#if defined CONFIG_KERNEL_FAMILY_WINDOWS + device_options_tooltip = "Device name (for example, use \"pd0\" for the first physical drive)"; +#elif defined CONFIG_KERNEL_LINUX + device_options_tooltip = "Device name (for example, /dev/sda or /dev/twa0)"; #endif - Gtk::Label* device_options_device_label = lookup_widget("device_options_device_label"); - app_gtkmm_set_widget_tooltip(*device_options_device_label, device_options_tooltip); + if (Gtk::Label* device_options_device_label = lookup_widget("device_options_device_label")) { + app_gtkmm_set_widget_tooltip(*device_options_device_label, device_options_tooltip); + } + if (device_options_device_entry) { + app_gtkmm_set_widget_tooltip(*device_options_device_entry, device_options_tooltip); + } + Gtk::Entry* device_options_type_entry = 0; APP_UI_RES_AUTO_CONNECT(device_options_type_entry, changed); + Glib::ustring device_type_tooltip = "Match only this type of device (as specified to -d smartctl parameter)"; +#if defined CONFIG_KERNEL_LINUX + device_type_tooltip = "Match only this type of device (as specified to -d smartctl parameter). Leave empty for all types. This can be used to specify a drive behind a RAID device, e.g. \"3ware,2\"."; +#endif + if (Gtk::Label* device_options_type_label = lookup_widget("device_options_type_label")) { + app_gtkmm_set_widget_tooltip(*device_options_type_label, device_type_tooltip); + } + if (device_options_type_entry) { + app_gtkmm_set_widget_tooltip(*device_options_type_entry, device_type_tooltip); + } + + Gtk::Entry* device_options_parameter_entry = 0; APP_UI_RES_AUTO_CONNECT(device_options_parameter_entry, changed); diff --git a/gsmartcontrol/src/res/gsc_add_device_window.glade b/gsmartcontrol/src/res/gsc_add_device_window.glade index 930fbda..7489b8f 100644 --- a/gsmartcontrol/src/res/gsc_add_device_window.glade +++ b/gsmartcontrol/src/res/gsc_add_device_window.glade @@ -19,44 +19,31 @@ 12 6 - + True - True - ● + + + True + True + ● + + 1 2 - 2 - 3 + 1 + 2 - + True - Additional smartctl parameters - Additional smartctl parameters 0 - Smartctl parameters: - - - 2 - 3 - GTK_FILL - - - - - True - Smartctl -d option, e.g. 3ware,2 for a third drive behind a 3ware RAID controller - Smartctl -d option, e.g. 3ware,2 for a third drive behind a 3ware RAID controller - 0 - Device _type: + Device _name: True - 1 - 2 GTK_FILL @@ -93,32 +80,45 @@ - + True 0 - Device _name: + Device _type: True + 1 + 2 GTK_FILL - + True - - - True - True - ● - - + Additional smartctl parameters + Additional smartctl parameters + 0 + Smartctl parameters: + + + 2 + 3 + GTK_FILL + + + + + True + True + Additional smartctl parameters + Additional smartctl parameters + ● 1 2 - 1 - 2 + 2 + 3 diff --git a/gsmartcontrol/src/res/gsc_preferences_window.glade b/gsmartcontrol/src/res/gsc_preferences_window.glade index 0d8731e..accc173 100644 --- a/gsmartcontrol/src/res/gsc_preferences_window.glade +++ b/gsmartcontrol/src/res/gsc_preferences_window.glade @@ -171,8 +171,8 @@ True - Global parameters for smartctl. These parameters will be used every time the progam invokes smartctl. - Global parameters for smartctl. These parameters will be used every time the progam invokes smartctl. + Global parameters for smartctl. These parameters will be used every time the progam invokes smartctl. Must be shell-escaped. + Global parameters for smartctl. These parameters will be used every time the progam invokes smartctl. Must be shell-escaped. Smartctl parameters: True @@ -185,8 +185,8 @@ True - A path to smartctl binary. If the path is not absolute, the binary will be looked for in user's $PATH. - A path to smartctl binary. If the path is not absolute, the binary will be looked for in user's $PATH. + A path to smartctl binary. If the path is not absolute, the binary will be looked for in user's PATH. + A path to smartctl binary. If the path is not absolute, the binary will be looked for in user's PATH. 1 S_martctl binary: True @@ -399,6 +399,8 @@ True True + Smartctl parameters (for example, "-T permissive" or "-d usbsunplus") + Smartctl parameters (for example, "-T permissive" or "-d usbsunplus") 1 @@ -410,8 +412,8 @@ True - Smartctl parameters for this device. For example, to use older smartctl versions with libata devices, use "-d ata". - Smartctl parameters for this device. For example, to use older smartctl versions with libata devices, use "-d ata". + Smartctl parameters (for example, "-T permissive" or "-d usbsunplus") + Smartctl parameters (for example, "-T permissive" or "-d usbsunplus") 1 _Parameters: True @@ -446,10 +448,8 @@ - + True - Match only this type of device (as specified to -d smartctl parameter). Leave empty for all types. This can be used to specify a drive behind a RAID device, e.g. 3ware,2. - Match only this type of device (as specified to -d smartctl parameter). Leave empty for all types. This can be used to specify a drive behind a RAID device, e.g. 3ware,2. 1 _Type: True