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

smartctl: now can take arbitrary device paths. Better logic for guessing device type.

Will use -n and -N options to over-ride guess if needed.


git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@205 4ea69e1a-61f1-4043-bf83-b5c94c648137
parent 5e39d340
Branches
No related tags found
No related merge requests found
CHANGELOG for smartmontools CHANGELOG for smartmontools
$Id: CHANGELOG,v 1.35 2002/10/31 17:01:14 ballen4705 Exp $ $Id: CHANGELOG,v 1.36 2002/11/04 13:32:08 ballen4705 Exp $
Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net> Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net>
...@@ -25,8 +25,16 @@ NOTES FOR FUTURE RELEASES: see TODO file. ...@@ -25,8 +25,16 @@ NOTES FOR FUTURE RELEASES: see TODO file.
CURRENT RELEASE (see VERSION file in this directory): CURRENT RELEASE (see VERSION file in this directory):
smartmontools-5.0.26 smartmontools-5.0.30
smartctl: added new options -n and -N to force device to be ATA or SCSI
smartctl: no longer dies silently if device path does not start/dev/X
smartctl: now handles arbitrary device paths
smartmontools-5.0.29
Modified .spec file and Makefile to make them more compliant with
the "right" way of doing things.
smartmontools-5.0.26
Fixed typesetting error in man page smartd.8 Fixed typesetting error in man page smartd.8
Removed redundant variable (harmless) from smartd.c Removed redundant variable (harmless) from smartd.c
......
...@@ -90,7 +90,8 @@ Eleven files are installed: ...@@ -90,7 +90,8 @@ Eleven files are installed:
/usr/share/doc/smartmontools-5.0/CHANGELOG [A log of changes. Also see CVS] /usr/share/doc/smartmontools-5.0/CHANGELOG [A log of changes. Also see CVS]
/usr/share/doc/smartmontools-5.0/COPYING [GNU Public License.] /usr/share/doc/smartmontools-5.0/COPYING [GNU Public License.]
/usr/share/doc/smartmontools-5.0/VERSION [Version number] /usr/share/doc/smartmontools-5.0/VERSION [Version number]
/usr/share/doc/smartmontools-5.0/smartd.conf [Sample Configuration file for /etc/] /usr/share/doc/smartmontools-5.0/smartd.conf [Example Configuration file for /etc/]
/etc/smartd.conf.example [Example Configuration file for /etc/]
Source and binary RPM files are available at the website listed above. Source and binary RPM files are available at the website listed above.
......
29 30
\# Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net> \# Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net>
\# \#
\# $Id: smartctl.8,v 1.22 2002/10/29 14:19:10 ballen4705 Exp $ \# $Id: smartctl.8,v 1.23 2002/11/04 13:32:08 ballen4705 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
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
\# at the Concurrent Systems Laboratory (now part of the Storage Systems \# at the Concurrent Systems Laboratory (now part of the Storage Systems
\# 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 SMARTCTL 8 "$Date: 2002/10/29 14:19:10 $" "smartmontools-5.0" .TH SMARTCTL 8 "$Date: 2002/11/04 13:32:08 $" "smartmontools-5.0"
.SH NAME .SH NAME
smartctl \- S.M.A.R.T. control and monitor utility smartctl \- S.M.A.R.T. control and monitor utility
.SH SYNOPSIS .SH SYNOPSIS
...@@ -55,12 +55,21 @@ the options does not matter. ...@@ -55,12 +55,21 @@ the options does not matter.
The second argument is the device to be controlled or The second argument is the device to be controlled or
interrogated. ATA devices use the form "/dev/hd*" and SCSI devices use interrogated. ATA devices use the form "/dev/hd*" and SCSI devices use
the form "/dev/sd*". the form "/dev/sd*". More general paths may also be specified.
.B Smartctl
will attempt to guess the device type. If needed, use the '\-n' and '\-N'
options respectively for specifying ATA and SCSI device type.
SCSI devices only accept the options a,i,c,e,d,O,s,S,x,X,A and V. For SCSI devices only accept the options
SCSI Tape Drives and Changers with TapeAlerts support use the .B a, i, c, e, d, O, s, S, x, X, A, N
devices "/dev/st*" and "/dev/sg*". TapeAlerts devices accept the options and
a,i,c,e,d, and V. .B V.
For SCSI Tape Drives and Changers with TapeAlerts support use
the devices "/dev/st*" and "/dev/sg*". TapeAlerts devices accept the
options
.B a, i, c, e, d, N
and
.B V.
The options are grouped below into several categories. The options are grouped below into several categories.
.B smartctl .B smartctl
...@@ -104,6 +113,16 @@ found is to use the exit status of ...@@ -104,6 +113,16 @@ found is to use the exit status of
All: Prints all parameters for c,i,g,v,t,l,L (for SCSI c,i). This prints all All: Prints all parameters for c,i,g,v,t,l,L (for SCSI c,i). This prints all
S.M.A.R.T. information about the disk. S.M.A.R.T. information about the disk.
.TP .TP
.B n
NotSCSI: Device is an ATA device.
.TP
.B N
NotATA: Device is a SCSI device. If neither this nor the previous
option are specified, then
.B smartctl
will attempt to guess the device type from the device name. You can
use this option or the previous option to over-ride to force the type.
.TP
.B S.M.A.R.T. FEATURE ENABLE/DISABLE COMMANDS: .B S.M.A.R.T. FEATURE ENABLE/DISABLE COMMANDS:
.IP .IP
.B Note: .B Note:
...@@ -471,4 +490,4 @@ Please let us know if there is an on\-line source for this document. ...@@ -471,4 +490,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: smartctl.8,v 1.22 2002/10/29 14:19:10 ballen4705 Exp $ $Id: smartctl.8,v 1.23 2002/11/04 13:32:08 ballen4705 Exp $
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include "extern.h" #include "extern.h"
extern const char *CVSid1, *CVSid2, *CVSid3, *CVSid4; extern const char *CVSid1, *CVSid2, *CVSid3, *CVSid4;
const char* CVSid5="$Id: smartctl.c,v 1.24 2002/10/30 06:02:40 ballen4705 Exp $" const char* CVSid5="$Id: smartctl.c,v 1.25 2002/11/04 13:32:08 ballen4705 Exp $"
CVSID1 CVSID2 CVSID3 CVSID4 CVSID5 CVSID6; CVSID1 CVSID2 CVSID3 CVSID4 CVSID5 CVSID6;
// This is a block containing all the "control variables". We declare // This is a block containing all the "control variables". We declare
...@@ -88,6 +88,8 @@ void Usage ( void){ ...@@ -88,6 +88,8 @@ void Usage ( void){
printf(" %c Show SMART Drive Self Test Log (ATA Only)\n", SMARTSELFTESTLOG); printf(" %c Show SMART Drive Self Test Log (ATA Only)\n", SMARTSELFTESTLOG);
printf(" %c Quiet: only show SMART drive errors (ATA Only)\n", QUIETMODE); printf(" %c Quiet: only show SMART drive errors (ATA Only)\n", QUIETMODE);
printf(" %c Very Quiet: no display, use exit status (ATA Only)\n", VERYQUIETMODE); printf(" %c Very Quiet: no display, use exit status (ATA Only)\n", VERYQUIETMODE);
printf(" %c Device is an ATA device (ATA Only)\n", NOTSCSIDEVICE);
printf(" %c Device is a SCSI device (SCSI Only)\n", NOTATADEVICE);
printf("\nVendor-specific Display Options:\n"); printf("\nVendor-specific Display Options:\n");
printf(" %c Raw Attribute 009 is minutes (ATA Only)\n", SMART009MINUTES); printf(" %c Raw Attribute 009 is minutes (ATA Only)\n", SMART009MINUTES);
printf("\nEnable/Disable Options:\n"); printf("\nEnable/Disable Options:\n");
...@@ -117,10 +119,11 @@ const char opts[] = { ...@@ -117,10 +119,11 @@ const char opts[] = {
SMARTENABLE, SMARTAUTOOFFLINEENABLE, SMARTAUTOOFFLINEDISABLE, SMARTENABLE, SMARTAUTOOFFLINEENABLE, SMARTAUTOOFFLINEDISABLE,
SMARTEXEOFFIMMEDIATE, SMARTSHORTSELFTEST, SMARTEXTENDSELFTEST, SMARTEXEOFFIMMEDIATE, SMARTSHORTSELFTEST, SMARTEXTENDSELFTEST,
SMARTSHORTCAPSELFTEST, SMARTEXTENDCAPSELFTEST, SMARTSELFTESTABORT, SMARTSHORTCAPSELFTEST, SMARTEXTENDCAPSELFTEST, SMARTSELFTESTABORT,
SMARTAUTOSAVEENABLE,SMARTAUTOSAVEDISABLE,PRINTCOPYLEFT,SMART009MINUTES,QUIETMODE,VERYQUIETMODE,'h','?','\0' SMARTAUTOSAVEENABLE,SMARTAUTOSAVEDISABLE,PRINTCOPYLEFT,SMART009MINUTES,
QUIETMODE,VERYQUIETMODE,NOTSCSIDEVICE,NOTATADEVICE,'h','?','\0'
}; };
unsigned char printcopyleft=0; unsigned char printcopyleft=0,tryata=0,tryscsi=0;
/* Takes command options and sets features to be run */ /* Takes command options and sets features to be run */
void ParseOpts (int argc, char** argv){ void ParseOpts (int argc, char** argv){
...@@ -133,6 +136,14 @@ void ParseOpts (int argc, char** argv){ ...@@ -133,6 +136,14 @@ void ParseOpts (int argc, char** argv){
opterr=optopt=0; opterr=optopt=0;
while (-1 != (optchar = getopt(argc, argv, opts))) { while (-1 != (optchar = getopt(argc, argv, opts))) {
switch (optchar){ switch (optchar){
case NOTATADEVICE:
tryata=0;
tryscsi=1;
break;
case NOTSCSIDEVICE:
tryata=1;
tryscsi=0;
break;
case QUIETMODE: case QUIETMODE:
con->quietmode=TRUE; con->quietmode=TRUE;
break; break;
...@@ -283,6 +294,7 @@ int main (int argc, char **argv){ ...@@ -283,6 +294,7 @@ int main (int argc, char **argv){
int fd,retval=0; int fd,retval=0;
char *device; char *device;
atamainctrl control; atamainctrl control;
const char *devroot="/dev/";
// define control block for external functions // define control block for external functions
con=&control; con=&control;
...@@ -304,11 +316,30 @@ int main (int argc, char **argv){ ...@@ -304,11 +316,30 @@ int main (int argc, char **argv){
return FAILDEV; return FAILDEV;
} }
// if necessary, try to guess if this is an ATA or SCSI device
if (!tryata && !tryscsi) {
if (!strncmp(device,devroot,strlen(devroot)) && strlen(device)>5){
if (device[5] == 'h') if (device[5] == 'h')
tryata=1;
if (device[5] == 's')
tryscsi=1;
}
else if (strlen(device)){
if (device[0] == 'h')
tryata=1;
if (device[0] == 's')
tryscsi=1;
}
}
// now call appropriate ATA or SCSI routine
if (tryata)
retval=ataPrintMain(fd); retval=ataPrintMain(fd);
else if (device[5] == 's') else if (tryscsi)
scsiPrintMain (fd); scsiPrintMain (fd);
else { else {
pout("Smartctl: specify if this is an ATA or SCSI device with the -%c or -%c options respectively.\n",
NOTSCSIDEVICE, NOTATADEVICE);
Usage(); Usage();
return FAILCMD; return FAILCMD;
} }
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include "extern.h" #include "extern.h"
extern const char *CVSid1, *CVSid2, *CVSid3, *CVSid4; extern const char *CVSid1, *CVSid2, *CVSid3, *CVSid4;
const char* CVSid5="$Id: smartctl.cpp,v 1.24 2002/10/30 06:02:40 ballen4705 Exp $" const char* CVSid5="$Id: smartctl.cpp,v 1.25 2002/11/04 13:32:08 ballen4705 Exp $"
CVSID1 CVSID2 CVSID3 CVSID4 CVSID5 CVSID6; CVSID1 CVSID2 CVSID3 CVSID4 CVSID5 CVSID6;
// This is a block containing all the "control variables". We declare // This is a block containing all the "control variables". We declare
...@@ -88,6 +88,8 @@ void Usage ( void){ ...@@ -88,6 +88,8 @@ void Usage ( void){
printf(" %c Show SMART Drive Self Test Log (ATA Only)\n", SMARTSELFTESTLOG); printf(" %c Show SMART Drive Self Test Log (ATA Only)\n", SMARTSELFTESTLOG);
printf(" %c Quiet: only show SMART drive errors (ATA Only)\n", QUIETMODE); printf(" %c Quiet: only show SMART drive errors (ATA Only)\n", QUIETMODE);
printf(" %c Very Quiet: no display, use exit status (ATA Only)\n", VERYQUIETMODE); printf(" %c Very Quiet: no display, use exit status (ATA Only)\n", VERYQUIETMODE);
printf(" %c Device is an ATA device (ATA Only)\n", NOTSCSIDEVICE);
printf(" %c Device is a SCSI device (SCSI Only)\n", NOTATADEVICE);
printf("\nVendor-specific Display Options:\n"); printf("\nVendor-specific Display Options:\n");
printf(" %c Raw Attribute 009 is minutes (ATA Only)\n", SMART009MINUTES); printf(" %c Raw Attribute 009 is minutes (ATA Only)\n", SMART009MINUTES);
printf("\nEnable/Disable Options:\n"); printf("\nEnable/Disable Options:\n");
...@@ -117,10 +119,11 @@ const char opts[] = { ...@@ -117,10 +119,11 @@ const char opts[] = {
SMARTENABLE, SMARTAUTOOFFLINEENABLE, SMARTAUTOOFFLINEDISABLE, SMARTENABLE, SMARTAUTOOFFLINEENABLE, SMARTAUTOOFFLINEDISABLE,
SMARTEXEOFFIMMEDIATE, SMARTSHORTSELFTEST, SMARTEXTENDSELFTEST, SMARTEXEOFFIMMEDIATE, SMARTSHORTSELFTEST, SMARTEXTENDSELFTEST,
SMARTSHORTCAPSELFTEST, SMARTEXTENDCAPSELFTEST, SMARTSELFTESTABORT, SMARTSHORTCAPSELFTEST, SMARTEXTENDCAPSELFTEST, SMARTSELFTESTABORT,
SMARTAUTOSAVEENABLE,SMARTAUTOSAVEDISABLE,PRINTCOPYLEFT,SMART009MINUTES,QUIETMODE,VERYQUIETMODE,'h','?','\0' SMARTAUTOSAVEENABLE,SMARTAUTOSAVEDISABLE,PRINTCOPYLEFT,SMART009MINUTES,
QUIETMODE,VERYQUIETMODE,NOTSCSIDEVICE,NOTATADEVICE,'h','?','\0'
}; };
unsigned char printcopyleft=0; unsigned char printcopyleft=0,tryata=0,tryscsi=0;
/* Takes command options and sets features to be run */ /* Takes command options and sets features to be run */
void ParseOpts (int argc, char** argv){ void ParseOpts (int argc, char** argv){
...@@ -133,6 +136,14 @@ void ParseOpts (int argc, char** argv){ ...@@ -133,6 +136,14 @@ void ParseOpts (int argc, char** argv){
opterr=optopt=0; opterr=optopt=0;
while (-1 != (optchar = getopt(argc, argv, opts))) { while (-1 != (optchar = getopt(argc, argv, opts))) {
switch (optchar){ switch (optchar){
case NOTATADEVICE:
tryata=0;
tryscsi=1;
break;
case NOTSCSIDEVICE:
tryata=1;
tryscsi=0;
break;
case QUIETMODE: case QUIETMODE:
con->quietmode=TRUE; con->quietmode=TRUE;
break; break;
...@@ -283,6 +294,7 @@ int main (int argc, char **argv){ ...@@ -283,6 +294,7 @@ int main (int argc, char **argv){
int fd,retval=0; int fd,retval=0;
char *device; char *device;
atamainctrl control; atamainctrl control;
const char *devroot="/dev/";
// define control block for external functions // define control block for external functions
con=&control; con=&control;
...@@ -304,11 +316,30 @@ int main (int argc, char **argv){ ...@@ -304,11 +316,30 @@ int main (int argc, char **argv){
return FAILDEV; return FAILDEV;
} }
// if necessary, try to guess if this is an ATA or SCSI device
if (!tryata && !tryscsi) {
if (!strncmp(device,devroot,strlen(devroot)) && strlen(device)>5){
if (device[5] == 'h') if (device[5] == 'h')
tryata=1;
if (device[5] == 's')
tryscsi=1;
}
else if (strlen(device)){
if (device[0] == 'h')
tryata=1;
if (device[0] == 's')
tryscsi=1;
}
}
// now call appropriate ATA or SCSI routine
if (tryata)
retval=ataPrintMain(fd); retval=ataPrintMain(fd);
else if (device[5] == 's') else if (tryscsi)
scsiPrintMain (fd); scsiPrintMain (fd);
else { else {
pout("Smartctl: specify if this is an ATA or SCSI device with the -%c or -%c options respectively.\n",
NOTSCSIDEVICE, NOTATADEVICE);
Usage(); Usage();
return FAILCMD; return FAILCMD;
} }
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#define __SMARTCTL_H_ #define __SMARTCTL_H_
#ifndef CVSID6 #ifndef CVSID6
#define CVSID6 "$Id: smartctl.h,v 1.10 2002/10/24 07:50:45 ballen4705 Exp $\n" #define CVSID6 "$Id: smartctl.h,v 1.11 2002/11/04 13:32:09 ballen4705 Exp $\n"
#endif #endif
/* Defines for command line options */ /* Defines for command line options */
...@@ -53,6 +53,8 @@ ...@@ -53,6 +53,8 @@
#define SMART009MINUTES 'm' #define SMART009MINUTES 'm'
#define QUIETMODE 'q' #define QUIETMODE 'q'
#define VERYQUIETMODE 'Q' #define VERYQUIETMODE 'Q'
#define NOTATADEVICE 'N'
#define NOTSCSIDEVICE 'n'
/* Boolean Values */ /* Boolean Values */
......
...@@ -20,7 +20,7 @@ Packager: Bruce Allen <smartmontools-support@lists.sourceforge.net> ...@@ -20,7 +20,7 @@ Packager: Bruce Allen <smartmontools-support@lists.sourceforge.net>
# http://ftp1.sourceforge.net/smartmontools/smartmontools-%{version}-%{release}.tar.gz # http://ftp1.sourceforge.net/smartmontools/smartmontools-%{version}-%{release}.tar.gz
# CVS ID of this file is: # CVS ID of this file is:
# $Id: smartmontools.spec,v 1.42 2002/11/04 09:30:12 ballen4705 Exp $ # $Id: smartmontools.spec,v 1.43 2002/11/04 13:32:09 ballen4705 Exp $
# Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net> # Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net>
# Home page: http://smartmontools.sourceforge.net/ # Home page: http://smartmontools.sourceforge.net/
...@@ -140,6 +140,9 @@ fi ...@@ -140,6 +140,9 @@ fi
%define date %(echo `LC_ALL="C" date +"%a %b %d %Y"`) %define date %(echo `LC_ALL="C" date +"%a %b %d %Y"`)
%changelog %changelog
* Mon Nov 4 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net> * Mon Nov 4 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net>
- smartctl: added new options -n and -N to force device to be ATA or SCSI
- smartctl: no longer dies silently if device path does not start/dev/X
- smartctl: now handles arbitrary device paths
- Added additional macros for manual and sbin paths in this SPEC file. - Added additional macros for manual and sbin paths in this SPEC file.
- Modified Makefile to install /etc/smartd.conf, but without overwriting existing config file - Modified Makefile to install /etc/smartd.conf, but without overwriting existing config file
- Modified this specfile to do the same, and to not remove any files that it did not install - Modified this specfile to do the same, and to not remove any files that it did not install
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment