From 311358a0f2d51803474518d767ce60873079faed Mon Sep 17 00:00:00 2001
From: ballen4705 <ballen4705@4ea69e1a-61f1-4043-bf83-b5c94c648137>
Date: Thu, 24 Oct 2002 08:46:03 +0000
Subject: [PATCH] Quiet option (-q) no longer prints all error log entries,
 just the number of entries and the times at which they occured.

git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@98 4ea69e1a-61f1-4043-bf83-b5c94c648137
---
 sm5/VERSION      |  2 +-
 sm5/ataprint.c   | 35 ++++++++++++++++++++---------------
 sm5/ataprint.cpp | 35 ++++++++++++++++++++---------------
 sm5/smartctl.8   | 20 +++++++++++---------
 sm5/smartctl.c   |  8 +++++---
 sm5/smartctl.cpp |  8 +++++---
 6 files changed, 62 insertions(+), 46 deletions(-)

diff --git a/sm5/VERSION b/sm5/VERSION
index b4de39476..48082f72f 100644
--- a/sm5/VERSION
+++ b/sm5/VERSION
@@ -1 +1 @@
-11
+12
diff --git a/sm5/ataprint.c b/sm5/ataprint.c
index af86a6b77..aeb221a36 100644
--- a/sm5/ataprint.c
+++ b/sm5/ataprint.c
@@ -28,7 +28,7 @@
 #include "smartctl.h"
 #include "extern.h"
 
-const char *CVSid4="$Id: ataprint.c,v 1.31 2002/10/24 07:50:45 ballen4705 Exp $"
+const char *CVSid4="$Id: ataprint.c,v 1.32 2002/10/24 08:46:03 ballen4705 Exp $"
 CVSID2 CVSID3 CVSID6;
 
 // Function for printing ASCII byte-swapped strings, skipping white
@@ -514,7 +514,7 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog data){
   QUIETON;
   // if log pointer out of range, return
   if ( data.error_log_pointer>5 ){
-    pout("Invalid Error log index = %02x (T13/1321D rev 1c"
+    pout("Invalid Error Log index = %02x (T13/1321D rev 1c"
 	 "Section 8.41.6.8.2.2 gives valid range from 1 to 5)\n\n",
 	 data.error_log_pointer);
     return;
@@ -522,11 +522,11 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog data){
   
   // starting printing error log info
   if (data.ata_error_count<=5)
-    pout ( "ATA Error Count:y %u\n", data.ata_error_count);
+    pout ( "ATA Error Count: %u\n", data.ata_error_count);
   else
-    pout ( "ATA Error Count: %u (only the most recent five errors are shown below)\n",
+    pout ( "ATA Error Count: %u (device log contains only the most recent five errors)\n",
 	   data.ata_error_count);
-  
+  QUIETOFF;
   pout("\tDCR = Device Control Register\n");
   pout("\tFR  = Features Register\n");
   pout("\tSC  = Sector Count Register\n");
@@ -557,10 +557,11 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog data){
       case 0x04: msgstate="doing SMART off-line or self test"; break;
       default:   msgstate="in a vendor specific or reserved state";
       }
-      pout("Error Log Structure %i:\n",5-k);
       // See table 42 of ATA5 spec
-      pout("Error occurred at disk power-on lifetime: %u hours\n",
-	     data.errorlog_struct[i].error_struct.timestamp);
+      QUIETON;
+      pout("Error %i occurred at disk power-on lifetime: %u hours\n",
+	     5-k,data.errorlog_struct[i].error_struct.timestamp);
+      QUIETOFF;
       pout("When the command that caused the error occurred, the device was %s.\n",msgstate);
       pout("After command completion occurred, registers were:\n");
       pout("ER:%02x SC:%02x SN:%02x CL:%02x CH:%02x D/H:%02x ST:%02x\n",
@@ -593,6 +594,9 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog data){
       pout("\n");
     }
   }
+  QUIETON;
+  if (quietmode)
+    pout("\n");
   QUIETOFF;
   return;  
 }
@@ -666,6 +670,8 @@ int ataPrintSmartSelfTestlog (struct ata_smart_selftestlog data,int allentries){
 	     percent,log->timestamp,firstlba);
     }
   }
+  if (!allentries && retval)
+    pout("\n");
   return retval;
 }
 
@@ -952,15 +958,14 @@ int ataPrintMain (int fd){
 	     "Drive failure expected in less than 24 hours. SAVE ALL DATA.\n");
       QUIETOFF;
       if (ataCheckSmart(smartval, smartthres,1)){
-	QUIETON;
 	returnval|=FAILATTR;
 	if (smartvendorattrib)
 	  pout("See vendor-specific Attribute list for failed Attributes.\n\n");
-	else
-	  {
-	    pout("Failed Attributes:\n");
-	    PrintSmartAttribWithThres(smartval, smartthres,1);
-	  }
+	else {
+	  QUIETON;
+	  pout("Failed Attributes:\n");
+	  PrintSmartAttribWithThres(smartval, smartthres,1);
+	}
       }
       else
 	pout("No failed Attributes found.\n\n");   
@@ -970,10 +975,10 @@ int ataPrintMain (int fd){
     else {
       pout("SMART overall-health self-assessment test result: PASSED\n");
       if (ataCheckSmart(smartval, smartthres,0)){
-	QUIETON;
 	if (smartvendorattrib)
 	  pout("See vendor-specific Attribute list for marginal Attributes.\n\n");
 	else {
+	  QUIETON;
 	  pout("Please note the following marginal attributes:\n");
 	  PrintSmartAttribWithThres(smartval, smartthres,2);
 	} 
diff --git a/sm5/ataprint.cpp b/sm5/ataprint.cpp
index 358b15d53..7e4c749e8 100644
--- a/sm5/ataprint.cpp
+++ b/sm5/ataprint.cpp
@@ -28,7 +28,7 @@
 #include "smartctl.h"
 #include "extern.h"
 
-const char *CVSid4="$Id: ataprint.cpp,v 1.31 2002/10/24 07:50:45 ballen4705 Exp $"
+const char *CVSid4="$Id: ataprint.cpp,v 1.32 2002/10/24 08:46:03 ballen4705 Exp $"
 CVSID2 CVSID3 CVSID6;
 
 // Function for printing ASCII byte-swapped strings, skipping white
@@ -514,7 +514,7 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog data){
   QUIETON;
   // if log pointer out of range, return
   if ( data.error_log_pointer>5 ){
-    pout("Invalid Error log index = %02x (T13/1321D rev 1c"
+    pout("Invalid Error Log index = %02x (T13/1321D rev 1c"
 	 "Section 8.41.6.8.2.2 gives valid range from 1 to 5)\n\n",
 	 data.error_log_pointer);
     return;
@@ -522,11 +522,11 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog data){
   
   // starting printing error log info
   if (data.ata_error_count<=5)
-    pout ( "ATA Error Count:y %u\n", data.ata_error_count);
+    pout ( "ATA Error Count: %u\n", data.ata_error_count);
   else
-    pout ( "ATA Error Count: %u (only the most recent five errors are shown below)\n",
+    pout ( "ATA Error Count: %u (device log contains only the most recent five errors)\n",
 	   data.ata_error_count);
-  
+  QUIETOFF;
   pout("\tDCR = Device Control Register\n");
   pout("\tFR  = Features Register\n");
   pout("\tSC  = Sector Count Register\n");
@@ -557,10 +557,11 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog data){
       case 0x04: msgstate="doing SMART off-line or self test"; break;
       default:   msgstate="in a vendor specific or reserved state";
       }
-      pout("Error Log Structure %i:\n",5-k);
       // See table 42 of ATA5 spec
-      pout("Error occurred at disk power-on lifetime: %u hours\n",
-	     data.errorlog_struct[i].error_struct.timestamp);
+      QUIETON;
+      pout("Error %i occurred at disk power-on lifetime: %u hours\n",
+	     5-k,data.errorlog_struct[i].error_struct.timestamp);
+      QUIETOFF;
       pout("When the command that caused the error occurred, the device was %s.\n",msgstate);
       pout("After command completion occurred, registers were:\n");
       pout("ER:%02x SC:%02x SN:%02x CL:%02x CH:%02x D/H:%02x ST:%02x\n",
@@ -593,6 +594,9 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog data){
       pout("\n");
     }
   }
+  QUIETON;
+  if (quietmode)
+    pout("\n");
   QUIETOFF;
   return;  
 }
@@ -666,6 +670,8 @@ int ataPrintSmartSelfTestlog (struct ata_smart_selftestlog data,int allentries){
 	     percent,log->timestamp,firstlba);
     }
   }
+  if (!allentries && retval)
+    pout("\n");
   return retval;
 }
 
@@ -952,15 +958,14 @@ int ataPrintMain (int fd){
 	     "Drive failure expected in less than 24 hours. SAVE ALL DATA.\n");
       QUIETOFF;
       if (ataCheckSmart(smartval, smartthres,1)){
-	QUIETON;
 	returnval|=FAILATTR;
 	if (smartvendorattrib)
 	  pout("See vendor-specific Attribute list for failed Attributes.\n\n");
-	else
-	  {
-	    pout("Failed Attributes:\n");
-	    PrintSmartAttribWithThres(smartval, smartthres,1);
-	  }
+	else {
+	  QUIETON;
+	  pout("Failed Attributes:\n");
+	  PrintSmartAttribWithThres(smartval, smartthres,1);
+	}
       }
       else
 	pout("No failed Attributes found.\n\n");   
@@ -970,10 +975,10 @@ int ataPrintMain (int fd){
     else {
       pout("SMART overall-health self-assessment test result: PASSED\n");
       if (ataCheckSmart(smartval, smartthres,0)){
-	QUIETON;
 	if (smartvendorattrib)
 	  pout("See vendor-specific Attribute list for marginal Attributes.\n\n");
 	else {
+	  QUIETON;
 	  pout("Please note the following marginal attributes:\n");
 	  PrintSmartAttribWithThres(smartval, smartthres,2);
 	} 
diff --git a/sm5/smartctl.8 b/sm5/smartctl.8
index eeb22914a..5f3c4ca82 100644
--- a/sm5/smartctl.8
+++ b/sm5/smartctl.8
@@ -1,6 +1,6 @@
 \# Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net>
 \#
-\# $Id: smartctl.8,v 1.17 2002/10/24 07:50:45 ballen4705 Exp $
+\# $Id: smartctl.8,v 1.18 2002/10/24 08:46:03 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
@@ -15,9 +15,9 @@
 \# at the Concurrent Systems Laboratory (now part of the Storage Systems
 \# Research Center), Jack Baskin School of Engineering, University of
 \# California, Santa Cruz. http://ssrc.soe.ucsc.edu/
-.TH SMARTCTL 8  "$Date: 2002/10/24 07:50:45 $" "smartmontools-5.0"
+.TH SMARTCTL 8  "$Date: 2002/10/24 08:46:03 $" "smartmontools-5.0"
 .SH NAME
-smartctl \- S.M.A.R.T. control utility 
+smartctl \- S.M.A.R.T. control and monitor utility 
 .SH SYNOPSIS
 .B smartctl \-[ViqQaedtTfFcgvlLm[O|S|s|X|x|A]] device
 
@@ -86,12 +86,14 @@ Says if the device supports S.M.A.R.T., and if so, whether
 S.M.A.R.T. support is currently enabled or disabled.
 .TP
 .B q
-Quiet mode: Only print: For the '\-l' option, errors recorded in the
-SMART error log; For the '\-L' option, errors recorded in the device
-self-test log; For the '\-c' SMART "disk failing" status or device
+Quiet mode: Only print: For the '\-l' option, just the number of
+errors recorded in the SMART error log and the power-on time when they
+occured, if any errors are recorded; For the '\-L' option, errors
+recorded in the device self-test log; For the '\-c' SMART "disk
+failing" status or device attributes (pre-failure or usage) which
+failed either now or in the past; For the '\-v' option device
 attributes (pre-failure or usage) which failed either now or in the
-past; For the '\-v' option device attributes (pre-failure or usage)
-which failed either now or in the past.
+past.
 .TP
 .B Q
 Very Quiet mode: Print no ouput.  The only way to learn about what was
@@ -440,4 +442,4 @@ Please let us know if there is an on\-line source for this document.
 
 .SH
 CVS ID OF THIS PAGE:
-$Id: smartctl.8,v 1.17 2002/10/24 07:50:45 ballen4705 Exp $
+$Id: smartctl.8,v 1.18 2002/10/24 08:46:03 ballen4705 Exp $
diff --git a/sm5/smartctl.c b/sm5/smartctl.c
index fab7c17a1..b68e93cdf 100644
--- a/sm5/smartctl.c
+++ b/sm5/smartctl.c
@@ -38,7 +38,7 @@
 #include "scsiprint.h"
 
 extern const char *CVSid1, *CVSid2, *CVSid4, *CVSid5; 
-const char* CVSid6="$Id: smartctl.c,v 1.17 2002/10/23 20:36:59 ballen4705 Exp $"
+const char* CVSid6="$Id: smartctl.c,v 1.18 2002/10/24 08:46:03 ballen4705 Exp $"
 CVSID1 CVSID2 CVSID4 CVSID5 CVSID6;
 
 unsigned char driveinfo               = FALSE;
@@ -211,10 +211,8 @@ void ParseOpts (int argc, char** argv){
     switch (optchar){
     case QUIETMODE:
       quietmode=TRUE;
-      veryquietmode=TRUE;
       break;
     case VERYQUIETMODE:
-      quietmode=FALSE;
       veryquietmode=TRUE;
       break;
     case SMART009MINUTES:
@@ -299,6 +297,10 @@ void ParseOpts (int argc, char** argv){
       exit(FAILCMD);	
     }
   }
+  // Do this here, so results are independent of argument order	
+  if (quietmode)
+    veryquietmode=TRUE;
+  
   // error message if user has asked for more than one test
   if (1<(smartexeoffimmediate+smartshortselftest+smartextendselftest+
 	 smartshortcapselftest+smartextendcapselftest+smartselftestabort)){
diff --git a/sm5/smartctl.cpp b/sm5/smartctl.cpp
index 9ed11df94..78da1b547 100644
--- a/sm5/smartctl.cpp
+++ b/sm5/smartctl.cpp
@@ -38,7 +38,7 @@
 #include "scsiprint.h"
 
 extern const char *CVSid1, *CVSid2, *CVSid4, *CVSid5; 
-const char* CVSid6="$Id: smartctl.cpp,v 1.17 2002/10/23 20:36:59 ballen4705 Exp $"
+const char* CVSid6="$Id: smartctl.cpp,v 1.18 2002/10/24 08:46:03 ballen4705 Exp $"
 CVSID1 CVSID2 CVSID4 CVSID5 CVSID6;
 
 unsigned char driveinfo               = FALSE;
@@ -211,10 +211,8 @@ void ParseOpts (int argc, char** argv){
     switch (optchar){
     case QUIETMODE:
       quietmode=TRUE;
-      veryquietmode=TRUE;
       break;
     case VERYQUIETMODE:
-      quietmode=FALSE;
       veryquietmode=TRUE;
       break;
     case SMART009MINUTES:
@@ -299,6 +297,10 @@ void ParseOpts (int argc, char** argv){
       exit(FAILCMD);	
     }
   }
+  // Do this here, so results are independent of argument order	
+  if (quietmode)
+    veryquietmode=TRUE;
+  
   // error message if user has asked for more than one test
   if (1<(smartexeoffimmediate+smartshortselftest+smartextendselftest+
 	 smartshortcapselftest+smartextendcapselftest+smartselftestabort)){
-- 
GitLab