Skip to content
Snippets Groups Projects
Commit cc94c05c authored by pjwilliams's avatar pjwilliams
Browse files

Replaced smartd.conf directive -C with smartd option -i

git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@385 4ea69e1a-61f1-4043-bf83-b5c94c648137
parent f014cd2f
Branches
No related tags found
No related merge requests found
CHANGELOG for smartmontools CHANGELOG for smartmontools
$Id: CHANGELOG,v 1.71 2002/12/28 16:16:52 pjwilliams Exp $ $Id: CHANGELOG,v 1.72 2002/12/29 01:10:41 pjwilliams Exp $
Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net> Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net>
...@@ -32,6 +32,8 @@ NOTES FOR FUTURE RELEASES: see TODO file. ...@@ -32,6 +32,8 @@ NOTES FOR FUTURE RELEASES: see TODO file.
CURRENT RELEASE (see VERSION file in this directory): CURRENT RELEASE (see VERSION file in this directory):
[PW] Replaced smartd.conf directive -C with smartd option -i
[PW] Changed options for smartctl -- see man page. [PW] Changed options for smartctl -- see man page.
[BA] Use strerror() to generate system call error messages. [BA] Use strerror() to generate system call error messages.
......
...@@ -218,7 +218,7 @@ old to new smartd.conf directives: ...@@ -218,7 +218,7 @@ old to new smartd.conf directives:
-A -X --abort -A -X --abort
SHOULD BECOME A COMMAND-LINE ARGUMENT (-i N, --interval N) =======> -C N Set checktime NOW CMD LINE: -i N NOW A COMMAND-LINE OPTION (-i N, --interval N) =======> -C N Set checktime CMD LINE: -i N
-f usage attributes -f -f usage attributes -f
-M ADD Email addresses -m ADD -M ADD Email addresses -m ADD
-m -3 Email mode -M diminishing,test -m -3 Email mode -M diminishing,test
...@@ -234,7 +234,7 @@ old to new smartd.conf directives: ...@@ -234,7 +234,7 @@ old to new smartd.conf directives:
\ Line continuation \ \ Line continuation \
------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------
Changes to smartd options (not yet implemented): Changes to smartd options (in progress):
---------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------
5.0 short 5.0 long 5.1 short 5.1 long 5.0 short 5.0 long 5.1 short 5.1 long
......
\# Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net> \# Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net>
\# \#
\# $Id: smartd.8,v 1.41 2002/12/08 12:56:52 pjwilliams Exp $ \# $Id: smartd.8,v 1.42 2002/12/29 01:10:42 pjwilliams Exp $
\# \#
\# This program is free software; you can redistribute it and/or modify it \# This program is free software; you can redistribute it and/or modify it
\# under the terms of the GNU General Public License as published by the Free \# under the terms of the GNU General Public License as published by the Free
...@@ -16,11 +16,11 @@ ...@@ -16,11 +16,11 @@
\# Research Center), Jack Baskin School of Engineering, University of \# Research Center), Jack Baskin School of Engineering, University of
\# California, Santa Cruz. http://ssrc.soe.ucsc.edu/ \# California, Santa Cruz. http://ssrc.soe.ucsc.edu/
\# \#
.TH SMARTD 8 "$Date: 2002/12/08 12:56:52 $" "smartmontools-5.0" .TH SMARTD 8 "$Date: 2002/12/29 01:10:42 $" "smartmontools-5.0"
.SH NAME .SH NAME
smartd \- S.M.A.R.T. Daemon smartd \- S.M.A.R.T. Daemon
.SH SYNOPSIS .SH SYNOPSIS
.B smartd [-XVh] [--debug] [--version] [--help] .B smartd [options]
.SH DESCRIPTION .SH DESCRIPTION
.B smartd .B smartd
...@@ -65,8 +65,8 @@ signal to ...@@ -65,8 +65,8 @@ signal to
.B smartd .B smartd
it will immediately check the status of the disks, and then return to it will immediately check the status of the disks, and then return to
polling the disks every 30 minutes. See the polling the disks every 30 minutes. See the
.B '\-C' .B '\-i'
Directive below for additional details. option below for additional details.
On startup, in the absence of the configuration file On startup, in the absence of the configuration file
.B /etc/smartd.conf, .B /etc/smartd.conf,
...@@ -104,6 +104,34 @@ in "debug" mode. In this mode, it does not ...@@ -104,6 +104,34 @@ in "debug" mode. In this mode, it does not
.B fork .B fork
(2) and displays status information to STDOUT. It also prints more (2) and displays status information to STDOUT. It also prints more
verbose information about what it is doing. verbose information about what it is doing.
.TP
.B \-i N, \-\-interval=N
Sets the interval between disk checks to
.I N
seconds, where
.I N
is a decimal integer. The minimum allowed value is ten and the maximum is the
largest positive integer that can be represented on your system (often 2^31-1).
The default is 1800 seconds.
Note that the superuser can make
.B smartd
check the status of the disks at any time by sending it the
.B SIGHUP
signal, for example with the command:
.nf
.B kill -SIGUSR1 <pid>
.fi
where
.B <pid>
is the process id number of
.B smartd.
One may also use:
.nf
.B killall -USR1 smartd
.fi
for the same purpose.
.TP .TP
.B \-V, \-\-version, \-\-license, \-\-copyright .B \-V, \-\-version, \-\-license, \-\-copyright
Prints license, copyright, and CVS version information onto Prints license, copyright, and CVS version information onto
...@@ -276,7 +304,7 @@ possible. ...@@ -276,7 +304,7 @@ possible.
.B If a SCSI disk is listed, .B If a SCSI disk is listed,
it will be monitored at the only implemented level: roughly equivalent it will be monitored at the only implemented level: roughly equivalent
to using the '\-c' option for an ATA disk. So with the exception of '\-S', '\-C', '\-M', and '\-m', to using the '\-c' option for an ATA disk. So with the exception of '\-S', '\-M', and '\-m',
the Directives below are ignored for SCSI the Directives below are ignored for SCSI
disks. For SCSI disks, the '\-M' Directive sends a warning email if disks. For SCSI disks, the '\-M' Directive sends a warning email if
the SMART status indicates a disk failure or problem. the SMART status indicates a disk failure or problem.
...@@ -298,33 +326,6 @@ device names like /dev/hda or /dev/sdb. If ...@@ -298,33 +326,6 @@ device names like /dev/hda or /dev/sdb. If
can't guess from this sixth character, then it will simply try to can't guess from this sixth character, then it will simply try to
access the device using first ATA and then SCSI ioctl()s. access the device using first ATA and then SCSI ioctl()s.
.TP .TP
.B \-C <N>
This sets the time in between disk checks to be
.B <N>
seconds apart, where N is a decimal integer. Note that although you can give this Directive
multiple times on different lines of the configuration file, only the
final value that is given is used. That final value applies to all the disks.
The default value of
.B <N>
is 1800 sec, and the minimum allowed value is
ten seconds. The maximum value is 2^31-1 seconds.
Note that the superuser can make
.B smartd
check the status of the disks at any time by sending it the
.B SIGHUP
signal, for example with the command:
.nf
.B kill -SIGUSR1 <pid>
.fi
where
.B <pid>
is the process id number of smartd. One may also use:
.nf
.B killall -USR1 smartd
.fi
for the same purpose.
.TP
.B \-P .B \-P
Permissive: Even if the disk appears to lack SMART capabilities, try Permissive: Even if the disk appears to lack SMART capabilities, try
to monitor it anyway. This may be required for some old disks (prior to monitor it anyway. This may be required for some old disks (prior
...@@ -656,4 +657,4 @@ Please let us know if there is an on\-line source for this document. ...@@ -656,4 +657,4 @@ Please let us know if there is an on\-line source for this document.
.SH .SH
CVS ID OF THIS PAGE: CVS ID OF THIS PAGE:
$Id: smartd.8,v 1.41 2002/12/08 12:56:52 pjwilliams Exp $ $Id: smartd.8,v 1.42 2002/12/29 01:10:42 pjwilliams Exp $
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,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.88 2002/12/16 12:27:00 ballen4705 Exp $" const char *CVSid6="$Id: smartd.c,v 1.89 2002/12/29 01:10:42 pjwilliams 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.
...@@ -318,7 +318,6 @@ void Directives() { ...@@ -318,7 +318,6 @@ void Directives() {
printout(LOG_INFO,"Configuration file Directives (following device name):\n"); printout(LOG_INFO,"Configuration file Directives (following device name):\n");
printout(LOG_INFO," -A Device is an ATA device\n"); printout(LOG_INFO," -A Device is an ATA device\n");
printout(LOG_INFO," -S Device is a SCSI device\n"); printout(LOG_INFO," -S Device is a SCSI device\n");
printout(LOG_INFO," -C N Check disks once every N seconds, where N>=10.\n");
printout(LOG_INFO," -P Permissive, ignore apparent lack of SMART.\n"); printout(LOG_INFO," -P Permissive, ignore apparent lack of SMART.\n");
printout(LOG_INFO," -T N Automatic offline tests. N=0: Disable, 1: Enable.\n"); printout(LOG_INFO," -T N Automatic offline tests. N=0: Disable, 1: Enable.\n");
printout(LOG_INFO," -s N Attribute Autosave. N=0: Disable, 1: Enable.\n"); printout(LOG_INFO," -s N Attribute Autosave. N=0: Disable, 1: Enable.\n");
...@@ -337,24 +336,26 @@ void Directives() { ...@@ -337,24 +336,26 @@ void Directives() {
printout(LOG_INFO," # Comment: text after a hash sign is ignored\n"); printout(LOG_INFO," # Comment: text after a hash sign is ignored\n");
printout(LOG_INFO," \\ Line continuation character\n"); printout(LOG_INFO," \\ Line continuation character\n");
printout(LOG_INFO,"Attribute ID is a decimal integer 1 <= ID <= 255\n"); printout(LOG_INFO,"Attribute ID is a decimal integer 1 <= ID <= 255\n");
printout(LOG_INFO,"SCSI devices: only -S, -C, -M, and -m Directives allowed.\n"); printout(LOG_INFO,"SCSI devices: only -S, -M, and -m Directives allowed.\n");
printout(LOG_INFO,"Example: /dev/hda -a\n"); printout(LOG_INFO,"Example: /dev/hda -a\n");
return; return;
} }
/* prints help information for command syntax */ /* prints help information for command syntax */
void Usage (void){ void Usage (void){
printout(LOG_INFO,"Usage: smartd [options]\n\n");
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
printout(LOG_INFO,"Usage: smartd [-XVh] [--debug] [--version] [--help]\n\n");
printout(LOG_INFO,"Command Line Options:\n"); printout(LOG_INFO,"Command Line Options:\n");
printout(LOG_INFO," -X, --debug\n Start smartd in debug mode\n\n"); printout(LOG_INFO," -X, --debug\n Start smartd in debug mode\n\n");
printout(LOG_INFO," -i N, --interval=N\n");
printout(LOG_INFO," Set interval between disk checks to N seconds, where N >= 10\n\n");
printout(LOG_INFO," -V, --version, --license, --copyright\n"); printout(LOG_INFO," -V, --version, --license, --copyright\n");
printout(LOG_INFO," Print License, Copyright, and version information\n\n"); printout(LOG_INFO," Print License, Copyright, and version information\n\n");
printout(LOG_INFO," -h, -?, --help, --usage\n Display this help and exit\n\n"); printout(LOG_INFO," -h, -?, --help, --usage\n Display this help and exit\n\n");
#else #else
printout(LOG_INFO,"Usage: smartd [-XVh]\n\n");
printout(LOG_INFO,"Command Line Options:\n"); printout(LOG_INFO,"Command Line Options:\n");
printout(LOG_INFO," -X Start smartd in debug mode\n"); printout(LOG_INFO," -X Start smartd in debug mode\n");
printout(LOG_INFO," -i N Set interval between disk checks to N seconds, where N >= 10\n");
printout(LOG_INFO," -V Print License, Copyright, and version information\n"); printout(LOG_INFO," -V Print License, Copyright, and version information\n");
printout(LOG_INFO," -h Display this help and exit\n"); printout(LOG_INFO," -h Display this help and exit\n");
printout(LOG_INFO," -? Same as -h\n"); printout(LOG_INFO," -? Same as -h\n");
...@@ -1067,10 +1068,6 @@ int parsetoken(char *token,cfgfile *cfg){ ...@@ -1067,10 +1068,6 @@ int parsetoken(char *token,cfgfile *cfg){
val=inttoken(arg=strtok(NULL,delim), name, token, lineno, CONFIGFILE, 1, 255); val=inttoken(arg=strtok(NULL,delim), name, token, lineno, CONFIGFILE, 1, 255);
isattoff(val,cfg->trackatt,1); isattoff(val,cfg->trackatt,1);
break; break;
case 'C':
// period (time interval) for checking
checktime=inttoken(arg=strtok(NULL,delim), name, token, lineno, CONFIGFILE, 10, INT_MAX);
break;
case 'M': case 'M':
// send email to address that follows // send email to address that follows
arg=strtok(NULL,delim); arg=strtok(NULL,delim);
...@@ -1325,9 +1322,14 @@ void ParseOpts(int argc, char **argv){ ...@@ -1325,9 +1322,14 @@ void ParseOpts(int argc, char **argv){
extern char *optarg; extern char *optarg;
extern int optopt, optind, opterr; extern int optopt, optind, opterr;
int optchar; int optchar;
char *tailptr;
long lchecktime;
const char *shortopts = "Xi:Vh?";
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
struct option long_options[] = { char *arg;
struct option longopts[] = {
{ "debug", no_argument, 0, 'X' }, { "debug", no_argument, 0, 'X' },
{ "interval", required_argument, 0, 'i' },
{ "version", no_argument, 0, 'V' }, { "version", no_argument, 0, 'V' },
{ "license", no_argument, 0, 'V' }, { "license", no_argument, 0, 'V' },
{ "copyright", no_argument, 0, 'V' }, { "copyright", no_argument, 0, 'V' },
...@@ -1341,14 +1343,29 @@ void ParseOpts(int argc, char **argv){ ...@@ -1341,14 +1343,29 @@ void ParseOpts(int argc, char **argv){
// Parse input options: // Parse input options:
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
while (-1 != (optchar = getopt_long(argc, argv, "XVh?", long_options, NULL))){ while (-1 != (optchar = getopt_long(argc, argv, shortopts, longopts, NULL))){
#else #else
while (-1 != (optchar = getopt(argc, argv, "XVh?"))){ while (-1 != (optchar = getopt(argc, argv, shortopts))){
#endif #endif
switch(optchar) { switch(optchar) {
case 'X': case 'X':
debugmode = TRUE; debugmode = TRUE;
break; break;
case 'i':
// Period (time interval) for checking
// strtol will set errno in the event of overflow, so we'll check it.
errno = 0;
lchecktime = strtol(optarg, &tailptr, 10);
if (*tailptr != '\0' || lchecktime < 10 || lchecktime > INT_MAX || errno) {
debugmode=1;
printhead();
printout(LOG_CRIT, "======> INVALID INTERVAL: %s <=======\n", optarg);
printout(LOG_CRIT, "======> INTERVAL MUST BE INTEGER BETWEEN %d AND %d <=======\n", 10, INT_MAX);
Usage();
exit(-1);
}
checktime = (int)lchecktime;
break;
case 'V': case 'V':
PrintCopyleft(); PrintCopyleft();
exit(0); exit(0);
...@@ -1357,25 +1374,36 @@ void ParseOpts(int argc, char **argv){ ...@@ -1357,25 +1374,36 @@ void ParseOpts(int argc, char **argv){
case 'h': case 'h':
default: default:
debugmode=1; debugmode=1;
if (optopt) {
printhead(); printhead();
printout(LOG_CRIT,"=======> UNRECOGNIZED OPTION: %c <======= \n\n",optopt);
Usage();
exit(-1);
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
} else if (optchar == '?' && argv[optind-1][1] == '-') { // Point arg to the argument in which this option was found.
printhead(); arg = argv[optind-1];
printout(LOG_CRIT,"=======> UNRECOGNIZED OPTION: %s <======= \n\n",argv[optind-1]+2); // Check whether the option is a long option that doesn't map to -h.
if (arg[1] == '-' && optchar != 'h') {
// Iff optopt holds a valid option then argument must be missing.
if (optopt && (strchr(shortopts, optopt) != NULL)) {
printout(LOG_CRIT, "=======> ARGUMENT REQUIRED FOR OPTION: %s <=======\n\n",arg+2);
} else {
printout(LOG_CRIT, "=======> UNRECOGNIZED OPTION: %s <=======\n\n",arg+2);
}
Usage(); Usage();
exit(-1); exit(-1);
}
#endif #endif
if (optopt) {
// Iff optopt holds a valid option then argument must be missing.
if (strchr(shortopts, optopt) != NULL){
printout(LOG_CRIT, "=======> ARGUMENT REQUIRED FOR OPTION: %c <=======\n\n",optopt);
} else {
printout(LOG_CRIT, "=======> UNRECOGNIZED OPTION: %c <=======\n\n",optopt);
}
Usage();
exit(-1);
} }
printhead();
Usage(); Usage();
exit(0); exit(0);
} }
} }
// print header // print header
printhead(); printhead();
return; return;
......
...@@ -34,7 +34,6 @@ monitor. ...@@ -34,7 +34,6 @@ monitor.
# HERE IS A LIST OF DIRECTIVES FOR THIS CONFIGURATION FILE # HERE IS A LIST OF DIRECTIVES FOR THIS CONFIGURATION FILE
# -A Device is an ATA device # -A Device is an ATA device
# -S Device is a SCSI device # -S Device is a SCSI device
# -C N Check disks every N seconds. N must be 10 or greater
# -P Ignore lack of SMART (for disks before ATA-3 Rev 4) # -P Ignore lack of SMART (for disks before ATA-3 Rev 4)
# -T N Automatic Offline Testing. N=1: enable, N=0: disable # -T N Automatic Offline Testing. N=1: enable, N=0: disable
# -s N Attribute Autosave. N=1: enable, N=0: disable # -s N Attribute Autosave. N=1: enable, N=0: disable
......
\# Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net> \# Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net>
\# \#
\# $Id: smartd.conf.5,v 1.14 2002/12/03 23:29:21 pjwilliams Exp $ \# $Id: smartd.conf.5,v 1.15 2002/12/29 01:10:42 pjwilliams Exp $
\# \#
\# This program is free software; you can redistribute it and/or modify it \# This program is free software; you can redistribute it and/or modify it
\# under the terms of the GNU General Public License as published by the Free \# under the terms of the GNU General Public License as published by the Free
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
\# Research Center), Jack Baskin School of Engineering, University of \# Research Center), Jack Baskin School of Engineering, University of
\# California, Santa Cruz. http://ssrc.soe.ucsc.edu/ \# California, Santa Cruz. http://ssrc.soe.ucsc.edu/
\# \#
.TH SMARTD.CONF 5 "$Date: 2002/12/03 23:29:21 $" "smartmontools-5.0" .TH SMARTD.CONF 5 "$Date: 2002/12/29 01:10:42 $" "smartmontools-5.0"
.SH NAME .SH NAME
smartd.conf \- S.M.A.R.T. Monitoring Daemon Configuration File smartd.conf \- S.M.A.R.T. Monitoring Daemon Configuration File
...@@ -160,7 +160,7 @@ possible. ...@@ -160,7 +160,7 @@ possible.
.B If a SCSI disk is listed, .B If a SCSI disk is listed,
it will be monitored at the only implemented level: roughly equivalent it will be monitored at the only implemented level: roughly equivalent
to using the '\-c' option for an ATA disk. So with the exception of '\-S', '\-C', '\-M', and '\-m', to using the '\-c' option for an ATA disk. So with the exception of '\-S', '\-M', and '\-m',
the Directives below are ignored for SCSI the Directives below are ignored for SCSI
disks. For SCSI disks, the '\-M' Directive sends a warning email if disks. For SCSI disks, the '\-M' Directive sends a warning email if
the SMART status indicates a disk failure or problem. the SMART status indicates a disk failure or problem.
...@@ -182,33 +182,6 @@ device names like /dev/hda or /dev/sdb. If ...@@ -182,33 +182,6 @@ device names like /dev/hda or /dev/sdb. If
can't guess from this sixth character, then it will simply try to can't guess from this sixth character, then it will simply try to
access the device using first ATA and then SCSI ioctl()s. access the device using first ATA and then SCSI ioctl()s.
.TP .TP
.B \-C <N>
This sets the time in between disk checks to be
.B <N>
seconds apart, where N is a decimal integer. Note that although you can give this Directive
multiple times on different lines of the configuration file, only the
final value that is given is used. That final value applies to all the disks.
The default value of
.B <N>
is 1800 sec, and the minimum allowed value is
ten seconds. The maximum value is 2^31-1 seconds.
Note that the superuser can make
.B smartd
check the status of the disks at any time by sending it the
.B SIGHUP
signal, for example with the command:
.nf
.B kill -SIGUSR1 <pid>
.fi
where
.B <pid>
is the process id number of smartd. One may also use:
.nf
.B killall -USR1 smartd
.fi
for the same purpose.
.TP
.B \-P .B \-P
Permissive: Even if the disk appears to lack SMART capabilities, try Permissive: Even if the disk appears to lack SMART capabilities, try
to monitor it anyway. This may be required for some old disks (prior to monitor it anyway. This may be required for some old disks (prior
...@@ -470,4 +443,4 @@ SEE ALSO: ...@@ -470,4 +443,4 @@ SEE ALSO:
.SH .SH
CVS ID OF THIS PAGE: CVS ID OF THIS PAGE:
$Id: smartd.conf.5,v 1.14 2002/12/03 23:29:21 pjwilliams Exp $ $Id: smartd.conf.5,v 1.15 2002/12/29 01:10:42 pjwilliams Exp $
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,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.88 2002/12/16 12:27:00 ballen4705 Exp $" const char *CVSid6="$Id: smartd.cpp,v 1.89 2002/12/29 01:10:42 pjwilliams 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.
...@@ -318,7 +318,6 @@ void Directives() { ...@@ -318,7 +318,6 @@ void Directives() {
printout(LOG_INFO,"Configuration file Directives (following device name):\n"); printout(LOG_INFO,"Configuration file Directives (following device name):\n");
printout(LOG_INFO," -A Device is an ATA device\n"); printout(LOG_INFO," -A Device is an ATA device\n");
printout(LOG_INFO," -S Device is a SCSI device\n"); printout(LOG_INFO," -S Device is a SCSI device\n");
printout(LOG_INFO," -C N Check disks once every N seconds, where N>=10.\n");
printout(LOG_INFO," -P Permissive, ignore apparent lack of SMART.\n"); printout(LOG_INFO," -P Permissive, ignore apparent lack of SMART.\n");
printout(LOG_INFO," -T N Automatic offline tests. N=0: Disable, 1: Enable.\n"); printout(LOG_INFO," -T N Automatic offline tests. N=0: Disable, 1: Enable.\n");
printout(LOG_INFO," -s N Attribute Autosave. N=0: Disable, 1: Enable.\n"); printout(LOG_INFO," -s N Attribute Autosave. N=0: Disable, 1: Enable.\n");
...@@ -337,24 +336,26 @@ void Directives() { ...@@ -337,24 +336,26 @@ void Directives() {
printout(LOG_INFO," # Comment: text after a hash sign is ignored\n"); printout(LOG_INFO," # Comment: text after a hash sign is ignored\n");
printout(LOG_INFO," \\ Line continuation character\n"); printout(LOG_INFO," \\ Line continuation character\n");
printout(LOG_INFO,"Attribute ID is a decimal integer 1 <= ID <= 255\n"); printout(LOG_INFO,"Attribute ID is a decimal integer 1 <= ID <= 255\n");
printout(LOG_INFO,"SCSI devices: only -S, -C, -M, and -m Directives allowed.\n"); printout(LOG_INFO,"SCSI devices: only -S, -M, and -m Directives allowed.\n");
printout(LOG_INFO,"Example: /dev/hda -a\n"); printout(LOG_INFO,"Example: /dev/hda -a\n");
return; return;
} }
/* prints help information for command syntax */ /* prints help information for command syntax */
void Usage (void){ void Usage (void){
printout(LOG_INFO,"Usage: smartd [options]\n\n");
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
printout(LOG_INFO,"Usage: smartd [-XVh] [--debug] [--version] [--help]\n\n");
printout(LOG_INFO,"Command Line Options:\n"); printout(LOG_INFO,"Command Line Options:\n");
printout(LOG_INFO," -X, --debug\n Start smartd in debug mode\n\n"); printout(LOG_INFO," -X, --debug\n Start smartd in debug mode\n\n");
printout(LOG_INFO," -i N, --interval=N\n");
printout(LOG_INFO," Set interval between disk checks to N seconds, where N >= 10\n\n");
printout(LOG_INFO," -V, --version, --license, --copyright\n"); printout(LOG_INFO," -V, --version, --license, --copyright\n");
printout(LOG_INFO," Print License, Copyright, and version information\n\n"); printout(LOG_INFO," Print License, Copyright, and version information\n\n");
printout(LOG_INFO," -h, -?, --help, --usage\n Display this help and exit\n\n"); printout(LOG_INFO," -h, -?, --help, --usage\n Display this help and exit\n\n");
#else #else
printout(LOG_INFO,"Usage: smartd [-XVh]\n\n");
printout(LOG_INFO,"Command Line Options:\n"); printout(LOG_INFO,"Command Line Options:\n");
printout(LOG_INFO," -X Start smartd in debug mode\n"); printout(LOG_INFO," -X Start smartd in debug mode\n");
printout(LOG_INFO," -i N Set interval between disk checks to N seconds, where N >= 10\n");
printout(LOG_INFO," -V Print License, Copyright, and version information\n"); printout(LOG_INFO," -V Print License, Copyright, and version information\n");
printout(LOG_INFO," -h Display this help and exit\n"); printout(LOG_INFO," -h Display this help and exit\n");
printout(LOG_INFO," -? Same as -h\n"); printout(LOG_INFO," -? Same as -h\n");
...@@ -1067,10 +1068,6 @@ int parsetoken(char *token,cfgfile *cfg){ ...@@ -1067,10 +1068,6 @@ int parsetoken(char *token,cfgfile *cfg){
val=inttoken(arg=strtok(NULL,delim), name, token, lineno, CONFIGFILE, 1, 255); val=inttoken(arg=strtok(NULL,delim), name, token, lineno, CONFIGFILE, 1, 255);
isattoff(val,cfg->trackatt,1); isattoff(val,cfg->trackatt,1);
break; break;
case 'C':
// period (time interval) for checking
checktime=inttoken(arg=strtok(NULL,delim), name, token, lineno, CONFIGFILE, 10, INT_MAX);
break;
case 'M': case 'M':
// send email to address that follows // send email to address that follows
arg=strtok(NULL,delim); arg=strtok(NULL,delim);
...@@ -1325,9 +1322,14 @@ void ParseOpts(int argc, char **argv){ ...@@ -1325,9 +1322,14 @@ void ParseOpts(int argc, char **argv){
extern char *optarg; extern char *optarg;
extern int optopt, optind, opterr; extern int optopt, optind, opterr;
int optchar; int optchar;
char *tailptr;
long lchecktime;
const char *shortopts = "Xi:Vh?";
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
struct option long_options[] = { char *arg;
struct option longopts[] = {
{ "debug", no_argument, 0, 'X' }, { "debug", no_argument, 0, 'X' },
{ "interval", required_argument, 0, 'i' },
{ "version", no_argument, 0, 'V' }, { "version", no_argument, 0, 'V' },
{ "license", no_argument, 0, 'V' }, { "license", no_argument, 0, 'V' },
{ "copyright", no_argument, 0, 'V' }, { "copyright", no_argument, 0, 'V' },
...@@ -1341,14 +1343,29 @@ void ParseOpts(int argc, char **argv){ ...@@ -1341,14 +1343,29 @@ void ParseOpts(int argc, char **argv){
// Parse input options: // Parse input options:
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
while (-1 != (optchar = getopt_long(argc, argv, "XVh?", long_options, NULL))){ while (-1 != (optchar = getopt_long(argc, argv, shortopts, longopts, NULL))){
#else #else
while (-1 != (optchar = getopt(argc, argv, "XVh?"))){ while (-1 != (optchar = getopt(argc, argv, shortopts))){
#endif #endif
switch(optchar) { switch(optchar) {
case 'X': case 'X':
debugmode = TRUE; debugmode = TRUE;
break; break;
case 'i':
// Period (time interval) for checking
// strtol will set errno in the event of overflow, so we'll check it.
errno = 0;
lchecktime = strtol(optarg, &tailptr, 10);
if (*tailptr != '\0' || lchecktime < 10 || lchecktime > INT_MAX || errno) {
debugmode=1;
printhead();
printout(LOG_CRIT, "======> INVALID INTERVAL: %s <=======\n", optarg);
printout(LOG_CRIT, "======> INTERVAL MUST BE INTEGER BETWEEN %d AND %d <=======\n", 10, INT_MAX);
Usage();
exit(-1);
}
checktime = (int)lchecktime;
break;
case 'V': case 'V':
PrintCopyleft(); PrintCopyleft();
exit(0); exit(0);
...@@ -1357,25 +1374,36 @@ void ParseOpts(int argc, char **argv){ ...@@ -1357,25 +1374,36 @@ void ParseOpts(int argc, char **argv){
case 'h': case 'h':
default: default:
debugmode=1; debugmode=1;
if (optopt) {
printhead(); printhead();
printout(LOG_CRIT,"=======> UNRECOGNIZED OPTION: %c <======= \n\n",optopt);
Usage();
exit(-1);
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
} else if (optchar == '?' && argv[optind-1][1] == '-') { // Point arg to the argument in which this option was found.
printhead(); arg = argv[optind-1];
printout(LOG_CRIT,"=======> UNRECOGNIZED OPTION: %s <======= \n\n",argv[optind-1]+2); // Check whether the option is a long option that doesn't map to -h.
if (arg[1] == '-' && optchar != 'h') {
// Iff optopt holds a valid option then argument must be missing.
if (optopt && (strchr(shortopts, optopt) != NULL)) {
printout(LOG_CRIT, "=======> ARGUMENT REQUIRED FOR OPTION: %s <=======\n\n",arg+2);
} else {
printout(LOG_CRIT, "=======> UNRECOGNIZED OPTION: %s <=======\n\n",arg+2);
}
Usage(); Usage();
exit(-1); exit(-1);
}
#endif #endif
if (optopt) {
// Iff optopt holds a valid option then argument must be missing.
if (strchr(shortopts, optopt) != NULL){
printout(LOG_CRIT, "=======> ARGUMENT REQUIRED FOR OPTION: %c <=======\n\n",optopt);
} else {
printout(LOG_CRIT, "=======> UNRECOGNIZED OPTION: %c <=======\n\n",optopt);
}
Usage();
exit(-1);
} }
printhead();
Usage(); Usage();
exit(0); exit(0);
} }
} }
// print header // print header
printhead(); printhead();
return; return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment