Commit aa690a74 authored by chrfranke's avatar chrfranke
Browse files

smartd: Other config entries may precede DEVICESCAN.

git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@3075 4ea69e1a-61f1-4043-bf83-b5c94c648137
parent b6806fb0
......@@ -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.
......
......@@ -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'
......
......@@ -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.
......
......@@ -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.
......
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment