From 7291f10b081eeca96bce96d9e6045e13c43a6dbc Mon Sep 17 00:00:00 2001
From: ballen4705 <ballen4705@4ea69e1a-61f1-4043-bf83-b5c94c648137>
Date: Sun, 10 Nov 2002 21:54:19 +0000
Subject: [PATCH] Added -P directive to smartd for Pre ATA 3 Rev 4 disks. 
 These disks may lack the SMART capability bit in the IDENFITY DEVICE
 structure.

git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@235 4ea69e1a-61f1-4043-bf83-b5c94c648137
---
 sm5/CHANGELOG     | 13 ++++++++++++-
 sm5/VERSION       |  2 +-
 sm5/smartd.8      | 17 ++++++++++++++---
 sm5/smartd.c      | 26 ++++++++++++++++++++++----
 sm5/smartd.conf   |  1 +
 sm5/smartd.conf.5 | 17 ++++++++++++++---
 sm5/smartd.cpp    | 26 ++++++++++++++++++++++----
 sm5/smartd.h      |  4 +++-
 8 files changed, 89 insertions(+), 17 deletions(-)

diff --git a/sm5/CHANGELOG b/sm5/CHANGELOG
index bba73c91a..49a3e9bff 100644
--- a/sm5/CHANGELOG
+++ b/sm5/CHANGELOG
@@ -1,6 +1,6 @@
 CHANGELOG for smartmontools
 
-$Id: CHANGELOG,v 1.40 2002/11/07 21:51:34 ballen4705 Exp $
+$Id: CHANGELOG,v 1.41 2002/11/10 21:54:19 ballen4705 Exp $
 
 Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net>
 
@@ -25,6 +25,17 @@ NOTES FOR FUTURE RELEASES: see TODO file.
 
 CURRENT RELEASE (see VERSION file in this directory):
 
+  Started impementing send-mail-on-error for smartd; not yet enabled.
+
+  Added -P (Permissive) Directive to smartd.conf file to allow SMART
+  monitoring of pre-ATA-3 Rev 4 disks that have SMART but do not have
+  a SMART capability bit.
+ 
+  Removed charset encodings from smartmontools.spec file for non-English
+  fields.
+
+smartmontools-5.0.32
+
   Added manual page smartd.conf.5 for configuration file.
 
   smartctl: Missing ANSI prototype in failuretest(); fixed.
diff --git a/sm5/VERSION b/sm5/VERSION
index 8f92bfdd4..7facc8993 100644
--- a/sm5/VERSION
+++ b/sm5/VERSION
@@ -1 +1 @@
-35
+36
diff --git a/sm5/smartd.8 b/sm5/smartd.8
index b726e6405..bde0b11f6 100644
--- a/sm5/smartd.8
+++ b/sm5/smartd.8
@@ -1,6 +1,6 @@
 \# Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net>
 \# 
-\# $Id: smartd.8,v 1.23 2002/11/07 21:51:34 ballen4705 Exp $
+\# $Id: smartd.8,v 1.24 2002/11/10 21:54:19 ballen4705 Exp $
 \#
 \# 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
@@ -16,7 +16,7 @@
 \# Research Center), Jack Baskin School of Engineering, University of
 \# California, Santa Cruz. http://ssrc.soe.ucsc.edu/
 \#
-.TH SMARTD 8  "$Date: 2002/11/07 21:51:34 $" "smartmontools-5.0"
+.TH SMARTD 8  "$Date: 2002/11/10 21:54:19 $" "smartmontools-5.0"
 .SH NAME
 smartd \- S.M.A.R.T. Daemon
 .SH SYNOPSIS
@@ -175,6 +175,7 @@ configuration file in
 For security, the configuration file should not be writable by anyone
 but root. The syntax of the file is as follows:
 
+.IP
 There should be one device listed per line, although you may have
 lines that are entirely comments or white space.
 
@@ -184,6 +185,8 @@ taken to be a comment, and ignored.
 Lines may be continued by using a backslash (\(rs) as the last
 non-whitespace or non-comment item on a line.
 
+.PP 0
+.fi
 Here is an example configuration file.  It's for illustrative purposes
 only; please don't copy it onto your system without reading to the end
 of the
@@ -279,6 +282,14 @@ The default value of
 is 1800 sec, and the minimum allowed value is
 ten seconds.
 .TP
+.B \-P
+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 ATA-3 revision 4) that implemented SMART before the SMART standards
+were incorporated into the ATA/ATAPI Specifications.  [Please see the
+.B smartctl \-P
+command-line option.]
+.TP
 .B \-c
 Check: Will check the SMART status of the disk.  If any Prefailure
 Attributes are less than or equal to their threshold values, then disk
@@ -503,4 +514,4 @@ Please let us know if there is an on\-line source for this document.
 
 .SH
 CVS ID OF THIS PAGE:
-$Id: smartd.8,v 1.23 2002/11/07 21:51:34 ballen4705 Exp $
+$Id: smartd.8,v 1.24 2002/11/10 21:54:19 ballen4705 Exp $
diff --git a/sm5/smartd.c b/sm5/smartd.c
index cc0cadbb8..f077217f2 100644
--- a/sm5/smartd.c
+++ b/sm5/smartd.c
@@ -45,7 +45,7 @@
 
 // CVS ID strings
 extern const char *CVSid1, *CVSid2;
-const char *CVSid6="$Id: smartd.c,v 1.53 2002/11/08 10:51:51 ballen4705 Exp $" 
+const char *CVSid6="$Id: smartd.c,v 1.54 2002/11/10 21:54:19 ballen4705 Exp $" 
 CVSID1 CVSID2 CVSID3 CVSID4 CVSID7;
 
 // global variable used for control of printing, passing arguments, etc.
@@ -331,9 +331,23 @@ int atadevicescan2(atadevices_t *devices, cfgfile *cfg){
   
   // Get drive identity structure
   // May want to add options to enable autosave, automatic online testing
-  if (ataReadHDIdentity (fd,&drive) || !ataSmartSupport(&drive) || ataEnableSmart(fd)){
-    // device exists, but not able to do SMART
-    printout(LOG_INFO,"Device: %s, not SMART capable, or couldn't enable SMART\n",device);
+  if (ataReadHDIdentity (fd,&drive)){
+    // Unable to read Identity structure
+    printout(LOG_INFO,"Device: %s, unable to read Device Identity Structure\n",device);
+    close(fd);
+    return 2; 
+  }
+  
+  if (!cfg->permissive && !ataSmartSupport(&drive)){
+    // SMART not supported
+    printout(LOG_INFO,"Device: %s, appears to lack SMART, use '-P' Directive to try anyway.\n",device);
+    close(fd);
+    return 2; 
+  }
+
+ if (ataEnableSmart(fd)){
+    // Enable SMART command has failed
+    printout(LOG_INFO,"Device: %s, could not enable SMART capability\n",device);
     close(fd);
     return 2; 
   }
@@ -774,6 +788,10 @@ int parsetoken(char *token,cfgfile *cfg){
     char *endptr;
     int val;
     
+  case 'P':
+    // Permissive mode; ignore errors from Mandatory SMART commands
+    cfg->permissive=1;
+    break;
   case 'A':
     // ATA device
     cfg->tryata=1;
diff --git a/sm5/smartd.conf b/sm5/smartd.conf
index 461765b50..4336bd731 100644
--- a/sm5/smartd.conf
+++ b/sm5/smartd.conf
@@ -34,6 +34,7 @@ DEVICESCAN
 #   -A    Device is an ATA 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)
 #   -c    Monitor SMART Health Status
 #   -l    Monitor SMART Error Log for changes
 #   -L    Monitor SMART Self-Test Log for new errors
diff --git a/sm5/smartd.conf.5 b/sm5/smartd.conf.5
index ea930d81d..e3500eacd 100644
--- a/sm5/smartd.conf.5
+++ b/sm5/smartd.conf.5
@@ -1,6 +1,6 @@
 \# Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net>
 \# 
-\# $Id: smartd.conf.5,v 1.1 2002/11/08 12:00:05 ballen4705 Exp $
+\# $Id: smartd.conf.5,v 1.2 2002/11/10 21:54:19 ballen4705 Exp $
 \#
 \# 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
@@ -16,7 +16,7 @@
 \# Research Center), Jack Baskin School of Engineering, University of
 \# California, Santa Cruz. http://ssrc.soe.ucsc.edu/
 \#
-.TH SMARTD.CONF 5  "$Date: 2002/11/08 12:00:05 $" "smartmontools-5.0"
+.TH SMARTD.CONF 5  "$Date: 2002/11/10 21:54:19 $" "smartmontools-5.0"
 .SH NAME
 /etc/smartd.conf \- S.M.A.R.T. Monitoring Daemon Configuration File
 
@@ -72,6 +72,7 @@ configuration file in
 For security, the configuration file should not be writable by anyone
 but root. The syntax of the file is as follows:
 
+.IP
 There should be one device listed per line, although you may have
 lines that are entirely comments or white space.
 
@@ -81,6 +82,8 @@ taken to be a comment, and ignored.
 Lines may be continued by using a backslash (\(rs) as the last
 non-whitespace or non-comment item on a line.
 
+.PP 0
+.fi
 Here is an example configuration file.  It's for illustrative purposes
 only; please don't copy it onto your system without reading to the end
 of the
@@ -176,6 +179,14 @@ The default value of
 is 1800 sec, and the minimum allowed value is
 ten seconds.
 .TP
+.B \-P
+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 ATA-3 revision 4) that implemented SMART before the SMART standards
+were incorporated into the ATA/ATAPI Specifications.  [Please see the
+.B smartctl \-P
+command-line option.]
+.TP
 .B \-c
 Check: Will check the SMART status of the disk.  If any Prefailure
 Attributes are less than or equal to their threshold values, then disk
@@ -330,4 +341,4 @@ SEE ALSO:
 
 .SH
 CVS ID OF THIS PAGE:
-$Id: smartd.conf.5,v 1.1 2002/11/08 12:00:05 ballen4705 Exp $
+$Id: smartd.conf.5,v 1.2 2002/11/10 21:54:19 ballen4705 Exp $
diff --git a/sm5/smartd.cpp b/sm5/smartd.cpp
index c16c05e9e..7de54698a 100644
--- a/sm5/smartd.cpp
+++ b/sm5/smartd.cpp
@@ -45,7 +45,7 @@
 
 // CVS ID strings
 extern const char *CVSid1, *CVSid2;
-const char *CVSid6="$Id: smartd.cpp,v 1.53 2002/11/08 10:51:51 ballen4705 Exp $" 
+const char *CVSid6="$Id: smartd.cpp,v 1.54 2002/11/10 21:54:19 ballen4705 Exp $" 
 CVSID1 CVSID2 CVSID3 CVSID4 CVSID7;
 
 // global variable used for control of printing, passing arguments, etc.
@@ -331,9 +331,23 @@ int atadevicescan2(atadevices_t *devices, cfgfile *cfg){
   
   // Get drive identity structure
   // May want to add options to enable autosave, automatic online testing
-  if (ataReadHDIdentity (fd,&drive) || !ataSmartSupport(&drive) || ataEnableSmart(fd)){
-    // device exists, but not able to do SMART
-    printout(LOG_INFO,"Device: %s, not SMART capable, or couldn't enable SMART\n",device);
+  if (ataReadHDIdentity (fd,&drive)){
+    // Unable to read Identity structure
+    printout(LOG_INFO,"Device: %s, unable to read Device Identity Structure\n",device);
+    close(fd);
+    return 2; 
+  }
+  
+  if (!cfg->permissive && !ataSmartSupport(&drive)){
+    // SMART not supported
+    printout(LOG_INFO,"Device: %s, appears to lack SMART, use '-P' Directive to try anyway.\n",device);
+    close(fd);
+    return 2; 
+  }
+
+ if (ataEnableSmart(fd)){
+    // Enable SMART command has failed
+    printout(LOG_INFO,"Device: %s, could not enable SMART capability\n",device);
     close(fd);
     return 2; 
   }
@@ -774,6 +788,10 @@ int parsetoken(char *token,cfgfile *cfg){
     char *endptr;
     int val;
     
+  case 'P':
+    // Permissive mode; ignore errors from Mandatory SMART commands
+    cfg->permissive=1;
+    break;
   case 'A':
     // ATA device
     cfg->tryata=1;
diff --git a/sm5/smartd.h b/sm5/smartd.h
index 3577ec823..02ee37c08 100644
--- a/sm5/smartd.h
+++ b/sm5/smartd.h
@@ -23,7 +23,7 @@
  */
 
 #ifndef CVSID7
-#define CVSID7 "$Id: smartd.h,v 1.18 2002/11/08 10:51:51 ballen4705 Exp $\n"
+#define CVSID7 "$Id: smartd.h,v 1.19 2002/11/10 21:54:19 ballen4705 Exp $\n"
 #endif
 
 // Configuration file
@@ -94,6 +94,8 @@ typedef struct configfile_s {
   char usage;
   char selftest;
   char errorlog;
+  // Should we ignore missing capabilities/SMART errors
+  char permissive;
   // mailing information for each of the previous error types
   mailinfo *mailinfop[6];
   // counts of ata and self-test errors.  Perhaps ought to be in the
-- 
GitLab