From 1870ba89d3a2c420bf271debfbf12634b2e14026 Mon Sep 17 00:00:00 2001 From: chrfranke <chrfranke@4ea69e1a-61f1-4043-bf83-b5c94c648137> Date: Sat, 6 Sep 2008 20:08:35 +0000 Subject: [PATCH] Remove dependencies ataprint.cpp and scsiprint.cpp from smartd. git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@2637 4ea69e1a-61f1-4043-bf83-b5c94c648137 --- sm5/CHANGELOG | 6 +- sm5/Makefile.am | 6 +- sm5/atacmds.cpp | 173 +++++++++++++++++++++++++++++- sm5/atacmds.h | 8 +- sm5/ataprint.cpp | 188 +-------------------------------- sm5/ataprint.h | 11 +- sm5/knowndrives.cpp | 7 +- sm5/os_win32/smartd_vc8.vcproj | 32 ++++++ sm5/scsiata.cpp | 4 +- sm5/smartctl.cpp | 19 +++- sm5/smartd.cpp | 15 +-- 11 files changed, 248 insertions(+), 221 deletions(-) diff --git a/sm5/CHANGELOG b/sm5/CHANGELOG index 768b61e5d..f7b0fa857 100644 --- a/sm5/CHANGELOG +++ b/sm5/CHANGELOG @@ -1,6 +1,6 @@ CHANGELOG for smartmontools -$Id: CHANGELOG,v 1.727 2008/09/06 14:39:43 chrfranke Exp $ +$Id: CHANGELOG,v 1.728 2008/09/06 20:08:35 chrfranke Exp $ The most recent version of this file is: http://smartmontools.cvs.sourceforge.net/smartmontools/sm5/CHANGELOG?view=markup @@ -39,6 +39,10 @@ NOTES FOR FUTURE RELEASES: see TODO file. <DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE> + [CF] Remove dependencies ataprint.cpp and scsiprint.cpp from smartd. + Move common ATA functions from ataprint.cpp to atacmds.cpp. + Module scsiprint.cpp was apparently never used in smartd. + [CF] Move smartd local declarations from smartd.h and utility.h to smartd.cpp. Remove smartd.h. diff --git a/sm5/Makefile.am b/sm5/Makefile.am index 9538c07fc..3f8d3d917 100644 --- a/sm5/Makefile.am +++ b/sm5/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with automake to produce Makefile.in # -# $Id: Makefile.am,v 1.89 2008/09/06 14:37:17 chrfranke Exp $ +# $Id: Makefile.am,v 1.90 2008/09/06 20:08:35 chrfranke Exp $ # @SET_MAKE@ @@ -21,8 +21,6 @@ smartd_SOURCES = smartd.cpp \ atacmdnames.h \ atacmds.cpp \ atacmds.h \ - ataprint.cpp \ - ataprint.h \ dev_ata_cmd_set.cpp \ dev_ata_cmd_set.h \ dev_interface.cpp \ @@ -36,8 +34,6 @@ smartd_SOURCES = smartd.cpp \ scsicmds.h \ scsiata.cpp \ scsiata.h \ - scsiprint.cpp \ - scsiprint.h \ utility.cpp \ utility.h diff --git a/sm5/atacmds.cpp b/sm5/atacmds.cpp index 898bce408..0b84ca6e9 100644 --- a/sm5/atacmds.cpp +++ b/sm5/atacmds.cpp @@ -39,7 +39,7 @@ #include <algorithm> // std::sort -const char *atacmds_c_cvsid="$Id: atacmds.cpp,v 1.205 2008/09/05 17:40:39 chrfranke Exp $" +const char *atacmds_c_cvsid="$Id: atacmds.cpp,v 1.206 2008/09/06 20:08:35 chrfranke Exp $" ATACMDS_H_CVSID CONFIG_H_CVSID EXTERN_H_CVSID INT64_H_CVSID SCSIATA_H_CVSID UTILITY_H_CVSID; // for passing global control variables @@ -686,6 +686,63 @@ unsigned char checksum(const unsigned char *buffer) return sum; } +// Copies n bytes (or n-1 if n is odd) from in to out, but swaps adjacents +// bytes. +static void swapbytes(char * out, const char * in, size_t n) +{ + for (size_t i = 0; i < n; i += 2) { + out[i] = in[i+1]; + out[i+1] = in[i]; + } +} + +// Copies in to out, but removes leading and trailing whitespace. +static void trim(char * out, const char * in) +{ + // Find the first non-space character (maybe none). + int first = -1; + int i; + for (i = 0; in[i]; i++) + if (!isspace((int)in[i])) { + first = i; + break; + } + + if (first == -1) { + // There are no non-space characters. + out[0] = '\0'; + return; + } + + // Find the last non-space character. + for (i = strlen(in)-1; i >= first && isspace((int)in[i]); i--) + ; + int last = i; + + strncpy(out, in+first, last-first+1); + out[last-first+1] = '\0'; +} + +// Convenience function for formatting strings from ata_identify_device +void format_ata_string(char * out, const char * in, int n) +{ + bool must_swap = !con->fixswappedid; +#ifdef __NetBSD__ + /* NetBSD kernel delivers IDENTIFY data in host byte order (but all else is LE) */ + if (isbigendian()) + must_swap = !must_swap; +#endif + + char tmp[65]; + n = n > 64 ? 64 : n; + if (!must_swap) + strncpy(tmp, in, n); + else + swapbytes(tmp, in, n); + tmp[n] = '\0'; + trim(out, tmp); +} + // returns -1 if command fails or the device is in Sleep mode, else // value of Sector Count register. Sector Count result values: // 00h device is in Standby mode. @@ -2259,6 +2316,120 @@ int ataSetSCTTempInterval(ata_device * device, unsigned interval, bool persisten return 0; } +// Print Smart self-test log, used by smartctl and smartd. +// return value is: +// bottom 8 bits: number of entries found where self-test showed an error +// remaining bits: if nonzero, power on hours of last self-test where error was found +int ataPrintSmartSelfTestlog(const ata_smart_selftestlog * data, bool allentries) +{ + if (allentries) + pout("SMART Self-test log structure revision number %d\n",(int)data->revnumber); + if ((data->revnumber!=0x0001) && allentries && con->fixfirmwarebug != FIX_SAMSUNG) + pout("Warning: ATA Specification requires self-test log structure revision number = 1\n"); + if (data->mostrecenttest==0){ + if (allentries) + pout("No self-tests have been logged. [To run self-tests, use: smartctl -t]\n\n"); + return 0; + } + + bool noheaderprinted = true; + int retval=0, hours=0, testno=0; + + // print log + for (int i = 20; i >= 0; i--) { + // log is a circular buffer + int j = (i+data->mostrecenttest)%21; + const ata_smart_selftestlog_struct * log = data->selftest_struct+j; + + if (nonempty(log, sizeof(*log))) { + // count entry based on non-empty structures -- needed for + // Seagate only -- other vendors don't have blank entries 'in + // the middle' + testno++; + + // test name + const char * msgtest; + switch(log->selftestnumber){ + case 0: msgtest="Offline "; break; + case 1: msgtest="Short offline "; break; + case 2: msgtest="Extended offline "; break; + case 3: msgtest="Conveyance offline "; break; + case 4: msgtest="Selective offline "; break; + case 127: msgtest="Abort offline test "; break; + case 129: msgtest="Short captive "; break; + case 130: msgtest="Extended captive "; break; + case 131: msgtest="Conveyance captive "; break; + case 132: msgtest="Selective captive "; break; + default: + if ( log->selftestnumber>=192 || + (log->selftestnumber>= 64 && log->selftestnumber<=126)) + msgtest="Vendor offline "; + else + msgtest="Reserved offline "; + } + + // test status + bool errorfound = false; + const char * msgstat; + switch((log->selfteststatus)>>4){ + case 0:msgstat="Completed without error "; break; + case 1:msgstat="Aborted by host "; break; + case 2:msgstat="Interrupted (host reset) "; break; + case 3:msgstat="Fatal or unknown error "; errorfound=true; break; + case 4:msgstat="Completed: unknown failure "; errorfound=true; break; + case 5:msgstat="Completed: electrical failure"; errorfound=true; break; + case 6:msgstat="Completed: servo/seek failure"; errorfound=true; break; + case 7:msgstat="Completed: read failure "; errorfound=true; break; + case 8:msgstat="Completed: handling damage?? "; errorfound=true; break; + case 15:msgstat="Self-test routine in progress"; break; + default:msgstat="Unknown/reserved test status "; + } + + char percent[64]; + retval+=errorfound; + sprintf(percent,"%1d0%%",(log->selfteststatus)&0xf); + + // T13/1321D revision 1c: (Data structure Rev #1) + + //The failing LBA shall be the LBA of the uncorrectable sector + //that caused the test to fail. If the device encountered more + //than one uncorrectable sector during the test, this field + //shall indicate the LBA of the first uncorrectable sector + //encountered. If the test passed or the test failed for some + //reason other than an uncorrectable sector, the value of this + //field is undefined. + + // This is true in ALL ATA-5 specs + + char firstlba[64]; + if (!errorfound || log->lbafirstfailure==0xffffffff || log->lbafirstfailure==0x00000000) + sprintf(firstlba,"%s","-"); + else + sprintf(firstlba,"%u",log->lbafirstfailure); + + // print out a header if needed + if (noheaderprinted && (allentries || errorfound)){ + pout("Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error\n"); + noheaderprinted = false; + } + + // print out an entry, either if we are printing all entries OR + // if an error was found + if (allentries || errorfound) + pout("#%2d %s %s %s %8d %s\n", testno, msgtest, msgstat, percent, (int)log->timestamp, firstlba); + + // keep track of time of most recent error + if (errorfound && !hours) + hours=log->timestamp; + } + } + if (!allentries && retval) + pout("\n"); + + hours = hours << 8; + return (retval | hours); +} + ///////////////////////////////////////////////////////////////////////////// // Pseudo-device to parse "smartctl -r ataioctl,2 ..." output and simulate diff --git a/sm5/atacmds.h b/sm5/atacmds.h index 097300409..77f722f5b 100644 --- a/sm5/atacmds.h +++ b/sm5/atacmds.h @@ -25,7 +25,7 @@ #ifndef ATACMDS_H_ #define ATACMDS_H_ -#define ATACMDS_H_CVSID "$Id: atacmds.h,v 1.99 2008/09/05 17:40:39 chrfranke Exp $\n" +#define ATACMDS_H_CVSID "$Id: atacmds.h,v 1.100 2008/09/06 20:08:35 chrfranke Exp $\n" #include "dev_interface.h" // ata_device @@ -644,6 +644,12 @@ std::string create_vendor_attribute_arg_list(); // This function is exported to give low-level capability int smartcommandhandler(ata_device * device, smart_command_set command, int select, char *data); +// Print Smart self-test log, used by smartctl and smartd. +int ataPrintSmartSelfTestlog(const ata_smart_selftestlog * data, bool allentries); + +// Convenience function for formatting strings from ata_identify_device. +void format_ata_string(char * out, const char * in, int n); + // Utility routines. unsigned char checksum(const unsigned char * buffer); diff --git a/sm5/ataprint.cpp b/sm5/ataprint.cpp index f13572821..c4f52614c 100644 --- a/sm5/ataprint.cpp +++ b/sm5/ataprint.cpp @@ -42,69 +42,12 @@ #include "utility.h" #include "knowndrives.h" -const char *ataprint_c_cvsid="$Id: ataprint.cpp,v 1.197 2008/09/05 21:11:50 chrfranke Exp $" +const char *ataprint_c_cvsid="$Id: ataprint.cpp,v 1.198 2008/09/06 20:08:35 chrfranke Exp $" ATACMDNAMES_H_CVSID ATACMDS_H_CVSID ATAPRINT_H_CVSID CONFIG_H_CVSID EXTERN_H_CVSID INT64_H_CVSID KNOWNDRIVES_H_CVSID SMARTCTL_H_CVSID UTILITY_H_CVSID; // for passing global control variables extern smartmonctrl *con; -// Copies n bytes (or n-1 if n is odd) from in to out, but swaps adjacents -// bytes. -static void swapbytes(char * out, const char * in, size_t n) -{ - for (size_t i = 0; i < n; i += 2) { - out[i] = in[i+1]; - out[i+1] = in[i]; - } -} - -// Copies in to out, but removes leading and trailing whitespace. -static void trim(char * out, const char * in) -{ - // Find the first non-space character (maybe none). - int first = -1; - int i; - for (i = 0; in[i]; i++) - if (!isspace((int)in[i])) { - first = i; - break; - } - - if (first == -1) { - // There are no non-space characters. - out[0] = '\0'; - return; - } - - // Find the last non-space character. - for (i = strlen(in)-1; i >= first && isspace((int)in[i]); i--) - ; - int last = i; - - strncpy(out, in+first, last-first+1); - out[last-first+1] = '\0'; -} - -// Convenience function for formatting strings from ata_identify_device -void format_ata_string(char *out, const char *in, int n) -{ - bool must_swap = !con->fixswappedid; -#ifdef __NetBSD__ - /* NetBSD kernel delivers IDENTIFY data in host byte order (but all else is LE) */ - if (isbigendian()) - must_swap = !must_swap; -#endif - - char tmp[65]; - n = n > 64 ? 64 : n; - if (!must_swap) - strncpy(tmp, in, n); - else - swapbytes(tmp, in, n); - tmp[n] = '\0'; - trim(out, tmp); -} - static const char * infofound(const char *output) { return (*output ? output : "[No Information Found]"); } @@ -1371,119 +1314,6 @@ static void ataPrintSelectiveSelfTestLog(const ata_selective_self_test_log * log return; } -// return value is: -// bottom 8 bits: number of entries found where self-test showed an error -// remaining bits: if nonzero, power on hours of last self-test where error was found -int ataPrintSmartSelfTestlog(const ata_smart_selftestlog * data, int allentries) -{ - if (allentries) - pout("SMART Self-test log structure revision number %d\n",(int)data->revnumber); - if ((data->revnumber!=0x0001) && allentries && con->fixfirmwarebug != FIX_SAMSUNG) - pout("Warning: ATA Specification requires self-test log structure revision number = 1\n"); - if (data->mostrecenttest==0){ - if (allentries) - pout("No self-tests have been logged. [To run self-tests, use: smartctl -t]\n\n"); - return 0; - } - - int noheaderprinted=1; - int retval=0, hours=0, testno=0; - - // print log - for (int i = 20;i >= 0; i--){ - // log is a circular buffer - int j = (i+data->mostrecenttest)%21; - const ata_smart_selftestlog_struct * log = data->selftest_struct+j; - - if (nonempty((unsigned char*)log,sizeof(*log))){ - // count entry based on non-empty structures -- needed for - // Seagate only -- other vendors don't have blank entries 'in - // the middle' - testno++; - - // test name - const char * msgtest; - switch(log->selftestnumber){ - case 0: msgtest="Offline "; break; - case 1: msgtest="Short offline "; break; - case 2: msgtest="Extended offline "; break; - case 3: msgtest="Conveyance offline "; break; - case 4: msgtest="Selective offline "; break; - case 127: msgtest="Abort offline test "; break; - case 129: msgtest="Short captive "; break; - case 130: msgtest="Extended captive "; break; - case 131: msgtest="Conveyance captive "; break; - case 132: msgtest="Selective captive "; break; - default: - if ( log->selftestnumber>=192 || - (log->selftestnumber>= 64 && log->selftestnumber<=126)) - msgtest="Vendor offline "; - else - msgtest="Reserved offline "; - } - - // test status - int errorfound = 0; - const char * msgstat; - switch((log->selfteststatus)>>4){ - case 0:msgstat="Completed without error "; break; - case 1:msgstat="Aborted by host "; break; - case 2:msgstat="Interrupted (host reset) "; break; - case 3:msgstat="Fatal or unknown error "; errorfound=1; break; - case 4:msgstat="Completed: unknown failure "; errorfound=1; break; - case 5:msgstat="Completed: electrical failure"; errorfound=1; break; - case 6:msgstat="Completed: servo/seek failure"; errorfound=1; break; - case 7:msgstat="Completed: read failure "; errorfound=1; break; - case 8:msgstat="Completed: handling damage?? "; errorfound=1; break; - case 15:msgstat="Self-test routine in progress"; break; - default:msgstat="Unknown/reserved test status "; - } - - char percent[64]; - retval+=errorfound; - sprintf(percent,"%1d0%%",(log->selfteststatus)&0xf); - - // T13/1321D revision 1c: (Data structure Rev #1) - - //The failing LBA shall be the LBA of the uncorrectable sector - //that caused the test to fail. If the device encountered more - //than one uncorrectable sector during the test, this field - //shall indicate the LBA of the first uncorrectable sector - //encountered. If the test passed or the test failed for some - //reason other than an uncorrectable sector, the value of this - //field is undefined. - - // This is true in ALL ATA-5 specs - - char firstlba[64]; - if (!errorfound || log->lbafirstfailure==0xffffffff || log->lbafirstfailure==0x00000000) - sprintf(firstlba,"%s","-"); - else - sprintf(firstlba,"%u",log->lbafirstfailure); - - // print out a header if needed - if (noheaderprinted && (allentries || errorfound)){ - pout("Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error\n"); - noheaderprinted=0; - } - - // print out an entry, either if we are printing all entries OR - // if an error was found - if (allentries || errorfound) - pout("#%2d %s %s %s %8d %s\n", testno, msgtest, msgstat, percent, (int)log->timestamp, firstlba); - - // keep track of time of most recent error - if (errorfound && !hours) - hours=log->timestamp; - } - } - if (!allentries && retval) - pout("\n"); - - hours = hours << 8; - return (retval | hours); -} - static void ataPseudoCheckSmart(const ata_smart_values * data, const ata_smart_thresholds_pvt * thresholds) { @@ -1668,22 +1498,6 @@ void failuretest(int type, int returnvalue){ EXIT(returnvalue|FAILCMD); } -// Used to warn users about invalid checksums. Action to be taken may be -// altered by the user. -void checksumwarning(const char *string){ - // user has asked us to ignore checksum errors - if (con->checksumignore) - return; - - pout("Warning! %s error: invalid SMART checksum.\n",string); - - // user has asked us to fail on checksum errors - if (con->checksumfail) - EXIT(FAILSMART); - - return; -} - // Initialize to zero just in case some SMART routines don't work static ata_identify_device drive; static ata_smart_values smartval; diff --git a/sm5/ataprint.h b/sm5/ataprint.h index 565a8ec56..912947726 100644 --- a/sm5/ataprint.h +++ b/sm5/ataprint.h @@ -25,19 +25,10 @@ #ifndef ATAPRINT_H_ #define ATAPRINT_H_ -#define ATAPRINT_H_CVSID "$Id: ataprint.h,v 1.36 2008/09/05 17:40:39 chrfranke Exp $\n" +#define ATAPRINT_H_CVSID "$Id: ataprint.h,v 1.37 2008/09/06 20:08:35 chrfranke Exp $\n" -#include <stdio.h> -#include <stdlib.h> #include <vector> -// returns number of entries that had logged errors -int ataPrintSmartSelfTestlog(const ata_smart_selftestlog * data, int allentries); - -// Convenience function for formatting strings from ata_identify_device. -void format_ata_string(char *out, const char *in, int n); - - // Request to dump a GP or SMART log struct ata_log_request { diff --git a/sm5/knowndrives.cpp b/sm5/knowndrives.cpp index 9c1cc1dce..20737fbb3 100644 --- a/sm5/knowndrives.cpp +++ b/sm5/knowndrives.cpp @@ -21,13 +21,12 @@ #include "int64.h" #include <stdio.h> #include "atacmds.h" -#include "ataprint.h" #include "extern.h" #include "knowndrives.h" -#include "utility.h" // includes <regex.h> +#include "utility.h" -const char *knowndrives_c_cvsid="$Id: knowndrives.cpp,v 1.173 2008/08/30 16:46:17 chrfranke Exp $" -ATACMDS_H_CVSID ATAPRINT_H_CVSID CONFIG_H_CVSID EXTERN_H_CVSID INT64_H_CVSID KNOWNDRIVES_H_CVSID UTILITY_H_CVSID; +const char *knowndrives_c_cvsid="$Id: knowndrives.cpp,v 1.174 2008/09/06 20:08:35 chrfranke Exp $" +ATACMDS_H_CVSID CONFIG_H_CVSID EXTERN_H_CVSID INT64_H_CVSID KNOWNDRIVES_H_CVSID UTILITY_H_CVSID; #define MODEL_STRING_LENGTH 40 #define FIRMWARE_STRING_LENGTH 8 diff --git a/sm5/os_win32/smartd_vc8.vcproj b/sm5/os_win32/smartd_vc8.vcproj index 5ccc98f40..6c2ea5ff5 100644 --- a/sm5/os_win32/smartd_vc8.vcproj +++ b/sm5/os_win32/smartd_vc8.vcproj @@ -312,10 +312,26 @@ <File RelativePath="..\ataprint.cpp" > + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="true" + > + <Tool + Name="VCCLCompilerTool" + /> + </FileConfiguration> </File> <File RelativePath="..\ataprint.h" > + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="true" + > + <Tool + Name="VCCustomBuildTool" + /> + </FileConfiguration> </File> <File RelativePath="..\AUTHORS" @@ -888,10 +904,26 @@ <File RelativePath="..\scsiprint.cpp" > + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="true" + > + <Tool + Name="VCCLCompilerTool" + /> + </FileConfiguration> </File> <File RelativePath="..\scsiprint.h" > + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="true" + > + <Tool + Name="VCCustomBuildTool" + /> + </FileConfiguration> </File> <File RelativePath="..\smartctl.8.in" diff --git a/sm5/scsiata.cpp b/sm5/scsiata.cpp index 34f74d826..a6c6bb739 100644 --- a/sm5/scsiata.cpp +++ b/sm5/scsiata.cpp @@ -44,13 +44,13 @@ #include "extern.h" #include "scsicmds.h" #include "scsiata.h" -#include "ataprint.h" // ataReadHDIdentity() +#include "atacmds.h" // ataReadHDIdentity() #include "utility.h" #include "dev_interface.h" #include "dev_ata_cmd_set.h" // ata_device_with_command_set #include "dev_tunnelled.h" // tunnelled_device<> -const char *scsiata_c_cvsid="$Id: scsiata.cpp,v 1.16 2008/08/23 17:07:17 chrfranke Exp $" +const char *scsiata_c_cvsid="$Id: scsiata.cpp,v 1.17 2008/09/06 20:08:35 chrfranke Exp $" CONFIG_H_CVSID EXTERN_H_CVSID INT64_H_CVSID SCSICMDS_H_CVSID SCSIATA_H_CVSID UTILITY_H_CVSID; /* for passing global control variables */ diff --git a/sm5/smartctl.cpp b/sm5/smartctl.cpp index f64f554de..b142a314d 100644 --- a/sm5/smartctl.cpp +++ b/sm5/smartctl.cpp @@ -64,16 +64,13 @@ extern const char *os_solaris_ata_s_cvsid; extern const char *cciss_c_cvsid; #endif extern const char *atacmdnames_c_cvsid, *atacmds_c_cvsid, *ataprint_c_cvsid, *knowndrives_c_cvsid, *os_XXXX_c_cvsid, *scsicmds_c_cvsid, *scsiprint_c_cvsid, *utility_c_cvsid; -const char* smartctl_c_cvsid="$Id: smartctl.cpp,v 1.188 2008/08/29 21:14:29 chrfranke Exp $" +const char* smartctl_c_cvsid="$Id: smartctl.cpp,v 1.189 2008/09/06 20:08:35 chrfranke Exp $" ATACMDS_H_CVSID ATAPRINT_H_CVSID CONFIG_H_CVSID EXTERN_H_CVSID INT64_H_CVSID KNOWNDRIVES_H_CVSID SCSICMDS_H_CVSID SCSIPRINT_H_CVSID SMARTCTL_H_CVSID UTILITY_H_CVSID; // This is a block containing all the "control variables". We declare // this globally in this file, and externally in other files. smartmonctrl *con=NULL; -// Track memory use -extern int64_t bytes; - void printslogan(){ pout("%s\n", format_version_info("smartctl")); } @@ -856,6 +853,20 @@ void PrintOut(int priority, const char *fmt, ...) { return; } +// Used to warn users about invalid checksums. Called from atacmds.cpp. +// Action to be taken may be altered by the user. +void checksumwarning(const char * string) +{ + // user has asked us to ignore checksum errors + if (con->checksumignore) + return; + + pout("Warning! %s error: invalid SMART checksum.\n", string); + + // user has asked us to fail on checksum errors + if (con->checksumfail) + EXIT(FAILSMART); +} // Main program without exception handling int main_worker(int argc, char **argv) diff --git a/sm5/smartd.cpp b/sm5/smartd.cpp index 2819407b7..18b7feb42 100644 --- a/sm5/smartd.cpp +++ b/sm5/smartd.cpp @@ -87,7 +87,6 @@ extern "C" int __stdcall FreeConsole(void); #include "int64.h" #include "atacmds.h" #include "dev_interface.h" -#include "ataprint.h" #include "extern.h" #include "knowndrives.h" #include "scsicmds.h" @@ -131,7 +130,7 @@ extern "C" int getdomainname(char *, int); // no declaration in header files! #define ARGUSED(x) ((void)(x)) // These are CVS identification information for *.cpp and *.h files -extern const char *atacmdnames_c_cvsid, *atacmds_c_cvsid, *ataprint_c_cvsid, *escalade_c_cvsid, +extern const char *atacmdnames_c_cvsid, *atacmds_c_cvsid, *knowndrives_c_cvsid, *os_XXXX_c_cvsid, *scsicmds_c_cvsid, *utility_c_cvsid; #ifdef _HAVE_CCISS @@ -143,8 +142,8 @@ extern const char *os_solaris_ata_s_cvsid; #ifdef _WIN32 extern const char *daemon_win32_c_cvsid, *hostname_win32_c_cvsid, *syslog_win32_c_cvsid; #endif -const char *smartd_c_cvsid="$Id: smartd.cpp,v 1.418 2008/09/06 14:37:17 chrfranke Exp $" -ATACMDS_H_CVSID ATAPRINT_H_CVSID CONFIG_H_CVSID +const char *smartd_c_cvsid="$Id: smartd.cpp,v 1.419 2008/09/06 20:08:35 chrfranke Exp $" +ATACMDS_H_CVSID CONFIG_H_CVSID #ifdef DAEMON_WIN32_H_CVSID DAEMON_WIN32_H_CVSID #endif @@ -474,7 +473,6 @@ void PrintCVS(void){ PrintOut(LOG_INFO,"CVS version IDs of files used to build this code are:\n"); PrintOneCVS(atacmdnames_c_cvsid); PrintOneCVS(atacmds_c_cvsid); - PrintOneCVS(ataprint_c_cvsid); #ifdef _HAVE_CCISS PrintOneCVS(cciss_c_cvsid); #endif @@ -1015,6 +1013,11 @@ void PrintOut(int priority, const char *fmt, ...){ return; } +// Used to warn users about invalid checksums. Called from atacmds.cpp. +void checksumwarning(const char * string) +{ + pout("Warning! %s error: invalid SMART checksum.\n", string); +} // Wait for the pid file to show up, this makes sure a calling program knows // that the daemon is really up and running and has a pid to kill it @@ -1304,7 +1307,7 @@ static int SelfTestErrorCount(ata_device * device, const char * name) } // return current number of self-test errors - return ataPrintSmartSelfTestlog(&log,0); + return ataPrintSmartSelfTestlog(&log, false); } #define SELFTEST_ERRORCOUNT(x) (x & 0xff) -- GitLab