diff --git a/sm5/Makefile b/sm5/Makefile index e7c4fbc89992ecc7d5ba088e537d55adb5d6f8ba..ae1a2281d846d9ff4d44f7ec36091ca56b386fcf 100644 --- a/sm5/Makefile +++ b/sm5/Makefile @@ -2,7 +2,7 @@ # # Home page: http://smartmontools.sourceforge.net # -# $Id: Makefile,v 1.19 2002/10/20 19:40:23 ballen4705 Exp $ +# $Id: Makefile,v 1.20 2002/10/22 08:43:22 ballen4705 Exp $ # # Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net> # @@ -21,8 +21,15 @@ # California, Santa Cruz. http://ssrc.soe.ucsc.edu/ CC = gcc -# CFLAGS = -fsigned-char -Wall -g -CFLAGS = -fsigned-char -Wall -O2 + +# Debugging +# CFLAGS = -fsigned-char -Wall -g + +# Build against kernel header files. Change linux-2.4 to correct path for your system +# CFLAGS = -fsigned-char -Wall -O2 -I./usr/src/linux-2.4/include + +# Normal build +CFLAGS = -fsigned-char -Wall -O2 releasefiles=atacmds.c atacmds.h ataprint.c ataprint.h CHANGELOG COPYING extern.h Makefile\ README scsicmds.c scsicmds.h scsiprint.c scsiprint.h smartctl.8 smartctl.c smartctl.h\ diff --git a/sm5/atacmds.c b/sm5/atacmds.c index fb672d84ad7a9e663103e0c0dadae778fab12beb..15f447b9b5922c97f3a65e02a0f889be8c816d1a 100644 --- a/sm5/atacmds.c +++ b/sm5/atacmds.c @@ -1,4 +1,4 @@ -// $Id: atacmds.c,v 1.14 2002/10/21 16:11:58 ballen4705 Exp $ +// $Id: atacmds.c,v 1.15 2002/10/22 08:43:22 ballen4705 Exp $ /* * atacmds.c * @@ -144,6 +144,7 @@ int ataReadHDIdentity ( int device, struct hd_driveid *buf){ // Reads current Device Identity info (512 bytes) into buf int ataReadHDIdentity (int device, struct hd_driveid *buf){ + unsigned short driveidchecksum; unsigned char parms[HDIO_DRIVE_CMD_HDR_SIZE+sizeof(*buf)]= {WIN_IDENTIFY, 0, 0, 1,}; @@ -163,7 +164,15 @@ int ataReadHDIdentity (int device, struct hd_driveid *buf){ // 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 ((buf->words160_255[95] & 0x00ff) == 0x00a5){ + + // 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 + driveidchecksum=buf->words160_255[95]; +#endif + if ((driveidchecksum & 0x00ff) == 0x00a5){ // Device identity structure contains a checksum unsigned char cksum=0; int i; diff --git a/sm5/atacmds.cpp b/sm5/atacmds.cpp index 5c0ee3d28869839590569c65b8da7552a751f84b..6982de9a8994817f3b355dad112d9614ce1c8872 100644 --- a/sm5/atacmds.cpp +++ b/sm5/atacmds.cpp @@ -1,4 +1,4 @@ -// $Id: atacmds.cpp,v 1.14 2002/10/21 16:11:58 ballen4705 Exp $ +// $Id: atacmds.cpp,v 1.15 2002/10/22 08:43:22 ballen4705 Exp $ /* * atacmds.c * @@ -144,6 +144,7 @@ int ataReadHDIdentity ( int device, struct hd_driveid *buf){ // Reads current Device Identity info (512 bytes) into buf int ataReadHDIdentity (int device, struct hd_driveid *buf){ + unsigned short driveidchecksum; unsigned char parms[HDIO_DRIVE_CMD_HDR_SIZE+sizeof(*buf)]= {WIN_IDENTIFY, 0, 0, 1,}; @@ -163,7 +164,15 @@ int ataReadHDIdentity (int device, struct hd_driveid *buf){ // 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 ((buf->words160_255[95] & 0x00ff) == 0x00a5){ + + // 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 + driveidchecksum=buf->words160_255[95]; +#endif + if ((driveidchecksum & 0x00ff) == 0x00a5){ // Device identity structure contains a checksum unsigned char cksum=0; int i; diff --git a/sm5/scsicmds.c b/sm5/scsicmds.c index 23fe5c8df2c4914219243352302b325172acf830..e2c276f09be3d0e1d4c2b858ccc73d8a4b49adc5 100644 --- a/sm5/scsicmds.c +++ b/sm5/scsicmds.c @@ -1,4 +1,4 @@ -// $Id: scsicmds.c,v 1.7 2002/10/15 14:24:27 ballen4705 Exp $ +// $Id: scsicmds.c,v 1.8 2002/10/22 08:43:22 ballen4705 Exp $ /* * scsicmds.c @@ -30,6 +30,8 @@ #include <unistd.h> #include <sys/ioctl.h> #include <linux/hdreg.h> +// We do NOT want to include the kernel SCSI header file, just user space one +#define _LINUX_SCSI_H #include <scsi/scsi.h> #include "scsicmds.h" diff --git a/sm5/scsicmds.cpp b/sm5/scsicmds.cpp index 9a0757e16b2f312853901c3c571c709ba168c383..d8fa1eb48c21d370533d16deb5c59929e1993697 100644 --- a/sm5/scsicmds.cpp +++ b/sm5/scsicmds.cpp @@ -1,4 +1,4 @@ -// $Id: scsicmds.cpp,v 1.7 2002/10/15 14:24:27 ballen4705 Exp $ +// $Id: scsicmds.cpp,v 1.8 2002/10/22 08:43:22 ballen4705 Exp $ /* * scsicmds.c @@ -30,6 +30,8 @@ #include <unistd.h> #include <sys/ioctl.h> #include <linux/hdreg.h> +// We do NOT want to include the kernel SCSI header file, just user space one +#define _LINUX_SCSI_H #include <scsi/scsi.h> #include "scsicmds.h" diff --git a/sm5/scsicmds.h b/sm5/scsicmds.h index 5d0b1051e1225bcfc2617a9dd7f70f272158f725..7843da88c6d2521c07ff30963255ddfaa0b9fb3e 100644 --- a/sm5/scsicmds.h +++ b/sm5/scsicmds.h @@ -1,4 +1,4 @@ -// $Id: scsicmds.h,v 1.5 2002/10/15 14:24:27 ballen4705 Exp $ +// $Id: scsicmds.h,v 1.6 2002/10/22 08:43:22 ballen4705 Exp $ /* * scsicmds.h * @@ -28,6 +28,38 @@ #define SCSICMDS_H_ +#ifndef LOG_SENSE +#define LOG_SENSE 0x4d +#endif + +#ifndef MODE_SENSE +#define MODE_SENSE 0x1a +#endif + +#ifndef MODE_SELECT +#define MODE_SELECT 0x15 +#endif + +#ifndef MODE_SELECT_10 +#define MODE_SELECT_10 0x55 +#endif + +#ifndef INQUIRY +#define INQUIRY 0x12 +#endif + +#ifndef REQUEST_SENSE +#define REQUEST_SENSE 0x03 +#endif + +#ifndef RECEIVE_DIAGNOSTIC +#define RECEIVE_DIAGNOSTIC 0x1c +#endif + +#ifndef SEND_DIAGNOSTIC +#define SEND_DIAGNOSTIC 0x1d +#endif + #include <stdio.h> #include <stdlib.h> #include <string.h>