From f40e0cfe3a4e83b2f2fd7801dbf47edce9b14527 Mon Sep 17 00:00:00 2001 From: chrfranke <chrfranke@4ea69e1a-61f1-4043-bf83-b5c94c648137> Date: Sun, 3 May 2009 13:21:35 +0000 Subject: [PATCH] smartd: Fix '-M test' directive in conjunction with '-s' option. git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@2781 4ea69e1a-61f1-4043-bf83-b5c94c648137 --- sm5/CHANGELOG | 5 ++++- sm5/smartd.cpp | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/sm5/CHANGELOG b/sm5/CHANGELOG index 82604869e..c42072459 100644 --- a/sm5/CHANGELOG +++ b/sm5/CHANGELOG @@ -1,6 +1,6 @@ CHANGELOG for smartmontools -$Id: CHANGELOG,v 1.798 2009/04/28 21:11:15 manfred99 Exp $ +$Id: CHANGELOG,v 1.799 2009/05/03 13:21:35 chrfranke Exp $ The most recent version of this file is: http://smartmontools.cvs.sourceforge.net/smartmontools/sm5/CHANGELOG?view=markup @@ -41,6 +41,9 @@ NOTES FOR FUTURE RELEASES: see TODO file. <DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE> + [CF] smartd: Fix '-M test' directive in conjunction with '-s' option. + Thanks to Matthias Becher for the problem report. + [MS] knowndrives.cpp updates: - Add Seagate Barracuda 7200.12 series - Add Seagate Momentus 5400.4 series diff --git a/sm5/smartd.cpp b/sm5/smartd.cpp index e52e5306e..3ff4a74e5 100644 --- a/sm5/smartd.cpp +++ b/sm5/smartd.cpp @@ -136,7 +136,7 @@ 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.444 2009/04/16 21:24:08 chrfranke Exp $" +const char *smartd_c_cvsid="$Id: smartd.cpp,v 1.445 2009/05/03 13:21:35 chrfranke Exp $" ATACMDS_H_CVSID CONFIG_H_CVSID #ifdef DAEMON_WIN32_H_CVSID DAEMON_WIN32_H_CVSID @@ -332,6 +332,9 @@ dev_config::dev_config() // Number of allowed mail message types const int SMARTD_NMAIL = 13; +// Type for '-M test' mails (state not persistent) +const int MAILTYPE_TEST = 0; +// TODO: Add const or enum for all mail types. struct mailinfo { int logged;// number of times an email has been sent @@ -545,6 +548,8 @@ static bool parse_dev_state_line(const char * line, persistent_dev_state & state int i = atoi(line+match[m].rm_so); if (!(0 <= i && i < SMARTD_NMAIL)) return false; + if (i == MAILTYPE_TEST) // Don't suppress test mails + return true; if (match[m+=2].rm_so >= 0) state.maillog[i].logged = (int)val; else if (match[++m].rm_so >= 0) @@ -642,6 +647,8 @@ static bool write_dev_state(const char * path, const persistent_dev_state & stat int i; for (i = 0; i < SMARTD_NMAIL; i++) { + if (i == MAILTYPE_TEST) // Don't suppress test mails + continue; const mailinfo & mi = state.maillog[i]; if (!mi.logged) continue; -- GitLab