diff --git a/sm5/CHANGELOG b/sm5/CHANGELOG index 693866e68afcbd8124ac352026c60c57ede7adf5..55652e2a9aa810df36f7c776e364144091e6903e 100644 --- a/sm5/CHANGELOG +++ b/sm5/CHANGELOG @@ -1,6 +1,6 @@ CHANGELOG for smartmontools -$Id: CHANGELOG,v 1.287 2003/12/09 22:40:13 pjwilliams Exp $ +$Id: CHANGELOG,v 1.288 2003/12/10 13:52:06 ballen4705 Exp $ The most recent version of this file is: http://cvs.sourceforge.net/viewcvs.py/smartmontools/sm5/CHANGELOG?sortby=date&view=markup @@ -24,6 +24,9 @@ NOTES FOR FUTURE RELEASES: see TODO file. <ADDITIONS TO THE CHANGE LOG SHOULD BE ADDED JUST BELOW HERE, PLEASE> + [BA] smartd: reduced number of scheduled self-test messages if + test already run in current hour. + [PW] Added Maxtor DiamondMax Plus 8 family to knowndrives table. [BA] linux: check for linux/hdreg.h. If it's there, use it. If diff --git a/sm5/smartd.c b/sm5/smartd.c index e3288703ab1d791bb962c140f798282b27905bde..d9ddf01deb9892001077621fc722a544e30650e6 100644 --- a/sm5/smartd.c +++ b/sm5/smartd.c @@ -69,7 +69,7 @@ extern const char *atacmdnames_c_cvsid, *atacmds_c_cvsid, *ataprint_c_cvsid, *escalade_c_cvsid, *knowndrives_c_cvsid, *os_XXXX_c_cvsid, *scsicmds_c_cvsid, *utility_c_cvsid; -const char *smartd_c_cvsid="$Id: smartd.c,v 1.264 2003/12/10 11:30:31 ballen4705 Exp $" +const char *smartd_c_cvsid="$Id: smartd.c,v 1.265 2003/12/10 13:52:06 ballen4705 Exp $" ATACMDS_H_CVSID ATAPRINT_H_CVSID CONFIG_H_CVSID EXTERN_H_CVSID KNOWNDRIVES_H_CVSID SCSICMDS_H_CVSID SMARTD_H_CVSID UTILITY_H_CVSID; @@ -1363,14 +1363,14 @@ int DoTestNow(cfgfile *cfg, char testtype) { struct tm timenow; time_t epochnow; char matchpattern[16]; - int retval=0; regmatch_t substring; - int weekday; + int weekday, length; + unsigned short hours; testinfo *dat=cfg->testdata; // check that self-testing has been requested if (!dat) - return retval; + return 0; // construct pattern containing the month, day of month, day of // week, and hour @@ -1383,32 +1383,28 @@ int DoTestNow(cfgfile *cfg, char testtype) { sprintf(matchpattern, "%c/%02d/%02d/%1d/%02d", testtype, timenow.tm_mon+1, timenow.tm_mday, weekday, timenow.tm_hour); - // see if we got a match - retval=!regexec(&(dat->cregex), matchpattern, 1, &substring, 0); + // if no match, we are done + if (regexec(&(dat->cregex), matchpattern, 1, &substring, 0)) + return 0; -#if 0 - // debugging: see how many characters of the type/date/time string - // match - PrintOut(LOG_CRIT, "rm_so=%d rm_eo=%d\n", substring.rm_so, substring.rm_eo); -#endif + // must match the ENTIRE type/date/time string + length=strlen(matchpattern); + if (substring.rm_so!=0 || substring.rm_eo!=length) + return 0; - if (retval>0) { - unsigned short hours=1+timenow.tm_hour+24*timenow.tm_yday; - int length=strlen(matchpattern); - if (substring.rm_so!=0 || substring.rm_eo!=length) - // must match unless the ENTIRE type/date/time string - retval=0; - else if (hours==dat->hour) { - // never do a second test in the same hour as one you've already done - PrintOut(LOG_INFO, "Device: %s, alread did test in current hour, skipping test of type %c\n", - cfg->name, testtype); - retval=0; - } - else - // save time of the current test - dat->hour=hours; + // never do a second test in the same hour as another test + hours=1+timenow.tm_hour+24*timenow.tm_yday; + if (hours==dat->hour) { + if (testtype!=dat->testtype) + PrintOut(LOG_INFO, "Device: %s, did test of type %c qin current hour, skipping test of type %c\n", + cfg->name, dat->testtype, testtype); + return 0; } - return retval; + + // save time and type of the current test; we are ready to do a test + dat->hour=hours; + dat->testtype=testtype; + return 1; } // Return zero on success, nonzero on failure. Perform offline (background) diff --git a/sm5/smartd.cpp b/sm5/smartd.cpp index 1a5ae2b680d3575ae1a9c05c218801fd121a791f..ecbd835f7ae18da1951dfe0c85345dba732b5422 100644 --- a/sm5/smartd.cpp +++ b/sm5/smartd.cpp @@ -69,7 +69,7 @@ extern const char *atacmdnames_c_cvsid, *atacmds_c_cvsid, *ataprint_c_cvsid, *escalade_c_cvsid, *knowndrives_c_cvsid, *os_XXXX_c_cvsid, *scsicmds_c_cvsid, *utility_c_cvsid; -const char *smartd_c_cvsid="$Id: smartd.cpp,v 1.264 2003/12/10 11:30:31 ballen4705 Exp $" +const char *smartd_c_cvsid="$Id: smartd.cpp,v 1.265 2003/12/10 13:52:06 ballen4705 Exp $" ATACMDS_H_CVSID ATAPRINT_H_CVSID CONFIG_H_CVSID EXTERN_H_CVSID KNOWNDRIVES_H_CVSID SCSICMDS_H_CVSID SMARTD_H_CVSID UTILITY_H_CVSID; @@ -1363,14 +1363,14 @@ int DoTestNow(cfgfile *cfg, char testtype) { struct tm timenow; time_t epochnow; char matchpattern[16]; - int retval=0; regmatch_t substring; - int weekday; + int weekday, length; + unsigned short hours; testinfo *dat=cfg->testdata; // check that self-testing has been requested if (!dat) - return retval; + return 0; // construct pattern containing the month, day of month, day of // week, and hour @@ -1383,32 +1383,28 @@ int DoTestNow(cfgfile *cfg, char testtype) { sprintf(matchpattern, "%c/%02d/%02d/%1d/%02d", testtype, timenow.tm_mon+1, timenow.tm_mday, weekday, timenow.tm_hour); - // see if we got a match - retval=!regexec(&(dat->cregex), matchpattern, 1, &substring, 0); + // if no match, we are done + if (regexec(&(dat->cregex), matchpattern, 1, &substring, 0)) + return 0; -#if 0 - // debugging: see how many characters of the type/date/time string - // match - PrintOut(LOG_CRIT, "rm_so=%d rm_eo=%d\n", substring.rm_so, substring.rm_eo); -#endif + // must match the ENTIRE type/date/time string + length=strlen(matchpattern); + if (substring.rm_so!=0 || substring.rm_eo!=length) + return 0; - if (retval>0) { - unsigned short hours=1+timenow.tm_hour+24*timenow.tm_yday; - int length=strlen(matchpattern); - if (substring.rm_so!=0 || substring.rm_eo!=length) - // must match unless the ENTIRE type/date/time string - retval=0; - else if (hours==dat->hour) { - // never do a second test in the same hour as one you've already done - PrintOut(LOG_INFO, "Device: %s, alread did test in current hour, skipping test of type %c\n", - cfg->name, testtype); - retval=0; - } - else - // save time of the current test - dat->hour=hours; + // never do a second test in the same hour as another test + hours=1+timenow.tm_hour+24*timenow.tm_yday; + if (hours==dat->hour) { + if (testtype!=dat->testtype) + PrintOut(LOG_INFO, "Device: %s, did test of type %c qin current hour, skipping test of type %c\n", + cfg->name, dat->testtype, testtype); + return 0; } - return retval; + + // save time and type of the current test; we are ready to do a test + dat->hour=hours; + dat->testtype=testtype; + return 1; } // Return zero on success, nonzero on failure. Perform offline (background) diff --git a/sm5/smartd.h b/sm5/smartd.h index e680b18acc1bf89e62918ab07b21c54df503ecd0..2828fe701c08cf8e1eb2452dbc2cb1009772b450 100644 --- a/sm5/smartd.h +++ b/sm5/smartd.h @@ -32,7 +32,7 @@ #ifndef SMARTD_H_CVSID -#define SMARTD_H_CVSID "$Id: smartd.h,v 1.65 2003/12/08 17:25:59 ballen4705 Exp $\n" +#define SMARTD_H_CVSID "$Id: smartd.h,v 1.66 2003/12/10 13:52:06 ballen4705 Exp $\n" #endif // Configuration file @@ -92,6 +92,7 @@ typedef struct testinfo_s { char *regex; // text form of regex regex_t cregex; // compiled form of regex unsigned short hour; // 1+hour of year when last scheduled self-test done + char testtype; // type of test done at hour indicated just above signed char not_cap_offline; // 0==unknown OR capable of offline, 1==not capable signed char not_cap_conveyance; signed char not_cap_short;