Skip to content
Snippets Groups Projects
Commit 88e4e4cd authored by ballen4705's avatar ballen4705
Browse files

[BA] smartd: The syslog entries how have a single process number for

  smartd, not two distinct numbers.  We do this by calling daemon_init()
  before printing header message and before reading config file.  Some
  perror() entries in the latter modified to print in the correct
  place.


git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@338 4ea69e1a-61f1-4043-bf83-b5c94c648137
parent 75925938
No related branches found
No related tags found
No related merge requests found
CHANGELOG for smartmontools CHANGELOG for smartmontools
$Id: CHANGELOG,v 1.61 2002/11/28 09:02:55 ballen4705 Exp $ $Id: CHANGELOG,v 1.62 2002/12/01 06:48:14 ballen4705 Exp $
Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net> Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net>
...@@ -32,6 +32,14 @@ NOTES FOR FUTURE RELEASES: see TODO file. ...@@ -32,6 +32,14 @@ NOTES FOR FUTURE RELEASES: see TODO file.
CURRENT RELEASE (see VERSION file in this directory): CURRENT RELEASE (see VERSION file in this directory):
[BA] smartd: The syslog entries how have a single process number for
smartd, not two distinct numbers. We do this by calling daemon_init()
before printing header message and before reading config file. Some
perror() entries in the latter modified to print in the correct
place.
smartmontools-5.0.48
[BA] smartctl: The -O option to enable an Immediate off-line test [BA] smartctl: The -O option to enable an Immediate off-line test
did not print out the correct time that the test would take to did not print out the correct time that the test would take to
complete. This is because the test timer is volatile and not complete. This is because the test timer is volatile and not
......
48 49
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
// CVS ID strings // CVS ID strings
extern const char *CVSid1, *CVSid2; extern const char *CVSid1, *CVSid2;
const char *CVSid6="$Id: smartd.c,v 1.76 2002/11/25 11:45:28 ballen4705 Exp $" const char *CVSid6="$Id: smartd.c,v 1.77 2002/12/01 06:48:14 ballen4705 Exp $"
CVSID1 CVSID2 CVSID3 CVSID4 CVSID7; CVSID1 CVSID2 CVSID3 CVSID4 CVSID7;
// global variable used for control of printing, passing arguments, etc. // global variable used for control of printing, passing arguments, etc.
...@@ -1090,7 +1090,10 @@ int parseconfigline(int entry, int lineno,char *line){ ...@@ -1090,7 +1090,10 @@ int parseconfigline(int entry, int lineno,char *line){
static int numtokens=0; static int numtokens=0;
if (!(copy=strdup(line))){ if (!(copy=strdup(line))){
perror("no memory available to parse line"); if (errno<sys_nerr)
printout(LOG_INFO,"No memory to parse file: %s line %d, %s\n", CONFIGFILE, lineno, sys_errlist[errno]);
else
printout(LOG_INFO,"No memory to parse file: %s line %d\n", CONFIGFILE, lineno);
exit(1); exit(1);
} }
...@@ -1115,7 +1118,7 @@ int parseconfigline(int entry, int lineno,char *line){ ...@@ -1115,7 +1118,7 @@ int parseconfigline(int entry, int lineno,char *line){
// Is there space for another entry? // Is there space for another entry?
if (entry>=MAXENTRIES){ if (entry>=MAXENTRIES){
printout(LOG_CRIT,"Error: configuration file %s can have no more than %d entries\n", printout(LOG_CRIT,"Error: configuration file %s can have no more than MAXENTRIES=%d entries\n",
CONFIGFILE,MAXENTRIES); CONFIGFILE,MAXENTRIES);
exit(1); exit(1);
} }
...@@ -1131,7 +1134,10 @@ int parseconfigline(int entry, int lineno,char *line){ ...@@ -1131,7 +1134,10 @@ int parseconfigline(int entry, int lineno,char *line){
cfg->trackatt=(unsigned char *)calloc(32,1); cfg->trackatt=(unsigned char *)calloc(32,1);
if (!cfg->name || !cfg->failatt || !cfg->trackatt) { if (!cfg->name || !cfg->failatt || !cfg->trackatt) {
perror("no memory available to save name"); if (errno<sys_nerr)
printout(LOG_INFO,"No memory to store file: %s line %d, %s\n", CONFIGFILE, lineno, sys_errlist[errno]);
else
printout(LOG_INFO,"No memory to store file: %s line %d\n", CONFIGFILE, lineno);
exit(1); exit(1);
} }
...@@ -1352,9 +1358,6 @@ void ParseOpts(int argc, char **argv){ ...@@ -1352,9 +1358,6 @@ void ParseOpts(int argc, char **argv){
exit(0); exit(0);
} }
} }
// print header
printhead();
return; return;
} }
...@@ -1395,9 +1398,13 @@ int makeconfigentries(int num, char *name, int isata, int start){ ...@@ -1395,9 +1398,13 @@ int makeconfigentries(int num, char *name, int isata, int start){
cfg->failatt=(unsigned char *)calloc(32,1); cfg->failatt=(unsigned char *)calloc(32,1);
cfg->trackatt=(unsigned char *)calloc(32,1); cfg->trackatt=(unsigned char *)calloc(32,1);
if (!cfg->name || !cfg->failatt || !cfg->trackatt) { if (!cfg->name || !cfg->failatt || !cfg->trackatt) {
perror("no memory available to save name"); if (errno<sys_nerr)
printout(LOG_INFO,"No memory for %d'th device after %s, %s\n", i, name, sys_errlist[errno]);
else
printout(LOG_INFO,"No memory for %d'th device after %s\n", i, name);
exit(1); exit(1);
} }
// increment final character of the name // increment final character of the name
cfg->name[strlen(name)-1]+=i; cfg->name[strlen(name)-1]+=i;
} }
...@@ -1435,14 +1442,17 @@ int main (int argc, char **argv){ ...@@ -1435,14 +1442,17 @@ int main (int argc, char **argv){
con->veryquietmode=debugmode?0:1; con->veryquietmode=debugmode?0:1;
con->checksumfail=0; con->checksumfail=0;
// look in configuration file CONFIGFILE (normally /etc/smartd.conf)
entries=parseconfigfile();
// If in background as a daemon, fork and close file descriptors // If in background as a daemon, fork and close file descriptors
if (!debugmode){ if (!debugmode){
daemon_init(); daemon_init();
} }
// print header after daemon_init so right process number in syslog
printhead();
// look in configuration file CONFIGFILE (normally /etc/smartd.conf)
entries=parseconfigfile();
// setup signal handler for shutdown // setup signal handler for shutdown
if (signal(SIGINT, sighandler)==SIG_IGN) if (signal(SIGINT, sighandler)==SIG_IGN)
signal(SIGINT, SIG_IGN); signal(SIGINT, SIG_IGN);
...@@ -1455,7 +1465,6 @@ int main (int argc, char **argv){ ...@@ -1455,7 +1465,6 @@ int main (int argc, char **argv){
if (signal(SIGUSR1, sleephandler)==SIG_IGN) if (signal(SIGUSR1, sleephandler)==SIG_IGN)
signal(SIGUSR1, SIG_IGN); signal(SIGUSR1, SIG_IGN);
// install goobye message // install goobye message
atexit(goobye); atexit(goobye);
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
// CVS ID strings // CVS ID strings
extern const char *CVSid1, *CVSid2; extern const char *CVSid1, *CVSid2;
const char *CVSid6="$Id: smartd.cpp,v 1.76 2002/11/25 11:45:28 ballen4705 Exp $" const char *CVSid6="$Id: smartd.cpp,v 1.77 2002/12/01 06:48:14 ballen4705 Exp $"
CVSID1 CVSID2 CVSID3 CVSID4 CVSID7; CVSID1 CVSID2 CVSID3 CVSID4 CVSID7;
// global variable used for control of printing, passing arguments, etc. // global variable used for control of printing, passing arguments, etc.
...@@ -1090,7 +1090,10 @@ int parseconfigline(int entry, int lineno,char *line){ ...@@ -1090,7 +1090,10 @@ int parseconfigline(int entry, int lineno,char *line){
static int numtokens=0; static int numtokens=0;
if (!(copy=strdup(line))){ if (!(copy=strdup(line))){
perror("no memory available to parse line"); if (errno<sys_nerr)
printout(LOG_INFO,"No memory to parse file: %s line %d, %s\n", CONFIGFILE, lineno, sys_errlist[errno]);
else
printout(LOG_INFO,"No memory to parse file: %s line %d\n", CONFIGFILE, lineno);
exit(1); exit(1);
} }
...@@ -1115,7 +1118,7 @@ int parseconfigline(int entry, int lineno,char *line){ ...@@ -1115,7 +1118,7 @@ int parseconfigline(int entry, int lineno,char *line){
// Is there space for another entry? // Is there space for another entry?
if (entry>=MAXENTRIES){ if (entry>=MAXENTRIES){
printout(LOG_CRIT,"Error: configuration file %s can have no more than %d entries\n", printout(LOG_CRIT,"Error: configuration file %s can have no more than MAXENTRIES=%d entries\n",
CONFIGFILE,MAXENTRIES); CONFIGFILE,MAXENTRIES);
exit(1); exit(1);
} }
...@@ -1131,7 +1134,10 @@ int parseconfigline(int entry, int lineno,char *line){ ...@@ -1131,7 +1134,10 @@ int parseconfigline(int entry, int lineno,char *line){
cfg->trackatt=(unsigned char *)calloc(32,1); cfg->trackatt=(unsigned char *)calloc(32,1);
if (!cfg->name || !cfg->failatt || !cfg->trackatt) { if (!cfg->name || !cfg->failatt || !cfg->trackatt) {
perror("no memory available to save name"); if (errno<sys_nerr)
printout(LOG_INFO,"No memory to store file: %s line %d, %s\n", CONFIGFILE, lineno, sys_errlist[errno]);
else
printout(LOG_INFO,"No memory to store file: %s line %d\n", CONFIGFILE, lineno);
exit(1); exit(1);
} }
...@@ -1352,9 +1358,6 @@ void ParseOpts(int argc, char **argv){ ...@@ -1352,9 +1358,6 @@ void ParseOpts(int argc, char **argv){
exit(0); exit(0);
} }
} }
// print header
printhead();
return; return;
} }
...@@ -1395,9 +1398,13 @@ int makeconfigentries(int num, char *name, int isata, int start){ ...@@ -1395,9 +1398,13 @@ int makeconfigentries(int num, char *name, int isata, int start){
cfg->failatt=(unsigned char *)calloc(32,1); cfg->failatt=(unsigned char *)calloc(32,1);
cfg->trackatt=(unsigned char *)calloc(32,1); cfg->trackatt=(unsigned char *)calloc(32,1);
if (!cfg->name || !cfg->failatt || !cfg->trackatt) { if (!cfg->name || !cfg->failatt || !cfg->trackatt) {
perror("no memory available to save name"); if (errno<sys_nerr)
printout(LOG_INFO,"No memory for %d'th device after %s, %s\n", i, name, sys_errlist[errno]);
else
printout(LOG_INFO,"No memory for %d'th device after %s\n", i, name);
exit(1); exit(1);
} }
// increment final character of the name // increment final character of the name
cfg->name[strlen(name)-1]+=i; cfg->name[strlen(name)-1]+=i;
} }
...@@ -1435,14 +1442,17 @@ int main (int argc, char **argv){ ...@@ -1435,14 +1442,17 @@ int main (int argc, char **argv){
con->veryquietmode=debugmode?0:1; con->veryquietmode=debugmode?0:1;
con->checksumfail=0; con->checksumfail=0;
// look in configuration file CONFIGFILE (normally /etc/smartd.conf)
entries=parseconfigfile();
// If in background as a daemon, fork and close file descriptors // If in background as a daemon, fork and close file descriptors
if (!debugmode){ if (!debugmode){
daemon_init(); daemon_init();
} }
// print header after daemon_init so right process number in syslog
printhead();
// look in configuration file CONFIGFILE (normally /etc/smartd.conf)
entries=parseconfigfile();
// setup signal handler for shutdown // setup signal handler for shutdown
if (signal(SIGINT, sighandler)==SIG_IGN) if (signal(SIGINT, sighandler)==SIG_IGN)
signal(SIGINT, SIG_IGN); signal(SIGINT, SIG_IGN);
...@@ -1455,7 +1465,6 @@ int main (int argc, char **argv){ ...@@ -1455,7 +1465,6 @@ int main (int argc, char **argv){
if (signal(SIGUSR1, sleephandler)==SIG_IGN) if (signal(SIGUSR1, sleephandler)==SIG_IGN)
signal(SIGUSR1, SIG_IGN); signal(SIGUSR1, SIG_IGN);
// install goobye message // install goobye message
atexit(goobye); atexit(goobye);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment