From f12fc490eec5f7e8af41d78962cc97c56fc9a600 Mon Sep 17 00:00:00 2001
From: ballen4705 <ballen4705@4ea69e1a-61f1-4043-bf83-b5c94c648137>
Date: Sat, 26 Oct 2002 11:32:33 +0000
Subject: [PATCH] Should enable compilation with old 2.2 kernels with munged
 header files

git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@141 4ea69e1a-61f1-4043-bf83-b5c94c648137
---
 sm5/atacmds.c   | 12 +++++++++++-
 sm5/atacmds.cpp | 12 +++++++++++-
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/sm5/atacmds.c b/sm5/atacmds.c
index 05abc696e..7de7c9b9b 100644
--- a/sm5/atacmds.c
+++ b/sm5/atacmds.c
@@ -29,7 +29,7 @@
 #include <errno.h>
 #include "atacmds.h"
 
-const char *CVSid1="$Id: atacmds.c,v 1.25 2002/10/26 06:44:42 ballen4705 Exp $" CVSID1;
+const char *CVSid1="$Id: atacmds.c,v 1.26 2002/10/26 11:32:33 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
@@ -163,6 +163,7 @@ int ataReadHDIdentity (int device, struct hd_driveid *buf){
   // Hedrick about this on Oct 17 2002.  Please remove this comment
   // once the fix has made it into the stock kernel tree.
 
+#if 0
   // The following ifdef is a HACK to distinguish different versions
   // of the header file defining hd_driveid
 #ifdef CFA_REQ_EXT_ERROR_CODE
@@ -170,6 +171,15 @@ int ataReadHDIdentity (int device, struct hd_driveid *buf){
 #else
   driveidchecksum=buf->words160_255[95];
 #endif
+#else
+  // This way is ugly and you may feel ill -- but it always works...
+  {
+    unsigned short *rawstructure=
+      (unsigned short *)(parms+HDIO_DRIVE_CMD_HDR_SIZE);
+    driveidchecksum=rawstructure[255];
+  }
+#endif
+
   if ((driveidchecksum & 0x00ff) == 0x00a5){
     // Device identity structure contains a checksum
     unsigned char cksum=0;
diff --git a/sm5/atacmds.cpp b/sm5/atacmds.cpp
index 94b07e7aa..f1c672b72 100644
--- a/sm5/atacmds.cpp
+++ b/sm5/atacmds.cpp
@@ -29,7 +29,7 @@
 #include <errno.h>
 #include "atacmds.h"
 
-const char *CVSid1="$Id: atacmds.cpp,v 1.25 2002/10/26 06:44:42 ballen4705 Exp $" CVSID1;
+const char *CVSid1="$Id: atacmds.cpp,v 1.26 2002/10/26 11:32:33 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
@@ -163,6 +163,7 @@ int ataReadHDIdentity (int device, struct hd_driveid *buf){
   // Hedrick about this on Oct 17 2002.  Please remove this comment
   // once the fix has made it into the stock kernel tree.
 
+#if 0
   // The following ifdef is a HACK to distinguish different versions
   // of the header file defining hd_driveid
 #ifdef CFA_REQ_EXT_ERROR_CODE
@@ -170,6 +171,15 @@ int ataReadHDIdentity (int device, struct hd_driveid *buf){
 #else
   driveidchecksum=buf->words160_255[95];
 #endif
+#else
+  // This way is ugly and you may feel ill -- but it always works...
+  {
+    unsigned short *rawstructure=
+      (unsigned short *)(parms+HDIO_DRIVE_CMD_HDR_SIZE);
+    driveidchecksum=rawstructure[255];
+  }
+#endif
+
   if ((driveidchecksum & 0x00ff) == 0x00a5){
     // Device identity structure contains a checksum
     unsigned char cksum=0;
-- 
GitLab