diff --git a/smartmontools/CHANGELOG b/smartmontools/CHANGELOG index 969886248156ea1bdd8b3cc038c0142ba9fd4b8a..a7164649dd8ea6984e5c0d633c08d4f00a2c7d67 100644 --- a/smartmontools/CHANGELOG +++ b/smartmontools/CHANGELOG @@ -42,6 +42,9 @@ NOTES FOR FUTURE RELEASES: see TODO file. <DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE> + [CF] Remove 'scsiata.h'. The 'scsiata.cpp' module now implements + parts of 'dev_interface.h'. + [CF] smartctl: Don't report an attribute as failed if threshold is 0. [CF] Print only one warning on checksum errors in multi sector log. diff --git a/smartmontools/Doxyfile b/smartmontools/Doxyfile index 8fb6466185b57e7bee26b1c4beec545b6f3a641e..50eeac75343d30c5282bdf6373884015622f5a97 100644 --- a/smartmontools/Doxyfile +++ b/smartmontools/Doxyfile @@ -84,7 +84,6 @@ INPUT = INPUT_ENCODING = UTF-8 FILE_PATTERNS = dev*.h \ dev*.cpp \ - scsiata.h \ scsiata.cpp RECURSIVE = NO EXCLUDE = diff --git a/smartmontools/Makefile.am b/smartmontools/Makefile.am index ae1c43caf3ec3402abf61e23b67110036d2b6c87..efb3169ad529bb207d3e672893c9810dbb9c5e37 100644 --- a/smartmontools/Makefile.am +++ b/smartmontools/Makefile.am @@ -39,7 +39,6 @@ smartd_SOURCES = smartd.cpp \ scsicmds.cpp \ scsicmds.h \ scsiata.cpp \ - scsiata.h \ utility.cpp \ utility.h @@ -109,7 +108,6 @@ smartctl_SOURCES= smartctl.cpp \ scsicmds.cpp \ scsicmds.h \ scsiata.cpp \ - scsiata.h \ scsiprint.cpp \ scsiprint.h \ utility.cpp \ diff --git a/smartmontools/atacmds.cpp b/smartmontools/atacmds.cpp index f7ed4e2c8a1b1f22aeac951ea625841a2af1048f..1aeaa378ff424f46e42db2d4ba65c7fead15f8f8 100644 --- a/smartmontools/atacmds.cpp +++ b/smartmontools/atacmds.cpp @@ -33,13 +33,10 @@ #include "config.h" #include "int64.h" #include "atacmds.h" -#include "scsiata.h" #include "extern.h" #include "utility.h" #include "dev_ata_cmd_set.h" // for parsed_ata_device -#include <algorithm> // std::sort - const char * atacmds_cpp_cvsid = "$Id$" ATACMDS_H_CVSID; diff --git a/smartmontools/os_win32/smartctl_vc8.vcproj b/smartmontools/os_win32/smartctl_vc8.vcproj index 9ea7924b0a134e60ceb3c081fe297e3bcebcf175..1f229fe5d88c00d3360a526b6456a9a9fcbf2e82 100644 --- a/smartmontools/os_win32/smartctl_vc8.vcproj +++ b/smartmontools/os_win32/smartctl_vc8.vcproj @@ -945,10 +945,6 @@ RelativePath="..\scsiata.cpp" > </File> - <File - RelativePath="..\scsiata.h" - > - </File> <File RelativePath="..\scsicmds.cpp" > diff --git a/smartmontools/os_win32/smartd_vc8.vcproj b/smartmontools/os_win32/smartd_vc8.vcproj index d9330b150df614051f4cbc35915e8931c9fe306b..f9ce4e942d8414027fe525443ae3e78be9a87a91 100644 --- a/smartmontools/os_win32/smartd_vc8.vcproj +++ b/smartmontools/os_win32/smartd_vc8.vcproj @@ -865,10 +865,6 @@ RelativePath="..\scsiata.cpp" > </File> - <File - RelativePath="..\scsiata.h" - > - </File> <File RelativePath="..\scsicmds.cpp" > diff --git a/smartmontools/scsiata.cpp b/smartmontools/scsiata.cpp index ff46c0f2fe37da0b499c81de3a1b44d8340d18c9..d555540ec13037bb9e0b10ad1593ca7c194f30d1 100644 --- a/smartmontools/scsiata.cpp +++ b/smartmontools/scsiata.cpp @@ -44,22 +44,57 @@ #include "int64.h" #include "extern.h" #include "scsicmds.h" -#include "scsiata.h" #include "atacmds.h" // ataReadHDIdentity() #include "utility.h" #include "dev_interface.h" #include "dev_ata_cmd_set.h" // ata_device_with_command_set #include "dev_tunnelled.h" // tunnelled_device<> -const char * scsiata_cpp_cvsid = "$Id$" - SCSIATA_H_CVSID; +const char * scsiata_cpp_cvsid = "$Id$"; /* for passing global control variables */ extern smartmonctrl *con; +/* This is a slightly stretched SCSI sense "descriptor" format header. + The addition is to allow the 0x70 and 0x71 response codes. The idea + is to place the salient data of both "fixed" and "descriptor" sense + format into one structure to ease application processing. + The original sense buffer should be kept around for those cases + in which more information is required (e.g. the LBA of a MEDIUM ERROR). */ +struct sg_scsi_sense_hdr { + unsigned char response_code; /* permit: 0x0, 0x70, 0x71, 0x72, 0x73 */ + unsigned char sense_key; + unsigned char asc; + unsigned char ascq; + unsigned char byte4; + unsigned char byte5; + unsigned char byte6; + unsigned char additional_length; +}; + +/* Maps the salient data from a sense buffer which is in either fixed or + descriptor format into a structure mimicking a descriptor format + header (i.e. the first 8 bytes of sense descriptor format). + If zero response code returns 0. Otherwise returns 1 and if 'sshp' is + non-NULL then zero all fields and then set the appropriate fields in + that structure. sshp::additional_length is always 0 for response + codes 0x70 and 0x71 (fixed format). */ +static int sg_scsi_normalize_sense(const unsigned char * sensep, int sb_len, + struct sg_scsi_sense_hdr * sshp); + +/* Attempt to find the first SCSI sense data descriptor that matches the + given 'desc_type'. If found return pointer to start of sense data + descriptor; otherwise (including fixed format sense data) returns NULL. */ +static const unsigned char * sg_scsi_sense_desc_find(const unsigned char * sensep, + int sense_len, int desc_type); + +#define SAT_ATA_PASSTHROUGH_12LEN 12 +#define SAT_ATA_PASSTHROUGH_16LEN 16 + #define DEF_SAT_ATA_PASSTHRU_SIZE 16 #define ATA_RETURN_DESCRIPTOR 9 + namespace sat { // no need to publish anything, name provided for Doxygen /// SAT support. @@ -397,8 +432,8 @@ static bool has_sat_pass_through(ata_device * dev, bool packet_interface = false /* Next two functions are borrowed from sg_lib.c in the sg3_utils package. Same copyrght owner, same license as this file. */ -int sg_scsi_normalize_sense(const unsigned char * sensep, int sb_len, - struct sg_scsi_sense_hdr * sshp) +static int sg_scsi_normalize_sense(const unsigned char * sensep, int sb_len, + struct sg_scsi_sense_hdr * sshp) { if (sshp) memset(sshp, 0, sizeof(struct sg_scsi_sense_hdr)); @@ -432,8 +467,8 @@ int sg_scsi_normalize_sense(const unsigned char * sensep, int sb_len, } -const unsigned char * sg_scsi_sense_desc_find(const unsigned char * sensep, - int sense_len, int desc_type) +static const unsigned char * sg_scsi_sense_desc_find(const unsigned char * sensep, + int sense_len, int desc_type) { int add_sen_len, add_len, desc_len, k; const unsigned char * descp; diff --git a/smartmontools/scsiata.h b/smartmontools/scsiata.h deleted file mode 100644 index b69e5ab1323ddc9a896ce706d79cc772201dd99e..0000000000000000000000000000000000000000 --- a/smartmontools/scsiata.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * scsiata.h - * - * Home page of code is: http://smartmontools.sourceforge.net - * - * Copyright (C) 2006-8 Douglas Gilbert <dougg@torque.net> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * You should have received a copy of the GNU General Public License - * (for example COPYING); if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - - -#ifndef SCSIATA_H_ -#define SCSIATA_H_ - -#define SCSIATA_H_CVSID "$Id: scsiata.h,v 1.6 2008/07/25 21:16:00 chrfranke Exp $\n" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <errno.h> - -#include "atacmds.h" - -#define SAT_ATA_PASSTHROUGH_12LEN 12 -#define SAT_ATA_PASSTHROUGH_16LEN 16 - -// Moved to C++ interface -//extern int sat_command_interface(int device, smart_command_set command, -// int select, char *data); -//extern int has_sat_pass_through(int device, int packet_interface); - -/* This is a slightly stretched SCSI sense "descriptor" format header. - The addition is to allow the 0x70 and 0x71 response codes. The idea - is to place the salient data of both "fixed" and "descriptor" sense - format into one structure to ease application processing. - The original sense buffer should be kept around for those cases - in which more information is required (e.g. the LBA of a MEDIUM ERROR). */ -struct sg_scsi_sense_hdr { - unsigned char response_code; /* permit: 0x0, 0x70, 0x71, 0x72, 0x73 */ - unsigned char sense_key; - unsigned char asc; - unsigned char ascq; - unsigned char byte4; - unsigned char byte5; - unsigned char byte6; - unsigned char additional_length; -}; - -/* Maps the salient data from a sense buffer which is in either fixed or - descriptor format into a structure mimicking a descriptor format - header (i.e. the first 8 bytes of sense descriptor format). - If zero response code returns 0. Otherwise returns 1 and if 'sshp' is - non-NULL then zero all fields and then set the appropriate fields in - that structure. sshp::additional_length is always 0 for response - codes 0x70 and 0x71 (fixed format). */ -extern int sg_scsi_normalize_sense(const unsigned char * sensep, - int sense_len, - struct sg_scsi_sense_hdr * sshp); - -/* Attempt to find the first SCSI sense data descriptor that matches the - given 'desc_type'. If found return pointer to start of sense data - descriptor; otherwise (including fixed format sense data) returns NULL. */ -extern const unsigned char * sg_scsi_sense_desc_find( - const unsigned char * sensep, int sense_len, int desc_type); - -// Moved to C++ interface -//extern int usbcypress_command_interface(int device, smart_command_set command, -// int select, char *data); - -#endif - diff --git a/smartmontools/scsiprint.cpp b/smartmontools/scsiprint.cpp index f60b2df1bde3948153111b1831a601e2b95f09ee..1d2fa83c2df4311a48aebd48a266469b1a0ffc9c 100644 --- a/smartmontools/scsiprint.cpp +++ b/smartmontools/scsiprint.cpp @@ -40,12 +40,11 @@ #include "scsiprint.h" #include "smartctl.h" #include "utility.h" -#include "scsiata.h" #define GBUF_SIZE 65535 -const char* scsiprint_c_cvsid="$Id: scsiprint.cpp,v 1.130 2009/06/24 04:10:10 dpgilbert Exp $" -CONFIG_H_CVSID EXTERN_H_CVSID INT64_H_CVSID SCSICMDS_H_CVSID SCSIPRINT_H_CVSID SMARTCTL_H_CVSID UTILITY_H_CVSID; +const char * scsiprint_c_cvsid = "$Id$" + SCSIPRINT_H_CVSID; // control block which points to external global control variables extern smartmonctrl *con; diff --git a/smartmontools/smartd.cpp b/smartmontools/smartd.cpp index 4bc516ef000dd700f03c7ca17c6f125a13b6e0c0..794aef55e4d2770344c79e4c9adc5f188d280458 100644 --- a/smartmontools/smartd.cpp +++ b/smartmontools/smartd.cpp @@ -84,7 +84,6 @@ extern "C" int __stdcall FreeConsole(void); #include "extern.h" #include "knowndrives.h" #include "scsicmds.h" -#include "scsiata.h" #include "utility.h" // This is for solaris, where signal() resets the handler to SIG_DFL