From 3bc7bc0630d33d09ea12dbd5a9ded1145d4f5c2c Mon Sep 17 00:00:00 2001 From: ballen4705 <ballen4705@4ea69e1a-61f1-4043-bf83-b5c94c648137> Date: Sat, 26 Oct 2002 19:59:01 +0000 Subject: [PATCH] Fixed errors that Bruno pointed out stopped the 2.2 kernel compilation git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@144 4ea69e1a-61f1-4043-bf83-b5c94c648137 --- sm5/atacmds.c | 20 ++++---- sm5/atacmds.cpp | 20 ++++---- sm5/atacmds.h | 4 +- sm5/ataprint.c | 130 ++++++++++++++++++++++------------------------- sm5/ataprint.cpp | 130 ++++++++++++++++++++++------------------------- 5 files changed, 144 insertions(+), 160 deletions(-) diff --git a/sm5/atacmds.c b/sm5/atacmds.c index 9f2e84254..7bce37b2f 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 25f512cbc..07f571ef3 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 511f6c287..439e45f68 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 6bc3d385f..5b99788f6 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 972a27c6c..2802fe6ab 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); } -- GitLab