diff --git a/sm5/atacmds.c b/sm5/atacmds.c index 7de7c9b9be380834094d8b7103a009e989fa926d..778c4d6747b88f2ceda7cc62ffc8b21b57672d8e 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.26 2002/10/26 11:32:33 ballen4705 Exp $" CVSID1; +const char *CVSid1="$Id: atacmds.c,v 1.27 2002/10/26 11:44: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 @@ -157,34 +157,33 @@ int ataReadHDIdentity (int device, struct hd_driveid *buf){ // copy data into driveid structure memcpy(buf,parms+HDIO_DRIVE_CMD_HDR_SIZE,sizeof(*buf)); - // Note -- the declaration that appears in - // /usr/include/linux/hdreg.h: short words160_255[95], is WRONG. - // It should say: short words160_255[96]. I have written to Andre - // 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 driveidchecksum=buf->integrity_word; #else + // Note -- the declaration that appears in + // /usr/include/linux/hdreg.h: short words160_255[95], is WRONG. + // It should say: short words160_255[96]. I have written to Andre + // Hedrick about this on Oct 17 2002. Please remove this comment + // once the fix has made it into the stock kernel tree. 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); + (unsigned short *)buf; driveidchecksum=rawstructure[255]; } #endif - + if ((driveidchecksum & 0x00ff) == 0x00a5){ // Device identity structure contains a checksum unsigned char cksum=0; int i; - + for (i=0;i<sizeof(*buf);i++) cksum+=parms[i+HDIO_DRIVE_CMD_HDR_SIZE]; diff --git a/sm5/atacmds.cpp b/sm5/atacmds.cpp index f1c672b722bc08a620a459a2fa4439aed12270b5..54d72c496a44aae66f21d6d3c68be6209e015115 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.26 2002/10/26 11:32:33 ballen4705 Exp $" CVSID1; +const char *CVSid1="$Id: atacmds.cpp,v 1.27 2002/10/26 11:44: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 @@ -157,34 +157,33 @@ int ataReadHDIdentity (int device, struct hd_driveid *buf){ // copy data into driveid structure memcpy(buf,parms+HDIO_DRIVE_CMD_HDR_SIZE,sizeof(*buf)); - // Note -- the declaration that appears in - // /usr/include/linux/hdreg.h: short words160_255[95], is WRONG. - // It should say: short words160_255[96]. I have written to Andre - // 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 driveidchecksum=buf->integrity_word; #else + // Note -- the declaration that appears in + // /usr/include/linux/hdreg.h: short words160_255[95], is WRONG. + // It should say: short words160_255[96]. I have written to Andre + // Hedrick about this on Oct 17 2002. Please remove this comment + // once the fix has made it into the stock kernel tree. 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); + (unsigned short *)buf; driveidchecksum=rawstructure[255]; } #endif - + if ((driveidchecksum & 0x00ff) == 0x00a5){ // Device identity structure contains a checksum unsigned char cksum=0; int i; - + for (i=0;i<sizeof(*buf);i++) cksum+=parms[i+HDIO_DRIVE_CMD_HDR_SIZE];