From 0ac969a6eee88124e2f634c3418c741b4a2fd1dd Mon Sep 17 00:00:00 2001 From: ballen4705 <ballen4705@4ea69e1a-61f1-4043-bf83-b5c94c648137> Date: Tue, 29 Oct 2002 22:09:52 +0000 Subject: [PATCH] Added a warning to smartctl, so that if a data structure is printed that does not have consistent identity, the user is alerted. git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@165 4ea69e1a-61f1-4043-bf83-b5c94c648137 --- sm5/ataprint.c | 17 +++++++++++++---- sm5/ataprint.cpp | 17 +++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/sm5/ataprint.c b/sm5/ataprint.c index 44407a06d..1ddf45baa 100644 --- a/sm5/ataprint.c +++ b/sm5/ataprint.c @@ -29,7 +29,7 @@ #include "smartctl.h" #include "extern.h" -const char *CVSid2="$Id: ataprint.c,v 1.36 2002/10/29 10:06:20 ballen4705 Exp $" +const char *CVSid2="$Id: ataprint.c,v 1.37 2002/10/29 22:09:52 ballen4705 Exp $" CVSID1 CVSID2 CVSID3 CVSID6; // for passing global control variables @@ -434,17 +434,26 @@ void PrintSmartAttribWithThres (struct ata_smart_values data, // Temperature case 194: - pout ("%u", disk->raw[0]); + pout ("%hhu", disk->raw[0]); if (rawvalue==disk->raw[0]) pout("\n"); else // The other bytes are in use. Try IBM's model - pout(" (Lifetime Min/Max %u/%u)\n",disk->raw[2], + pout(" (Lifetime Min/Max %hhu/%hhu)\n",disk->raw[2], disk->raw[4]); break; default: pout("%llu\n", rawvalue); - } + } + + // print a warning if there is inconsistency here! + if (disk->id != thre->id){ + char atdat[64],atthr[64]; + ataPrintSmartAttribName(atdat,disk->id); + ataPrintSmartAttribName(atthr,thre->id); + pout("%-28s<== Data Page | WARNING: PREVIOUS ATTRIBUTE HAS TWO\n",atdat); + pout("%-28s<== Threshold Page | INCONSISTENT IDENTITIES IN THE DATA\n",atthr); + } } } if (!needheader) pout("\n"); diff --git a/sm5/ataprint.cpp b/sm5/ataprint.cpp index 15cde024f..b2b9e1611 100644 --- a/sm5/ataprint.cpp +++ b/sm5/ataprint.cpp @@ -29,7 +29,7 @@ #include "smartctl.h" #include "extern.h" -const char *CVSid2="$Id: ataprint.cpp,v 1.36 2002/10/29 10:06:20 ballen4705 Exp $" +const char *CVSid2="$Id: ataprint.cpp,v 1.37 2002/10/29 22:09:52 ballen4705 Exp $" CVSID1 CVSID2 CVSID3 CVSID6; // for passing global control variables @@ -434,17 +434,26 @@ void PrintSmartAttribWithThres (struct ata_smart_values data, // Temperature case 194: - pout ("%u", disk->raw[0]); + pout ("%hhu", disk->raw[0]); if (rawvalue==disk->raw[0]) pout("\n"); else // The other bytes are in use. Try IBM's model - pout(" (Lifetime Min/Max %u/%u)\n",disk->raw[2], + pout(" (Lifetime Min/Max %hhu/%hhu)\n",disk->raw[2], disk->raw[4]); break; default: pout("%llu\n", rawvalue); - } + } + + // print a warning if there is inconsistency here! + if (disk->id != thre->id){ + char atdat[64],atthr[64]; + ataPrintSmartAttribName(atdat,disk->id); + ataPrintSmartAttribName(atthr,thre->id); + pout("%-28s<== Data Page | WARNING: PREVIOUS ATTRIBUTE HAS TWO\n",atdat); + pout("%-28s<== Threshold Page | INCONSISTENT IDENTITIES IN THE DATA\n",atthr); + } } } if (!needheader) pout("\n"); -- GitLab