From da403b28c91491f33e308b3338e7cd227695abb8 Mon Sep 17 00:00:00 2001 From: Alexander Shaduri Date: Tue, 29 Aug 2017 15:13:13 +0000 Subject: [PATCH] Require smartmontools version 5.43 at runtime. --- gsmartcontrol/TODO | 15 ++++----------- gsmartcontrol/debian.dist/control | 3 +-- gsmartcontrol/gsmartcontrol.spec.in | 4 ++-- gsmartcontrol/src/applib/smartctl_parser.cpp | 12 +++++++----- gsmartcontrol/src/applib/smartctl_parser.h | 2 +- gsmartcontrol/src/gsc_main_window.cpp | 12 ++++++++++++ gsmartcontrol/src/hz/scoped_ptr.h | 7 +++++++ 7 files changed, 34 insertions(+), 21 deletions(-) diff --git a/gsmartcontrol/TODO b/gsmartcontrol/TODO index e1cff35..d876abc 100644 --- a/gsmartcontrol/TODO +++ b/gsmartcontrol/TODO @@ -42,6 +42,8 @@ Add ability (through ctrl-C?) to copy individual rows from attributes page, Require smartctl 5.43 (for --get=all) + Update specs / dsc. + Detect on startup. Add menu item - "update drive database" (not sure about linux, should @@ -56,26 +58,17 @@ Testing: -48-bit ATA command support: +Add ability to load --xall output: --xall for ATA: --health --info --get=all --capabilities --attributes --format=brief -l xerror,error -l xselftest,selftest -l selective -l directory -l scttemp -l scterc -l devstat -l sataphy --xall for SCSI: --health --info --attributes -l error -l selftest -l background -l sasphy - use --format=brief, which affects --attributes by decoding flags. - Show flag descriptions in tooltips, for each attribute. - There are no TYPE or UPDATED columns in this mode, decode it from flags. - Updated offline: -, Always: O. - Pre-failure: P, old age: -. - Maybe get rid of Type and Updated columns and print only decoded flags? - Add a tab for -l devstat - it shows interesting statistics. Some of this stuff is better than attributes, maybe show them before attributes. Also needs the warnings and descriptions. - Add ability to load --xall output. - Document RAID support. @@ -122,8 +115,8 @@ Add a button (with dropdown) to Info window, to run -l sataphy (advanced) -l directory (very advanced) -l scttemp (rarely supported and difficult to parse) - Just show the output in a text window. Maybe add -l selective here (and remove it from GUI). + Just show the output in a text window. "Put this all in Error Log", raname to Logs. Make it a dropdown combo and "Retrieve" button, showing the output where selective is now. diff --git a/gsmartcontrol/debian.dist/control b/gsmartcontrol/debian.dist/control index cf32d92..7467e2a 100644 --- a/gsmartcontrol/debian.dist/control +++ b/gsmartcontrol/debian.dist/control @@ -9,8 +9,7 @@ Standards-Version: 3.7.3 Package: gsmartcontrol Architecture: any -#Depends: ${shlibs:Depends}, ${misc:Depends}, smartmontools, menu -Depends: ${shlibs:Depends}, smartmontools, menu +Depends: ${shlibs:Depends}, smartmontools (>= 5.43), menu Description: Hard disk drive and SSD health inspection tool GSmartControl is a graphical user interface for smartctl (from smartmontools package), which is a tool for querying and controlling SMART diff --git a/gsmartcontrol/gsmartcontrol.spec.in b/gsmartcontrol/gsmartcontrol.spec.in index c2bd07d..0842588 100644 --- a/gsmartcontrol/gsmartcontrol.spec.in +++ b/gsmartcontrol/gsmartcontrol.spec.in @@ -24,7 +24,7 @@ Group: Hardware/Other # SUSE / OpenSUSE. SLES also defines the correct suse_version. %if 0%{?suse_version} -Requires: smartmontools, polkit, bash +Requires: smartmontools >= 5.43, polkit, bash BuildRequires: gcc-c++, libstdc++-devel, pcre-devel, gtkmm3-devel >= 3.4.0 BuildRequires: update-desktop-files BuildRequires: fdupes @@ -35,7 +35,7 @@ BuildRequires: fdupes # Fedora, CentOS, RHEL %if 0%{?fedora_version} || 0%{?rhel_version} || 0%{?centos_version} -Requires: smartmontools, polkit, bash +Requires: smartmontools >= 5.43, polkit, bash BuildRequires: gcc-c++, pcre-devel, gtkmm30-devel >= 3.4.0 %endif diff --git a/gsmartcontrol/src/applib/smartctl_parser.cpp b/gsmartcontrol/src/applib/smartctl_parser.cpp index 8296a50..9ed49ed 100644 --- a/gsmartcontrol/src/applib/smartctl_parser.cpp +++ b/gsmartcontrol/src/applib/smartctl_parser.cpp @@ -190,7 +190,7 @@ bool SmartctlParser::parse_full(const std::string& full, StorageAttribute::DiskT } } - if (!check_version(version, version_full)) { + if (!check_parsed_version(version, version_full)) { set_error_msg("Incompatible smartctl version."); debug_out_warn("app", DBG_FUNC_MSG << "Incompatible smartctl version. Returning.\n"); return false; @@ -238,7 +238,9 @@ bool SmartctlParser::parse_full(const std::string& full, StorageAttribute::DiskT // returns false on failure. Non-unix newlines in s are ok. bool SmartctlParser::parse_version(const std::string& s, std::string& version, std::string& version_full) { - // e.g. "smartctl version 5.37" or "smartctl 5.39" + // e.g. + // "smartctl version 5.37" + // "smartctl 5.39" // "smartctl 5.39 2009-06-03 20:10" (cvs versions) // "smartctl 5.39 2009-08-08 r2873" (svn versions) if (!app_pcre_match("/^smartctl (?:version )?(([0-9][^ \\t\\n\\r]+)(?: [0-9 r:-]+)?)/mi", s, &version_full, &version)) { @@ -254,18 +256,18 @@ bool SmartctlParser::parse_version(const std::string& s, std::string& version, s // check that the version of smartctl output can be parsed with this parser. -bool SmartctlParser::check_version(const std::string& version_str, const std::string& version_full_str) +bool SmartctlParser::check_parsed_version(const std::string& version_str, const std::string& version_full_str) { // tested with 5.1-xx versions (1 - 18), and 5.[20 - 38]. // note: 5.1-11 (maybe others too) with scsi disk gives non-parsable output (why?). // 5.0-24, 5.0-36, 5.0-49 tested with data only, from smartmontool site. // can't fully test 5.0-xx, they don't support sata and I have only sata. - double minimum_version = 5.0; + const double minimum_req_version = 5.0; double version = 0; if (hz::string_is_numeric(version_str, version, false)) { - if (version >= minimum_version) + if (version >= minimum_req_version) return true; } diff --git a/gsmartcontrol/src/applib/smartctl_parser.h b/gsmartcontrol/src/applib/smartctl_parser.h index 2c30955..01a8cc7 100644 --- a/gsmartcontrol/src/applib/smartctl_parser.h +++ b/gsmartcontrol/src/applib/smartctl_parser.h @@ -43,7 +43,7 @@ class SmartctlParser { /// Check that the version of smartctl output can be parsed with this parser. - static bool check_version(const std::string& version_str, const std::string& version_full_str); + static bool check_parsed_version(const std::string& version_str, const std::string& version_full_str); /// Convert e.g. "1,000,204,886,016 bytes" to 1.00 TiB [931.51 GB, 1000204886016 bytes] diff --git a/gsmartcontrol/src/gsc_main_window.cpp b/gsmartcontrol/src/gsc_main_window.cpp index e86184d..6c6bddf 100644 --- a/gsmartcontrol/src/gsc_main_window.cpp +++ b/gsmartcontrol/src/gsc_main_window.cpp @@ -129,6 +129,18 @@ GscMainWindow::GscMainWindow(BaseObjectType* gtkcobj, const app_ui_res_ref_t& re break; } + { + // We require this version at runtime to support --get=all. + const double minimum_req_version = 5.43; + double version_double = 0; + if (hz::string_is_numeric(version, version_double, false)) { + if (version_double < minimum_req_version) { + error_msg = "Smartctl version " + version + " found, " + hz::number_to_string(minimum_req_version) + " required."; + break; + } + } + } + } while (false); bool smartctl_valid = error_msg.empty(); diff --git a/gsmartcontrol/src/hz/scoped_ptr.h b/gsmartcontrol/src/hz/scoped_ptr.h index 9b08333..73c5437 100644 --- a/gsmartcontrol/src/hz/scoped_ptr.h +++ b/gsmartcontrol/src/hz/scoped_ptr.h @@ -125,7 +125,14 @@ class scoped_ptr { // non-copyable cleaner->cleanup(ptr); delete cleaner; } else { +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdelete-incomplete" +#endif delete ptr; +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif } }