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

added flag to self test log print function to show only errors

git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@87 4ea69e1a-61f1-4043-bf83-b5c94c648137
parent 26a7af76
No related branches found
No related tags found
No related merge requests found
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "smartctl.h" #include "smartctl.h"
#include "extern.h" #include "extern.h"
const char *CVSid4="$Id: ataprint.c,v 1.23 2002/10/22 16:49:16 ballen4705 Exp $\n" const char *CVSid4="$Id: ataprint.c,v 1.24 2002/10/22 20:35:42 ballen4705 Exp $\n"
"\t" CVSID2 "\t" CVSID3 "\t" CVSID6 ; "\t" CVSID2 "\t" CVSID3 "\t" CVSID6 ;
// Function for printing ASCII byte-swapped strings, skipping white // Function for printing ASCII byte-swapped strings, skipping white
...@@ -401,7 +401,7 @@ void PrintSmartAttribWithThres (struct ata_smart_values data, ...@@ -401,7 +401,7 @@ void PrintSmartAttribWithThres (struct ata_smart_values data,
// is this currently failed, or has it ever failed? // is this currently failed, or has it ever failed?
if (failednow) if (failednow)
status="FAILED_NOW!"; status="FAILING_NOW";
else if (failedever) else if (failedever)
status="In_the_past"; status="In_the_past";
else else
...@@ -615,29 +615,29 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog data) ...@@ -615,29 +615,29 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog data)
} }
void ataPrintSmartSelfTestlog (struct ata_smart_selftestlog data){ void ataPrintSmartSelfTestlog (struct ata_smart_selftestlog data,int allentries){
int i,j; int i,j,noheaderprinted=1;
if (allentries)
printf("SMART Self-test log, version number %u\n",data.revnumber); printf("SMART Self-test log, version number %u\n",data.revnumber);
if (data.revnumber!=0x01) if (data.revnumber!=0x01 && allentries)
printf("Warning - structure revision number does not match spec!\n"); printf("Warning - structure revision number does not match spec!\n");
if (data.mostrecenttest==0){ if (data.mostrecenttest==0){
if (allentries)
printf("No self-tests have been logged\n"); printf("No self-tests have been logged\n");
return; return;
} }
// print log // print log
printf("Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error\n");
for (i=20;i>=0;i--){ for (i=20;i>=0;i--){
struct ata_smart_selftestlog_struct *log; struct ata_smart_selftestlog_struct *log;
// log is a circular buffer // log is a circular buffer
j=(i+data.mostrecenttest)%21; j=(i+data.mostrecenttest)%21;
log=&(data.selftest_struct[j]); log=data.selftest_struct+j;
if (nonempty((unsigned char*)log,sizeof(*log))){ if (nonempty((unsigned char*)log,sizeof(*log))){
char *msgtest,*msgstat,percent[64],firstlba[64]; char *msgtest,*msgstat,percent[64],firstlba[64];
int errorfound=0;
// test name // test name
switch(log->selftestnumber){ switch(log->selftestnumber){
...@@ -655,11 +655,11 @@ void ataPrintSmartSelfTestlog (struct ata_smart_selftestlog data){ ...@@ -655,11 +655,11 @@ void ataPrintSmartSelfTestlog (struct ata_smart_selftestlog data){
case 0:msgstat="Completed "; break; case 0:msgstat="Completed "; break;
case 1:msgstat="Aborted by host "; break; case 1:msgstat="Aborted by host "; break;
case 2:msgstat="Interrupted (host reset) "; break; case 2:msgstat="Interrupted (host reset) "; break;
case 3:msgstat="Fatal or unknown error "; break; case 3:msgstat="Fatal or unknown error "; errorfound=1; break;
case 4:msgstat="Completed: unknown failure "; break; case 4:msgstat="Completed: unknown failure "; errorfound=1; break;
case 5:msgstat="Completed: electrical failure"; break; case 5:msgstat="Completed: electrical failure"; errorfound=1; break;
case 6:msgstat="Completed: servo/seek failure"; break; case 6:msgstat="Completed: servo/seek failure"; errorfound=1; break;
case 7:msgstat="Completed: read failure "; break; case 7:msgstat="Completed: read failure "; errorfound=1; break;
case 15:msgstat="Test in progress "; break; case 15:msgstat="Test in progress "; break;
default:msgstat="Unknown test status "; default:msgstat="Unknown test status ";
} }
...@@ -669,13 +669,15 @@ void ataPrintSmartSelfTestlog (struct ata_smart_selftestlog data){ ...@@ -669,13 +669,15 @@ void ataPrintSmartSelfTestlog (struct ata_smart_selftestlog data){
sprintf(firstlba,"%s",""); sprintf(firstlba,"%s","");
else else
sprintf(firstlba,"0x%08x",log->lbafirstfailure); sprintf(firstlba,"0x%08x",log->lbafirstfailure);
printf("#%2d %s %s %s %8u %s\n",
21-i, if (noheaderprinted && (allentries || errorfound)){
msgtest, printf("Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error\n");
msgstat, noheaderprinted=0;
percent, }
log->timestamp,
firstlba); if (allentries || errorfound)
printf("#%2d %s %s %s %8u %s\n",21-i,msgtest,msgstat,
percent,log->timestamp,firstlba);
} }
else else
return; return;
...@@ -913,11 +915,11 @@ int ataPrintMain (int fd){ ...@@ -913,11 +915,11 @@ int ataPrintMain (int fd){
// for everything else read values and thresholds are needed // for everything else read values and thresholds are needed
if (ataReadSmartValues(fd, &smartval)){ if (ataReadSmartValues(fd, &smartval)){
printf("Smartctl: SMART Values Read Failed.\n\n"); printf("Smartctl: SMART Read Values failed.\n\n");
returnval|=FAILSMART; returnval|=FAILSMART;
} }
if (ataReadSmartThresholds(fd, &smartthres)){ if (ataReadSmartThresholds(fd, &smartthres)){
printf("Smartctl: SMART Thresholds Read Failed.\n\n"); printf("Smartctl: SMART Read Thresholds failed.\n\n");
returnval|=FAILSMART; returnval|=FAILSMART;
} }
...@@ -953,14 +955,14 @@ int ataPrintMain (int fd){ ...@@ -953,14 +955,14 @@ int ataPrintMain (int fd){
if (checksmart){ if (checksmart){
if (code) { if (code) {
printf("SMART overall-health self-assessment test result: FAILED!\n" printf("SMART overall-health self-assessment test result: FAILED!\n"
"Drive failure expected in less than 24 hours. SAVE ALL DATA\n"); "Drive failure expected in less than 24 hours. SAVE ALL DATA.\n");
if (ataCheckSmart(smartval, smartthres,1)){ if (ataCheckSmart(smartval, smartthres,1)){
returnval|=FAILATTR; returnval|=FAILATTR;
printf("Failed attributes:\n"); printf("Failed Attributes:\n");
PrintSmartAttribWithThres(smartval, smartthres,1); PrintSmartAttribWithThres(smartval, smartthres,1);
} }
else { else {
printf("No failing attributes found.\n"); printf("No failed Attributes found.\n");
} }
printf("\n"); printf("\n");
returnval|=FAILSTATUS; returnval|=FAILSTATUS;
...@@ -986,11 +988,8 @@ int ataPrintMain (int fd){ ...@@ -986,11 +988,8 @@ int ataPrintMain (int fd){
// Print SMART error log // Print SMART error log
if (smarterrorlog){ if (smarterrorlog){
if (!isSmartErrorLogCapable(smartval)){ if (!isSmartErrorLogCapable(smartval))
printf("Device does not support Error Logging\n"); printf("Device does not support Error Logging\n");
returnval|=FAILSMART;
}
else {
if (ataReadErrorLog(fd, &smarterror)){ if (ataReadErrorLog(fd, &smarterror)){
printf("Smartctl: SMART Errorlog Read Failed\n"); printf("Smartctl: SMART Errorlog Read Failed\n");
returnval|=FAILSMART; returnval|=FAILSMART;
...@@ -998,21 +997,18 @@ int ataPrintMain (int fd){ ...@@ -998,21 +997,18 @@ int ataPrintMain (int fd){
else else
ataPrintSmartErrorlog(smarterror); ataPrintSmartErrorlog(smarterror);
} }
}
// Print SMART self-test log // Print SMART self-test log
if (smartselftestlog){ if (smartselftestlog){
if (!isSmartErrorLogCapable(smartval)){ if (!isSmartErrorLogCapable(smartval))
printf("Device does not support Self Test Logging\n"); printf("Device does not support Self Test Logging\n");
returnval|=FAILSMART;
}
else { else {
if(ataReadSelfTestLog(fd, &smartselftest)){ if(ataReadSelfTestLog(fd, &smartselftest)){
printf("Smartctl: SMART Self Test Log Read Failed\n"); printf("Smartctl: SMART Self Test Log Read Failed\n");
returnval|=FAILSMART; returnval|=FAILSMART;
} }
else else
ataPrintSmartSelfTestlog(smartselftest); ataPrintSmartSelfTestlog(smartselftest,1);
} }
} }
...@@ -1023,14 +1019,10 @@ int ataPrintMain (int fd){ ...@@ -1023,14 +1019,10 @@ int ataPrintMain (int fd){
printf("\n=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===\n"); printf("\n=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===\n");
// if doing a self-test, be sure it's supported by the hardware // if doing a self-test, be sure it's supported by the hardware
if (testcase==OFFLINE_FULL_SCAN && !isSupportExecuteOfflineImmediate(smartval)){ if (testcase==OFFLINE_FULL_SCAN && !isSupportExecuteOfflineImmediate(smartval))
printf("ERROR: device does not support Execute Off-Line Immediate function.\n\n"); printf("ERROR: device does not support Execute Off-Line Immediate function.\n\n");
return returnval|=FAILSMART; else if (!isSupportSelfTest(smartval))
}
else if (!isSupportSelfTest(smartval)){
printf ("ERROR: device does not support Self-Test functions.\n\n"); printf ("ERROR: device does not support Self-Test functions.\n\n");
return returnval|=FAILSMART;
}
// Now do the test // Now do the test
if (ataSmartTest(fd, testcase)) if (ataSmartTest(fd, testcase))
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "smartctl.h" #include "smartctl.h"
#include "extern.h" #include "extern.h"
const char *CVSid4="$Id: ataprint.cpp,v 1.23 2002/10/22 16:49:16 ballen4705 Exp $\n" const char *CVSid4="$Id: ataprint.cpp,v 1.24 2002/10/22 20:35:42 ballen4705 Exp $\n"
"\t" CVSID2 "\t" CVSID3 "\t" CVSID6 ; "\t" CVSID2 "\t" CVSID3 "\t" CVSID6 ;
// Function for printing ASCII byte-swapped strings, skipping white // Function for printing ASCII byte-swapped strings, skipping white
...@@ -401,7 +401,7 @@ void PrintSmartAttribWithThres (struct ata_smart_values data, ...@@ -401,7 +401,7 @@ void PrintSmartAttribWithThres (struct ata_smart_values data,
// is this currently failed, or has it ever failed? // is this currently failed, or has it ever failed?
if (failednow) if (failednow)
status="FAILED_NOW!"; status="FAILING_NOW";
else if (failedever) else if (failedever)
status="In_the_past"; status="In_the_past";
else else
...@@ -615,29 +615,29 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog data) ...@@ -615,29 +615,29 @@ void ataPrintSmartErrorlog (struct ata_smart_errorlog data)
} }
void ataPrintSmartSelfTestlog (struct ata_smart_selftestlog data){ void ataPrintSmartSelfTestlog (struct ata_smart_selftestlog data,int allentries){
int i,j; int i,j,noheaderprinted=1;
if (allentries)
printf("SMART Self-test log, version number %u\n",data.revnumber); printf("SMART Self-test log, version number %u\n",data.revnumber);
if (data.revnumber!=0x01) if (data.revnumber!=0x01 && allentries)
printf("Warning - structure revision number does not match spec!\n"); printf("Warning - structure revision number does not match spec!\n");
if (data.mostrecenttest==0){ if (data.mostrecenttest==0){
if (allentries)
printf("No self-tests have been logged\n"); printf("No self-tests have been logged\n");
return; return;
} }
// print log // print log
printf("Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error\n");
for (i=20;i>=0;i--){ for (i=20;i>=0;i--){
struct ata_smart_selftestlog_struct *log; struct ata_smart_selftestlog_struct *log;
// log is a circular buffer // log is a circular buffer
j=(i+data.mostrecenttest)%21; j=(i+data.mostrecenttest)%21;
log=&(data.selftest_struct[j]); log=data.selftest_struct+j;
if (nonempty((unsigned char*)log,sizeof(*log))){ if (nonempty((unsigned char*)log,sizeof(*log))){
char *msgtest,*msgstat,percent[64],firstlba[64]; char *msgtest,*msgstat,percent[64],firstlba[64];
int errorfound=0;
// test name // test name
switch(log->selftestnumber){ switch(log->selftestnumber){
...@@ -655,11 +655,11 @@ void ataPrintSmartSelfTestlog (struct ata_smart_selftestlog data){ ...@@ -655,11 +655,11 @@ void ataPrintSmartSelfTestlog (struct ata_smart_selftestlog data){
case 0:msgstat="Completed "; break; case 0:msgstat="Completed "; break;
case 1:msgstat="Aborted by host "; break; case 1:msgstat="Aborted by host "; break;
case 2:msgstat="Interrupted (host reset) "; break; case 2:msgstat="Interrupted (host reset) "; break;
case 3:msgstat="Fatal or unknown error "; break; case 3:msgstat="Fatal or unknown error "; errorfound=1; break;
case 4:msgstat="Completed: unknown failure "; break; case 4:msgstat="Completed: unknown failure "; errorfound=1; break;
case 5:msgstat="Completed: electrical failure"; break; case 5:msgstat="Completed: electrical failure"; errorfound=1; break;
case 6:msgstat="Completed: servo/seek failure"; break; case 6:msgstat="Completed: servo/seek failure"; errorfound=1; break;
case 7:msgstat="Completed: read failure "; break; case 7:msgstat="Completed: read failure "; errorfound=1; break;
case 15:msgstat="Test in progress "; break; case 15:msgstat="Test in progress "; break;
default:msgstat="Unknown test status "; default:msgstat="Unknown test status ";
} }
...@@ -669,13 +669,15 @@ void ataPrintSmartSelfTestlog (struct ata_smart_selftestlog data){ ...@@ -669,13 +669,15 @@ void ataPrintSmartSelfTestlog (struct ata_smart_selftestlog data){
sprintf(firstlba,"%s",""); sprintf(firstlba,"%s","");
else else
sprintf(firstlba,"0x%08x",log->lbafirstfailure); sprintf(firstlba,"0x%08x",log->lbafirstfailure);
printf("#%2d %s %s %s %8u %s\n",
21-i, if (noheaderprinted && (allentries || errorfound)){
msgtest, printf("Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error\n");
msgstat, noheaderprinted=0;
percent, }
log->timestamp,
firstlba); if (allentries || errorfound)
printf("#%2d %s %s %s %8u %s\n",21-i,msgtest,msgstat,
percent,log->timestamp,firstlba);
} }
else else
return; return;
...@@ -913,11 +915,11 @@ int ataPrintMain (int fd){ ...@@ -913,11 +915,11 @@ int ataPrintMain (int fd){
// for everything else read values and thresholds are needed // for everything else read values and thresholds are needed
if (ataReadSmartValues(fd, &smartval)){ if (ataReadSmartValues(fd, &smartval)){
printf("Smartctl: SMART Values Read Failed.\n\n"); printf("Smartctl: SMART Read Values failed.\n\n");
returnval|=FAILSMART; returnval|=FAILSMART;
} }
if (ataReadSmartThresholds(fd, &smartthres)){ if (ataReadSmartThresholds(fd, &smartthres)){
printf("Smartctl: SMART Thresholds Read Failed.\n\n"); printf("Smartctl: SMART Read Thresholds failed.\n\n");
returnval|=FAILSMART; returnval|=FAILSMART;
} }
...@@ -953,14 +955,14 @@ int ataPrintMain (int fd){ ...@@ -953,14 +955,14 @@ int ataPrintMain (int fd){
if (checksmart){ if (checksmart){
if (code) { if (code) {
printf("SMART overall-health self-assessment test result: FAILED!\n" printf("SMART overall-health self-assessment test result: FAILED!\n"
"Drive failure expected in less than 24 hours. SAVE ALL DATA\n"); "Drive failure expected in less than 24 hours. SAVE ALL DATA.\n");
if (ataCheckSmart(smartval, smartthres,1)){ if (ataCheckSmart(smartval, smartthres,1)){
returnval|=FAILATTR; returnval|=FAILATTR;
printf("Failed attributes:\n"); printf("Failed Attributes:\n");
PrintSmartAttribWithThres(smartval, smartthres,1); PrintSmartAttribWithThres(smartval, smartthres,1);
} }
else { else {
printf("No failing attributes found.\n"); printf("No failed Attributes found.\n");
} }
printf("\n"); printf("\n");
returnval|=FAILSTATUS; returnval|=FAILSTATUS;
...@@ -986,11 +988,8 @@ int ataPrintMain (int fd){ ...@@ -986,11 +988,8 @@ int ataPrintMain (int fd){
// Print SMART error log // Print SMART error log
if (smarterrorlog){ if (smarterrorlog){
if (!isSmartErrorLogCapable(smartval)){ if (!isSmartErrorLogCapable(smartval))
printf("Device does not support Error Logging\n"); printf("Device does not support Error Logging\n");
returnval|=FAILSMART;
}
else {
if (ataReadErrorLog(fd, &smarterror)){ if (ataReadErrorLog(fd, &smarterror)){
printf("Smartctl: SMART Errorlog Read Failed\n"); printf("Smartctl: SMART Errorlog Read Failed\n");
returnval|=FAILSMART; returnval|=FAILSMART;
...@@ -998,21 +997,18 @@ int ataPrintMain (int fd){ ...@@ -998,21 +997,18 @@ int ataPrintMain (int fd){
else else
ataPrintSmartErrorlog(smarterror); ataPrintSmartErrorlog(smarterror);
} }
}
// Print SMART self-test log // Print SMART self-test log
if (smartselftestlog){ if (smartselftestlog){
if (!isSmartErrorLogCapable(smartval)){ if (!isSmartErrorLogCapable(smartval))
printf("Device does not support Self Test Logging\n"); printf("Device does not support Self Test Logging\n");
returnval|=FAILSMART;
}
else { else {
if(ataReadSelfTestLog(fd, &smartselftest)){ if(ataReadSelfTestLog(fd, &smartselftest)){
printf("Smartctl: SMART Self Test Log Read Failed\n"); printf("Smartctl: SMART Self Test Log Read Failed\n");
returnval|=FAILSMART; returnval|=FAILSMART;
} }
else else
ataPrintSmartSelfTestlog(smartselftest); ataPrintSmartSelfTestlog(smartselftest,1);
} }
} }
...@@ -1023,14 +1019,10 @@ int ataPrintMain (int fd){ ...@@ -1023,14 +1019,10 @@ int ataPrintMain (int fd){
printf("\n=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===\n"); printf("\n=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===\n");
// if doing a self-test, be sure it's supported by the hardware // if doing a self-test, be sure it's supported by the hardware
if (testcase==OFFLINE_FULL_SCAN && !isSupportExecuteOfflineImmediate(smartval)){ if (testcase==OFFLINE_FULL_SCAN && !isSupportExecuteOfflineImmediate(smartval))
printf("ERROR: device does not support Execute Off-Line Immediate function.\n\n"); printf("ERROR: device does not support Execute Off-Line Immediate function.\n\n");
return returnval|=FAILSMART; else if (!isSupportSelfTest(smartval))
}
else if (!isSupportSelfTest(smartval)){
printf ("ERROR: device does not support Self-Test functions.\n\n"); printf ("ERROR: device does not support Self-Test functions.\n\n");
return returnval|=FAILSMART;
}
// Now do the test // Now do the test
if (ataSmartTest(fd, testcase)) if (ataSmartTest(fd, testcase))
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#define _SMART_PRINT_H_ #define _SMART_PRINT_H_
#ifndef CVSID2 #ifndef CVSID2
#define CVSID2 "$Id: ataprint.h,v 1.9 2002/10/22 16:49:16 ballen4705 Exp $\n" #define CVSID2 "$Id: ataprint.h,v 1.10 2002/10/22 20:35:42 ballen4705 Exp $\n"
#endif #endif
#include <stdio.h> #include <stdio.h>
...@@ -49,7 +49,7 @@ void PrintSmartAttribWithThres (struct ata_smart_values data, ...@@ -49,7 +49,7 @@ void PrintSmartAttribWithThres (struct ata_smart_values data,
struct ata_smart_thresholds thresholds, struct ata_smart_thresholds thresholds,
int onlyfailed); int onlyfailed);
void ataPrintSmartSelfTestlog (struct ata_smart_selftestlog data); void ataPrintSmartSelfTestlog(struct ata_smart_selftestlog data, int allentries);
void ataPseudoCheckSmart (struct ata_smart_values , void ataPseudoCheckSmart (struct ata_smart_values ,
struct ata_smart_thresholds ); struct ata_smart_thresholds );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment