From d2108d6e727f7d012daf1522bc4b2009a24b2e4a Mon Sep 17 00:00:00 2001 From: chrfranke <chrfranke@4ea69e1a-61f1-4043-bf83-b5c94c648137> Date: Fri, 24 Jul 2009 16:47:03 +0000 Subject: [PATCH] Remove 'scsiata.h'. git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@2861 4ea69e1a-61f1-4043-bf83-b5c94c648137 --- smartmontools/CHANGELOG | 3 + smartmontools/Doxyfile | 1 - smartmontools/Makefile.am | 2 - smartmontools/atacmds.cpp | 3 - smartmontools/os_win32/smartctl_vc8.vcproj | 4 -- smartmontools/os_win32/smartd_vc8.vcproj | 4 -- smartmontools/scsiata.cpp | 49 ++++++++++++-- smartmontools/scsiata.h | 79 ---------------------- smartmontools/scsiprint.cpp | 5 +- smartmontools/smartd.cpp | 1 - 10 files changed, 47 insertions(+), 104 deletions(-) delete mode 100644 smartmontools/scsiata.h diff --git a/smartmontools/CHANGELOG b/smartmontools/CHANGELOG index 969886248..a7164649d 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 8fb646618..50eeac753 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 ae1c43caf..efb3169ad 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 f7ed4e2c8..1aeaa378f 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 9ea7924b0..1f229fe5d 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 d9330b150..f9ce4e942 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 ff46c0f2f..d555540ec 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 b69e5ab13..000000000 --- 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 f60b2df1b..1d2fa83c2 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 4bc516ef0..794aef55e 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 -- GitLab