diff --git a/smartmontools/CHANGELOG b/smartmontools/CHANGELOG index 5ded674f9984d83bdd907aea2bf8252de5b5d982..f08e9e763e038d35f07f2023ed6a4547e4c343dc 100644 --- a/smartmontools/CHANGELOG +++ b/smartmontools/CHANGELOG @@ -43,6 +43,9 @@ NOTES FOR FUTURE RELEASES: see TODO file. <DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE> + [CF] smartd: Other config entries may precede DEVICESCAN. + Very first step towards a more flexible device scanning. + [CF] Windows: Use '.win64' in names of 64-bit binary packages. Use correct 'strip' program when cross-compiling. diff --git a/smartmontools/NEWS b/smartmontools/NEWS index a1b9fcae7c405d200043197a16aa09211a0bbfaf..4317ed6a944243302ff7c95840e0394243fa67fa 100644 --- a/smartmontools/NEWS +++ b/smartmontools/NEWS @@ -8,6 +8,7 @@ http://smartmontools.svn.sourceforge.net/viewvc/smartmontools/trunk/smartmontool Date <Not released yet, please try current SVN> Summary: smartmontools release 5.40 ----------------------------------------------------------- +- Other config entries may precede smartd DEVICESCAN. - Option '-v' allows to specify byte order of attribute raw value - configure: New default value for '--with-docdir'. - Drive database is in a separate source file 'drivedb.h' diff --git a/smartmontools/smartd.8.in b/smartmontools/smartd.8.in index f560459476d30f1310c7983f905bee84a52d3868..6b94f6fe6d614770deb7786b5bba0f6c296ab298 100644 --- a/smartmontools/smartd.8.in +++ b/smartmontools/smartd.8.in @@ -680,8 +680,7 @@ Section below! .SH CONFIGURATION FILE DIRECTIVES .PP -If the first non-comment entry in the configuration file is the text -string +If a non-comment entry in the configuration file is the text string .B DEVICESCAN in capital letters, then \fBsmartd\fP @@ -1699,11 +1698,15 @@ If you want more frequent information, use: .TP .B ADDITIONAL DETAILS ABOUT DEVICESCAN -If the first non-comment entry in the configuration file is the text +If a non-comment entry in the configuration file is the text string \fBDEVICESCAN\fP in capital letters, then \fBsmartd\fP will ignore any remaining lines in the configuration file, and will scan for devices. +[NEW EXPERIMENTAL SMARTD FEATURE] Configuration entries for devices +not found by the platform\-specific device scanning may precede the +\fBDEVICESCAN\fP entry. + If \fBDEVICESCAN\fP is not followed by any Directives, then smartd will scan for both ATA and SCSI devices, and will monitor all possible SMART properties of any devices that are found. diff --git a/smartmontools/smartd.conf.5.in b/smartmontools/smartd.conf.5.in index 78c7e5d4cb90e797a52f609b974f1d12806bb5dd..916910830afae065860a6088ad4d75c03e3a7452 100644 --- a/smartmontools/smartd.conf.5.in +++ b/smartmontools/smartd.conf.5.in @@ -234,8 +234,7 @@ Section below! .SH CONFIGURATION FILE DIRECTIVES .PP -If the first non-comment entry in the configuration file is the text -string +If a non-comment entry in the configuration file is the text string .B DEVICESCAN in capital letters, then \fBsmartd\fP @@ -1253,11 +1252,15 @@ If you want more frequent information, use: .TP .B ADDITIONAL DETAILS ABOUT DEVICESCAN -If the first non-comment entry in the configuration file is the text +If a non-comment entry in the configuration file is the text string \fBDEVICESCAN\fP in capital letters, then \fBsmartd\fP will ignore any remaining lines in the configuration file, and will scan for devices. +[NEW EXPERIMENTAL SMARTD FEATURE] Configuration entries for devices +not found by the platform\-specific device scanning may precede the +\fBDEVICESCAN\fP entry. + If \fBDEVICESCAN\fP is not followed by any Directives, then smartd will scan for both ATA and SCSI devices, and will monitor all possible SMART properties of any devices that are found. diff --git a/smartmontools/smartd.cpp b/smartmontools/smartd.cpp index 9f00a8fe045ac2b4bbc561c6fc3bbd69fc0ecee6..b8eaa09c4b671bb115cca122fd148d95ddb52380 100644 --- a/smartmontools/smartd.cpp +++ b/smartmontools/smartd.cpp @@ -3455,7 +3455,7 @@ static int ParseToken(char * token, dev_config & cfg) // -2: found an error // // Note: this routine modifies *line from the caller! -static int ParseConfigLine(dev_config_vector & conf_entries, int entry, int lineno, /*const*/ char * line) +static int ParseConfigLine(dev_config_vector & conf_entries, int /*entry*/, int lineno, /*const*/ char * line) { char *token=NULL; char *name=NULL; @@ -3470,10 +3470,6 @@ static int ParseConfigLine(dev_config_vector & conf_entries, int entry, int line // Have we detected the SCANDIRECTIVE directive? if (!strcmp(SCANDIRECTIVE,name)){ devscan=1; - if (entry) { - PrintOut(LOG_INFO,"Scan Directive %s (line %d) must be the first entry in %s\n",name, lineno, configfile); - return -2; - } } // We've got a legit entry, make space to store it @@ -3562,7 +3558,7 @@ static int ParseConfigLine(dev_config_vector & conf_entries, int entry, int line // possiblities: // Empty configuration file ==> conf_entries.empty() // No configuration file ==> conf_entries[0].lineno == 0 -// SCANDIRECTIVE found ==> conf_entries[0].lineno != 0 +// SCANDIRECTIVE found ==> conf_entries.back().lineno != 0 (size >= 1) static int ParseConfigFile(dev_config_vector & conf_entries) { // maximum line length in configuration file @@ -4046,6 +4042,10 @@ static int MakeConfigEntries(const dev_config & base_cfg, if (devlist.size() <= 0) return 0; + // add empty device slots for existing config entries + while (scanned_devs.size() < conf_entries.size()) + scanned_devs.push_back((smart_device *)0); + // loop over entries to create for (unsigned i = 0; i < devlist.size(); i++) { // Move device pointer @@ -4078,8 +4078,6 @@ static void CanNotRegister(const char *name, const char *type, int line, bool sc // Returns negative value (see ParseConfigFile()) if config file // had errors, else number of entries which may be zero or positive. -// If we found no configuration file, or it contained SCANDIRECTIVE, -// then *scanning is set to 1, else 0. static int ReadOrMakeConfigEntries(dev_config_vector & conf_entries, smart_device_list & scanned_devs) { // parse configuration file configfile (normally /etc/smartd.conf) @@ -4098,12 +4096,12 @@ static int ReadOrMakeConfigEntries(dev_config_vector & conf_entries, smart_devic // we did not find a SCANDIRECTIVE and did find valid entries PrintOut(LOG_INFO, "Configuration file %s parsed.\n", configfile); } - else if (conf_entries.size() == 1) { + else if (!conf_entries.empty()) { // we found a SCANDIRECTIVE or there was no configuration file so - // scan. Configuration file's first entry contains all options + // scan. Configuration file's last entry contains all options // that were set - dev_config first = conf_entries.front(); - conf_entries.clear(); + dev_config first = conf_entries.back(); + conf_entries.pop_back(); if (first.lineno) PrintOut(LOG_INFO,"Configuration file %s was parsed, found %s, scanning devices\n", configfile, SCANDIRECTIVE);