diff --git a/sm5/atacmds.c b/sm5/atacmds.c index 9f2e84254a50f66881f968282036c5ef9a66c932..7bce37b2f910c465b233504cae40b43f457b787d 100644 --- a/sm5/atacmds.c +++ b/sm5/atacmds.c @@ -30,7 +30,7 @@ #include <stdlib.h> #include "atacmds.h" -const char *CVSid1="$Id: atacmds.c,v 1.28 2002/10/26 19:33:39 ballen4705 Exp $" CVSID1; +const char *CVSid1="$Id: atacmds.c,v 1.29 2002/10/26 19:59:01 ballen4705 Exp $" CVSID1; // These Drive Identity tables are taken from hdparm 5.2, and are also // given in the ATA/ATAPI specs for the IDENTIFY DEVICE command. Note @@ -132,7 +132,7 @@ void checksumwarning(const char *string){ // state information, and for example the checksum is usually // wrong. The replacement function follows afterwards #if (0) -int ataReadHDIdentity ( int device, struct hd_driveid *buf){ +int ataReadHDIdentity (int device, struct hd_driveid *buf){ if (ioctl(device, HDIO_GET_IDENTITY, buf)){ perror ("ATA GET HD Failed"); return -1; @@ -199,17 +199,17 @@ int ataReadHDIdentity (int device, struct hd_driveid *buf){ // describing which revision. Note that Revision 0 of ATA-3 does NOT // support SMART. For this one case we return -3 rather than +3 as // the version number. See notes above. -int ataVersionInfo (const char** description, struct hd_driveid drive){ - unsigned short major,minor; +int ataVersionInfo (const char** description, struct hd_driveid drive, unsigned short *minor){ + unsigned short major; int i; // get major and minor ATA revision numbers #ifdef __NEW_HD_DRIVE_ID major=drive.major_rev_num; - minor=drive.minor_rev_num; + *minor=drive.minor_rev_num; #else major=drive.word80; - minor=drive.word81; + *minor=drive.word81; #endif // First check if device has ANY ATA version information in it @@ -219,10 +219,10 @@ int ataVersionInfo (const char** description, struct hd_driveid drive){ } // The minor revision number has more information - try there first - if (minor && (minor<=MINOR_MAX)){ - int std = actual_ver[minor]; + if (*minor && (*minor<=MINOR_MAX)){ + int std = actual_ver[*minor]; if (std) { - *description=minor_str[minor]; + *description=minor_str[*minor]; return std; } } @@ -530,7 +530,7 @@ int ataSmartStatus2(int device){ // Should be fixed by putting in a call to code // that compares smart data to thresholds. int ataSmartStatus2(int device){ - return ataSmartStatus(device) + return ataSmartStatus(device); } #endif diff --git a/sm5/atacmds.cpp b/sm5/atacmds.cpp index 25f512cbc7c8a72076b32a02084c5c0cdcaed756..07f571ef3d55804a6979875de5b5e1707cd8f49e 100644 --- a/sm5/atacmds.cpp +++ b/sm5/atacmds.cpp @@ -30,7 +30,7 @@ #include <stdlib.h> #include "atacmds.h" -const char *CVSid1="$Id: atacmds.cpp,v 1.28 2002/10/26 19:33:39 ballen4705 Exp $" CVSID1; +const char *CVSid1="$Id: atacmds.cpp,v 1.29 2002/10/26 19:59:01 ballen4705 Exp $" CVSID1; // These Drive Identity tables are taken from hdparm 5.2, and are also // given in the ATA/ATAPI specs for the IDENTIFY DEVICE command. Note @@ -132,7 +132,7 @@ void checksumwarning(const char *string){ // state information, and for example the checksum is usually // wrong. The replacement function follows afterwards #if (0) -int ataReadHDIdentity ( int device, struct hd_driveid *buf){ +int ataReadHDIdentity (int device, struct hd_driveid *buf){ if (ioctl(device, HDIO_GET_IDENTITY, buf)){ perror ("ATA GET HD Failed"); return -1; @@ -199,17 +199,17 @@ int ataReadHDIdentity (int device, struct hd_driveid *buf){ // describing which revision. Note that Revision 0 of ATA-3 does NOT // support SMART. For this one case we return -3 rather than +3 as // the version number. See notes above. -int ataVersionInfo (const char** description, struct hd_driveid drive){ - unsigned short major,minor; +int ataVersionInfo (const char** description, struct hd_driveid drive, unsigned short *minor){ + unsigned short major; int i; // get major and minor ATA revision numbers #ifdef __NEW_HD_DRIVE_ID major=drive.major_rev_num; - minor=drive.minor_rev_num; + *minor=drive.minor_rev_num; #else major=drive.word80; - minor=drive.word81; + *minor=drive.word81; #endif // First check if device has ANY ATA version information in it @@ -219,10 +219,10 @@ int ataVersionInfo (const char** description, struct hd_driveid drive){ } // The minor revision number has more information - try there first - if (minor && (minor<=MINOR_MAX)){ - int std = actual_ver[minor]; + if (*minor && (*minor<=MINOR_MAX)){ + int std = actual_ver[*minor]; if (std) { - *description=minor_str[minor]; + *description=minor_str[*minor]; return std; } } @@ -530,7 +530,7 @@ int ataSmartStatus2(int device){ // Should be fixed by putting in a call to code // that compares smart data to thresholds. int ataSmartStatus2(int device){ - return ataSmartStatus(device) + return ataSmartStatus(device); } #endif diff --git a/sm5/atacmds.h b/sm5/atacmds.h index 511f6c287544f1a4ea93187f90e11a6aeb69b9e0..439e45f688fd07f4f75cdb070e143944399a241a 100644 --- a/sm5/atacmds.h +++ b/sm5/atacmds.h @@ -26,7 +26,7 @@ #define _ATACMDS_H_ #ifndef CVSID1 -#define CVSID1 "$Id: atacmds.h,v 1.19 2002/10/26 19:33:39 ballen4705 Exp $\n" +#define CVSID1 "$Id: atacmds.h,v 1.20 2002/10/26 19:59:01 ballen4705 Exp $\n" #endif // These are the major and minor versions for smartd and smartctl @@ -314,7 +314,7 @@ int ataSmartSelfTestAbort (int device); // Returns the latest compatibility of ATA/ATAPI Version the device // supports. Returns -1 if Version command is not supported -int ataVersionInfo (const char **description, struct hd_driveid drive); +int ataVersionInfo (const char **description, struct hd_driveid drive, unsigned short *minor); // If SMART supported, this is guaranteed to return 1 if SMART is enabled, else 0. diff --git a/sm5/ataprint.c b/sm5/ataprint.c index 6bc3d385f1db1871ed9380f812e8592559cf9a3d..5b99788f66a4b6c1afa19462f55b78f198bf7f11 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.33 2002/10/24 09:54:02 ballen4705 Exp $" +const char *CVSid4="$Id: ataprint.c,v 1.34 2002/10/26 19:59:01 ballen4705 Exp $" CVSID2 CVSID3 CVSID6; // Function for printing ASCII byte-swapped strings, skipping white @@ -63,6 +63,7 @@ void ataPrintDriveInfo (struct hd_driveid drive){ int version; const char *description; char unknown[64]; + unsigned short minorrev; // print out model, serial # and firmware versions (byte-swap ASCI strings) pout("Device Model: "); @@ -75,11 +76,11 @@ void ataPrintDriveInfo (struct hd_driveid drive){ printswap(drive.fw_rev,8); // now get ATA version info - version=ataVersionInfo(&description,drive); + version=ataVersionInfo(&description,drive, &minorrev); // unrecognized minor revision code if (!description){ - sprintf(unknown,"Unrecognized. Minor revision code: 0x%02x",drive.minor_rev_num); + sprintf(unknown,"Unrecognized. Minor revision code: 0x%02x",minorrev); description=unknown; } @@ -104,67 +105,59 @@ void ataPrintDriveInfo (struct hd_driveid drive){ /* void PrintSmartOfflineStatus ( struct ata_smart_values data) prints verbose value Off-line data collection status byte */ - -void PrintSmartOfflineStatus ( struct ata_smart_values data) -{ - pout ("Off-line data collection status: "); - - switch (data.offline_data_collection_status){ - case 0x00: - case 0x80: - pout ("(0x%02x)\tOffline data collection activity was\n\t\t\t\t\t", - data.offline_data_collection_status); - pout("never started.\n"); - break; - case 0x01: - case 0x81: - pout ("(0x%02x)\tReserved.\n", - data.offline_data_collection_status); - break; - case 0x02: - case 0x82: - pout ("(0x%02x)\tOffline data collection activity \n\t\t\t\t\t", - data.offline_data_collection_status); - pout ("completed without error.\n"); - break; - case 0x03: - case 0x83: - pout ("(0x%02x)\tReserved.\n", - data.offline_data_collection_status); - break; - case 0x04: - case 0x84: - pout ("(0x%02x)\tOffline data collection activity was \n\t\t\t\t\t", - data.offline_data_collection_status); - pout ("suspended by an interrupting command from host.\n"); - break; - case 0x05: - case 0x85: - pout ("(0x%02x)\tOffline data collection activity was \n\t\t\t\t\t", - data.offline_data_collection_status); - pout ("aborted by an interrupting command from host.\n"); - break; - case 0x06: - case 0x86: - pout ("(0x%02x)\tOffline data collection activity was \n\t\t\t\t\t", - data.offline_data_collection_status); - pout ("aborted by the device with a fatal error.\n"); - break; - default: - if ( ((data.offline_data_collection_status >= 0x07) && - (data.offline_data_collection_status <= 0x3f)) || - ((data.offline_data_collection_status >= 0xc0) && - (data.offline_data_collection_status <= 0xff)) ) - { - pout ("(0x%02x)\tVendor Specific.\n", - data.offline_data_collection_status); - } - else - { - pout ("(0x%02x)\tReserved.\n", - data.offline_data_collection_status); - } - } +void PrintSmartOfflineStatus(struct ata_smart_values data){ + pout("Off-line data collection status: "); + + switch(data.offline_data_collection_status){ + case 0x00: + case 0x80: + pout("(0x%02x)\tOffline data collection activity was\n\t\t\t\t\t", + data.offline_data_collection_status); + pout("never started.\n"); + break; + case 0x01: + case 0x81: + pout("(0x%02x)\tReserved.\n", + data.offline_data_collection_status); + break; + case 0x02: + case 0x82: + pout("(0x%02x)\tOffline data collection activity \n\t\t\t\t\t", + data.offline_data_collection_status); + pout("completed without error.\n"); + break; + case 0x03: + case 0x83: + pout("(0x%02x)\tReserved.\n", + data.offline_data_collection_status); + break; + case 0x04: + case 0x84: + pout("(0x%02x)\tOffline data collection activity was \n\t\t\t\t\t", + data.offline_data_collection_status); + pout("suspended by an interrupting command from host.\n"); + break; + case 0x05: + case 0x85: + pout("(0x%02x)\tOffline data collection activity was \n\t\t\t\t\t", + data.offline_data_collection_status); + pout("aborted by an interrupting command from host.\n"); + break; + case 0x06: + case 0x86: + pout("(0x%02x)\tOffline data collection activity was \n\t\t\t\t\t", + data.offline_data_collection_status); + pout("aborted by the device with a fatal error.\n"); + break; + default: + if ( ((data.offline_data_collection_status >= 0x07) && + (data.offline_data_collection_status <= 0x3f)) || + ((data.offline_data_collection_status >= 0xc0) && + (data.offline_data_collection_status <= 0xff)) ) + pout("(0x%02x)\tVendor Specific.\n",data.offline_data_collection_status); + else + pout("(0x%02x)\tReserved.\n",data.offline_data_collection_status); + } } @@ -237,11 +230,10 @@ void PrintSmartSelfExecStatus ( struct ata_smart_values data) -void PrintSmartTotalTimeCompleteOffline ( struct ata_smart_values data) -{ - pout ("Total time to complete off-line \n"); - pout ("data collection: \t\t (%4d) seconds.\n", - data.total_time_to_complete_off_line); +void PrintSmartTotalTimeCompleteOffline ( struct ata_smart_values data){ + pout("Total time to complete off-line \n"); + pout("data collection: \t\t (%4d) seconds.\n", + data.total_time_to_complete_off_line); } diff --git a/sm5/ataprint.cpp b/sm5/ataprint.cpp index 972a27c6c1d6f53330eb9b60d1fdafeef3ff19d6..2802fe6ab287c88872d041fd5e039b6ea0e64907 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.33 2002/10/24 09:54:02 ballen4705 Exp $" +const char *CVSid4="$Id: ataprint.cpp,v 1.34 2002/10/26 19:59:01 ballen4705 Exp $" CVSID2 CVSID3 CVSID6; // Function for printing ASCII byte-swapped strings, skipping white @@ -63,6 +63,7 @@ void ataPrintDriveInfo (struct hd_driveid drive){ int version; const char *description; char unknown[64]; + unsigned short minorrev; // print out model, serial # and firmware versions (byte-swap ASCI strings) pout("Device Model: "); @@ -75,11 +76,11 @@ void ataPrintDriveInfo (struct hd_driveid drive){ printswap(drive.fw_rev,8); // now get ATA version info - version=ataVersionInfo(&description,drive); + version=ataVersionInfo(&description,drive, &minorrev); // unrecognized minor revision code if (!description){ - sprintf(unknown,"Unrecognized. Minor revision code: 0x%02x",drive.minor_rev_num); + sprintf(unknown,"Unrecognized. Minor revision code: 0x%02x",minorrev); description=unknown; } @@ -104,67 +105,59 @@ void ataPrintDriveInfo (struct hd_driveid drive){ /* void PrintSmartOfflineStatus ( struct ata_smart_values data) prints verbose value Off-line data collection status byte */ - -void PrintSmartOfflineStatus ( struct ata_smart_values data) -{ - pout ("Off-line data collection status: "); - - switch (data.offline_data_collection_status){ - case 0x00: - case 0x80: - pout ("(0x%02x)\tOffline data collection activity was\n\t\t\t\t\t", - data.offline_data_collection_status); - pout("never started.\n"); - break; - case 0x01: - case 0x81: - pout ("(0x%02x)\tReserved.\n", - data.offline_data_collection_status); - break; - case 0x02: - case 0x82: - pout ("(0x%02x)\tOffline data collection activity \n\t\t\t\t\t", - data.offline_data_collection_status); - pout ("completed without error.\n"); - break; - case 0x03: - case 0x83: - pout ("(0x%02x)\tReserved.\n", - data.offline_data_collection_status); - break; - case 0x04: - case 0x84: - pout ("(0x%02x)\tOffline data collection activity was \n\t\t\t\t\t", - data.offline_data_collection_status); - pout ("suspended by an interrupting command from host.\n"); - break; - case 0x05: - case 0x85: - pout ("(0x%02x)\tOffline data collection activity was \n\t\t\t\t\t", - data.offline_data_collection_status); - pout ("aborted by an interrupting command from host.\n"); - break; - case 0x06: - case 0x86: - pout ("(0x%02x)\tOffline data collection activity was \n\t\t\t\t\t", - data.offline_data_collection_status); - pout ("aborted by the device with a fatal error.\n"); - break; - default: - if ( ((data.offline_data_collection_status >= 0x07) && - (data.offline_data_collection_status <= 0x3f)) || - ((data.offline_data_collection_status >= 0xc0) && - (data.offline_data_collection_status <= 0xff)) ) - { - pout ("(0x%02x)\tVendor Specific.\n", - data.offline_data_collection_status); - } - else - { - pout ("(0x%02x)\tReserved.\n", - data.offline_data_collection_status); - } - } +void PrintSmartOfflineStatus(struct ata_smart_values data){ + pout("Off-line data collection status: "); + + switch(data.offline_data_collection_status){ + case 0x00: + case 0x80: + pout("(0x%02x)\tOffline data collection activity was\n\t\t\t\t\t", + data.offline_data_collection_status); + pout("never started.\n"); + break; + case 0x01: + case 0x81: + pout("(0x%02x)\tReserved.\n", + data.offline_data_collection_status); + break; + case 0x02: + case 0x82: + pout("(0x%02x)\tOffline data collection activity \n\t\t\t\t\t", + data.offline_data_collection_status); + pout("completed without error.\n"); + break; + case 0x03: + case 0x83: + pout("(0x%02x)\tReserved.\n", + data.offline_data_collection_status); + break; + case 0x04: + case 0x84: + pout("(0x%02x)\tOffline data collection activity was \n\t\t\t\t\t", + data.offline_data_collection_status); + pout("suspended by an interrupting command from host.\n"); + break; + case 0x05: + case 0x85: + pout("(0x%02x)\tOffline data collection activity was \n\t\t\t\t\t", + data.offline_data_collection_status); + pout("aborted by an interrupting command from host.\n"); + break; + case 0x06: + case 0x86: + pout("(0x%02x)\tOffline data collection activity was \n\t\t\t\t\t", + data.offline_data_collection_status); + pout("aborted by the device with a fatal error.\n"); + break; + default: + if ( ((data.offline_data_collection_status >= 0x07) && + (data.offline_data_collection_status <= 0x3f)) || + ((data.offline_data_collection_status >= 0xc0) && + (data.offline_data_collection_status <= 0xff)) ) + pout("(0x%02x)\tVendor Specific.\n",data.offline_data_collection_status); + else + pout("(0x%02x)\tReserved.\n",data.offline_data_collection_status); + } } @@ -237,11 +230,10 @@ void PrintSmartSelfExecStatus ( struct ata_smart_values data) -void PrintSmartTotalTimeCompleteOffline ( struct ata_smart_values data) -{ - pout ("Total time to complete off-line \n"); - pout ("data collection: \t\t (%4d) seconds.\n", - data.total_time_to_complete_off_line); +void PrintSmartTotalTimeCompleteOffline ( struct ata_smart_values data){ + pout("Total time to complete off-line \n"); + pout("data collection: \t\t (%4d) seconds.\n", + data.total_time_to_complete_off_line); }