smartmontools SVN Rev 3317
Utility to control and monitor storage systems with "S.M.A.R.T."
Classes | Defines | Functions | Variables
scsicmds.cpp File Reference
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include "config.h"
#include "int64.h"
#include "scsicmds.h"
#include "atacmds.h"
#include "dev_interface.h"
#include "utility.h"
Include dependency graph for scsicmds.cpp:

Go to the source code of this file.

Classes

struct  scsi_opcode_name

Defines

#define DEXCPT_ENABLE   0x08
#define EWASC_ENABLE   0x10
#define DEXCPT_DISABLE   0xf7
#define EWASC_DISABLE   0xef
#define TEST_DISABLE   0xfb
#define SCSI_IEC_MP_BYTE2_ENABLED   0x10
#define SCSI_IEC_MP_BYTE2_TEST_MASK   0x4
#define SCSI_IEC_MP_MRIE   6
#define SCSI_IEC_MP_INTERVAL_T   0
#define SCSI_IEC_MP_REPORT_COUNT   1

Functions

void dStrHex (const char *str, int len, int no_ascii)
const char * scsi_get_opcode_name (UINT8 opcode)
void scsi_do_sense_disect (const struct scsi_cmnd_io *io_buf, struct scsi_sense_disect *out)
int scsiSimpleSenseFilter (const struct scsi_sense_disect *sinfo)
const char * scsiErrString (int scsiErr)
int scsi_vpd_dev_id_iter (const unsigned char *initial_desig_desc, int page_len, int *off, int m_assoc, int m_desig_type, int m_code_set)
int scsi_decode_lu_dev_id (const unsigned char *b, int blen, char *s, int slen, int *transport)
int scsiLogSense (scsi_device *device, int pagenum, int subpagenum, UINT8 *pBuf, int bufLen, int known_resp_len)
int scsiLogSelect (scsi_device *device, int pcr, int sp, int pc, int pagenum, int subpagenum, UINT8 *pBuf, int bufLen)
int scsiModeSense (scsi_device *device, int pagenum, int subpagenum, int pc, UINT8 *pBuf, int bufLen)
int scsiModeSelect (scsi_device *device, int sp, UINT8 *pBuf, int bufLen)
int scsiModeSense10 (scsi_device *device, int pagenum, int subpagenum, int pc, UINT8 *pBuf, int bufLen)
int scsiModeSelect10 (scsi_device *device, int sp, UINT8 *pBuf, int bufLen)
int scsiStdInquiry (scsi_device *device, UINT8 *pBuf, int bufLen)
int scsiInquiryVpd (scsi_device *device, int vpd_page, UINT8 *pBuf, int bufLen)
int scsiRequestSense (scsi_device *device, struct scsi_sense_disect *sense_info)
int scsiSendDiagnostic (scsi_device *device, int functioncode, UINT8 *pBuf, int bufLen)
int scsiReceiveDiagnostic (scsi_device *device, int pcv, int pagenum, UINT8 *pBuf, int bufLen)
static int _testunitready (scsi_device *device, struct scsi_sense_disect *sinfo)
int scsiTestUnitReady (scsi_device *device)
int scsiReadDefect10 (scsi_device *device, int req_plist, int req_glist, int dl_format, UINT8 *pBuf, int bufLen)
int scsiReadDefect12 (scsi_device *device, int req_plist, int req_glist, int dl_format, int addrDescIndex, UINT8 *pBuf, int bufLen)
int scsiReadCapacity10 (scsi_device *device, unsigned int *last_lbap, unsigned int *lb_sizep)
int scsiReadCapacity16 (scsi_device *device, UINT8 *pBuf, int bufLen)
uint64_t scsiGetSize (scsi_device *device, unsigned int *lb_sizep, int *lb_per_pb_expp)
int scsiGetProtPBInfo (scsi_device *device, unsigned char *rc16_12_31p)
int scsiModePageOffset (const UINT8 *resp, int len, int modese_len)
int scsiFetchIECmpage (scsi_device *device, struct scsi_iec_mode_page *iecp, int modese_len)
int scsi_IsExceptionControlEnabled (const struct scsi_iec_mode_page *iecp)
int scsi_IsWarningEnabled (const struct scsi_iec_mode_page *iecp)
int scsiSetExceptionControlAndWarning (scsi_device *device, int enabled, const struct scsi_iec_mode_page *iecp)
int scsiGetTemp (scsi_device *device, UINT8 *currenttemp, UINT8 *triptemp)
int scsiCheckIE (scsi_device *device, int hasIELogPage, int hasTempLogPage, UINT8 *asc, UINT8 *ascq, UINT8 *currenttemp, UINT8 *triptemp)
const char * scsiTapeAlertsTapeDevice (unsigned short code)
const char * scsiTapeAlertsChangerDevice (unsigned short code)
const char * scsiGetIEString (UINT8 asc, UINT8 ascq)
int scsiSmartIBMOfflineTest (scsi_device *device)
int scsiSmartDefaultSelfTest (scsi_device *device)
int scsiSmartShortSelfTest (scsi_device *device)
int scsiSmartExtendSelfTest (scsi_device *device)
int scsiSmartShortCapSelfTest (scsi_device *device)
int scsiSmartExtendCapSelfTest (scsi_device *device)
int scsiSmartSelfTestAbort (scsi_device *device)
int scsiFetchExtendedSelfTestTime (scsi_device *device, int *durationSec, int modese_len)
void scsiDecodeErrCounterPage (unsigned char *resp, struct scsiErrorCounter *ecp)
void scsiDecodeNonMediumErrPage (unsigned char *resp, struct scsiNonMediumError *nmep)
int scsiCountFailedSelfTests (scsi_device *fd, int noisy)
int scsiSelfTestInProgress (scsi_device *fd, int *inProgress)
int scsiFetchControlGLTSD (scsi_device *device, int modese_len, int current)
int scsiGetRPM (scsi_device *device, int modese_len, int *form_factorp, int *haw_zbcp)
int scsiGetSetCache (scsi_device *device, int modese_len, short int *wcep, short int *rcdp)
int scsiSetControlGLTSD (scsi_device *device, int enabled, int modese_len)
int scsiFetchTransportProtocol (scsi_device *device, int modese_len)
const unsigned char * sg_scsi_sense_desc_find (const unsigned char *sensep, int sense_len, int desc_type)
void scsi_format_id_string (char *out, const unsigned char *in, int n)

Variables

const char * scsicmds_c_cvsid
unsigned char scsi_debugmode = 0
supported_vpd_pagessupported_vpd_pages_p = NULL
static struct scsi_opcode_name opcode_name_arr []
static const char * vendor_specific = "<vendor specific>"
static const char * TapeAlertsMessageTable []
static const char * ChangerTapeAlertsMessageTable []
static const char * strs_for_asc_5d []
static const char * strs_for_asc_b []
static char spare_buff [128]

Define Documentation

#define DEXCPT_DISABLE   0xf7

Definition at line 1325 of file scsicmds.cpp.

#define DEXCPT_ENABLE   0x08

Definition at line 1323 of file scsicmds.cpp.

#define EWASC_DISABLE   0xef

Definition at line 1326 of file scsicmds.cpp.

#define EWASC_ENABLE   0x10

Definition at line 1324 of file scsicmds.cpp.

#define SCSI_IEC_MP_BYTE2_ENABLED   0x10

Definition at line 1414 of file scsicmds.cpp.

#define SCSI_IEC_MP_BYTE2_TEST_MASK   0x4

Definition at line 1415 of file scsicmds.cpp.

#define SCSI_IEC_MP_INTERVAL_T   0

Definition at line 1418 of file scsicmds.cpp.

#define SCSI_IEC_MP_MRIE   6

Definition at line 1417 of file scsicmds.cpp.

#define SCSI_IEC_MP_REPORT_COUNT   1

Definition at line 1419 of file scsicmds.cpp.

#define TEST_DISABLE   0xfb

Definition at line 1327 of file scsicmds.cpp.


Function Documentation

static int _testunitready ( scsi_device device,
struct scsi_sense_disect sinfo 
) [static]

Definition at line 1028 of file scsicmds.cpp.

void dStrHex ( const char *  str,
int  len,
int  no_ascii 
)

Definition at line 91 of file scsicmds.cpp.

int scsi_decode_lu_dev_id ( const unsigned char *  b,
int  blen,
char *  s,
int  slen,
int *  transport 
)

Definition at line 330 of file scsicmds.cpp.

void scsi_do_sense_disect ( const struct scsi_cmnd_io io_buf,
struct scsi_sense_disect out 
)

Definition at line 195 of file scsicmds.cpp.

void scsi_format_id_string ( char *  out,
const unsigned char *  in,
int  n 
)

Definition at line 2764 of file scsicmds.cpp.

const char* scsi_get_opcode_name ( UINT8  opcode)

Definition at line 176 of file scsicmds.cpp.

int scsi_IsExceptionControlEnabled ( const struct scsi_iec_mode_page iecp)

Definition at line 1382 of file scsicmds.cpp.

int scsi_IsWarningEnabled ( const struct scsi_iec_mode_page iecp)

Definition at line 1398 of file scsicmds.cpp.

int scsi_vpd_dev_id_iter ( const unsigned char *  initial_desig_desc,
int  page_len,
int *  off,
int  m_assoc,
int  m_desig_type,
int  m_code_set 
)

Definition at line 301 of file scsicmds.cpp.

int scsiCheckIE ( scsi_device device,
int  hasIELogPage,
int  hasTempLogPage,
UINT8 asc,
UINT8 ascq,
UINT8 currenttemp,
UINT8 triptemp 
)

Definition at line 1529 of file scsicmds.cpp.

int scsiCountFailedSelfTests ( scsi_device fd,
int  noisy 
)

Definition at line 2370 of file scsicmds.cpp.

void scsiDecodeErrCounterPage ( unsigned char *  resp,
struct scsiErrorCounter ecp 
)

Definition at line 2245 of file scsicmds.cpp.

void scsiDecodeNonMediumErrPage ( unsigned char *  resp,
struct scsiNonMediumError nmep 
)

Definition at line 2292 of file scsicmds.cpp.

const char* scsiErrString ( int  scsiErr)

Definition at line 257 of file scsicmds.cpp.

int scsiFetchControlGLTSD ( scsi_device device,
int  modese_len,
int  current 
)

Definition at line 2448 of file scsicmds.cpp.

int scsiFetchExtendedSelfTestTime ( scsi_device device,
int *  durationSec,
int  modese_len 
)

Definition at line 2207 of file scsicmds.cpp.

int scsiFetchIECmpage ( scsi_device device,
struct scsi_iec_mode_page iecp,
int  modese_len 
)

Definition at line 1335 of file scsicmds.cpp.

int scsiFetchTransportProtocol ( scsi_device device,
int  modese_len 
)

Definition at line 2703 of file scsicmds.cpp.

const char* scsiGetIEString ( UINT8  asc,
UINT8  ascq 
)

Definition at line 2083 of file scsicmds.cpp.

int scsiGetProtPBInfo ( scsi_device device,
unsigned char *  rc16_12_31p 
)

Definition at line 1273 of file scsicmds.cpp.

int scsiGetRPM ( scsi_device device,
int  modese_len,
int *  form_factorp,
int *  haw_zbcp 
)

Definition at line 2483 of file scsicmds.cpp.

int scsiGetSetCache ( scsi_device device,
int  modese_len,
short int *  wcep,
short int *  rcdp 
)

Definition at line 2529 of file scsicmds.cpp.

uint64_t scsiGetSize ( scsi_device device,
unsigned int *  lb_sizep,
int *  lb_per_pb_expp 
)

Definition at line 1228 of file scsicmds.cpp.

int scsiGetTemp ( scsi_device device,
UINT8 currenttemp,
UINT8 triptemp 
)

Definition at line 1506 of file scsicmds.cpp.

int scsiInquiryVpd ( scsi_device device,
int  vpd_page,
UINT8 pBuf,
int  bufLen 
)

Definition at line 814 of file scsicmds.cpp.

int scsiLogSelect ( scsi_device device,
int  pcr,
int  sp,
int  pc,
int  pagenum,
int  subpagenum,
UINT8 pBuf,
int  bufLen 
)

Definition at line 549 of file scsicmds.cpp.

int scsiLogSense ( scsi_device device,
int  pagenum,
int  subpagenum,
UINT8 pBuf,
int  bufLen,
int  known_resp_len 
)

Definition at line 456 of file scsicmds.cpp.

int scsiModePageOffset ( const UINT8 resp,
int  len,
int  modese_len 
)

Definition at line 1292 of file scsicmds.cpp.

int scsiModeSelect ( scsi_device device,
int  sp,
UINT8 pBuf,
int  bufLen 
)

Definition at line 641 of file scsicmds.cpp.

int scsiModeSelect10 ( scsi_device device,
int  sp,
UINT8 pBuf,
int  bufLen 
)

Definition at line 738 of file scsicmds.cpp.

int scsiModeSense ( scsi_device device,
int  pagenum,
int  subpagenum,
int  pc,
UINT8 pBuf,
int  bufLen 
)

Definition at line 585 of file scsicmds.cpp.

int scsiModeSense10 ( scsi_device device,
int  pagenum,
int  subpagenum,
int  pc,
UINT8 pBuf,
int  bufLen 
)

Definition at line 683 of file scsicmds.cpp.

int scsiReadCapacity10 ( scsi_device device,
unsigned int *  last_lbap,
unsigned int *  lb_sizep 
)

Definition at line 1152 of file scsicmds.cpp.

int scsiReadCapacity16 ( scsi_device device,
UINT8 pBuf,
int  bufLen 
)

Definition at line 1194 of file scsicmds.cpp.

int scsiReadDefect10 ( scsi_device device,
int  req_plist,
int  req_glist,
int  dl_format,
UINT8 pBuf,
int  bufLen 
)

Definition at line 1078 of file scsicmds.cpp.

int scsiReadDefect12 ( scsi_device device,
int  req_plist,
int  req_glist,
int  dl_format,
int  addrDescIndex,
UINT8 pBuf,
int  bufLen 
)

Definition at line 1112 of file scsicmds.cpp.

int scsiReceiveDiagnostic ( scsi_device device,
int  pcv,
int  pagenum,
UINT8 pBuf,
int  bufLen 
)

Definition at line 996 of file scsicmds.cpp.

int scsiRequestSense ( scsi_device device,
struct scsi_sense_disect sense_info 
)

Definition at line 876 of file scsicmds.cpp.

int scsiSelfTestInProgress ( scsi_device fd,
int *  inProgress 
)

Definition at line 2420 of file scsicmds.cpp.

int scsiSendDiagnostic ( scsi_device device,
int  functioncode,
UINT8 pBuf,
int  bufLen 
)

Definition at line 957 of file scsicmds.cpp.

int scsiSetControlGLTSD ( scsi_device device,
int  enabled,
int  modese_len 
)

Definition at line 2632 of file scsicmds.cpp.

int scsiSetExceptionControlAndWarning ( scsi_device device,
int  enabled,
const struct scsi_iec_mode_page iecp 
)

Definition at line 1429 of file scsicmds.cpp.

int scsiSimpleSenseFilter ( const struct scsi_sense_disect sinfo)

Definition at line 219 of file scsicmds.cpp.

int scsiSmartDefaultSelfTest ( scsi_device device)

Definition at line 2137 of file scsicmds.cpp.

int scsiSmartExtendCapSelfTest ( scsi_device device)

Definition at line 2182 of file scsicmds.cpp.

int scsiSmartExtendSelfTest ( scsi_device device)

Definition at line 2159 of file scsicmds.cpp.

int scsiSmartIBMOfflineTest ( scsi_device device)

Definition at line 2115 of file scsicmds.cpp.

int scsiSmartSelfTestAbort ( scsi_device device)

Definition at line 2194 of file scsicmds.cpp.

int scsiSmartShortCapSelfTest ( scsi_device device)

Definition at line 2171 of file scsicmds.cpp.

int scsiSmartShortSelfTest ( scsi_device device)

Definition at line 2148 of file scsicmds.cpp.

int scsiStdInquiry ( scsi_device device,
UINT8 pBuf,
int  bufLen 
)

Definition at line 780 of file scsicmds.cpp.

const char* scsiTapeAlertsChangerDevice ( unsigned short  code)

Definition at line 1948 of file scsicmds.cpp.

const char* scsiTapeAlertsTapeDevice ( unsigned short  code)

Definition at line 1812 of file scsicmds.cpp.

int scsiTestUnitReady ( scsi_device device)

Definition at line 1055 of file scsicmds.cpp.

const unsigned char* sg_scsi_sense_desc_find ( const unsigned char *  sensep,
int  sense_len,
int  desc_type 
)

Definition at line 2737 of file scsicmds.cpp.


Variable Documentation

const char* ChangerTapeAlertsMessageTable[] [static]

Definition at line 1821 of file scsicmds.cpp.

struct scsi_opcode_name opcode_name_arr[] [static]
Initial value:
 {
    
    {TEST_UNIT_READY, "test unit ready"},       
    {REQUEST_SENSE, "request sense"},           
    {INQUIRY, "inquiry"},                       
    {MODE_SELECT, "mode select(6)"},            
    {MODE_SENSE, "mode sense(6)"},              
    {START_STOP_UNIT, "start stop unit"},       
    {RECEIVE_DIAGNOSTIC, "receive diagnostic"}, 
    {SEND_DIAGNOSTIC, "send diagnostic"},       
    {READ_CAPACITY_10, "read capacity(10)"},    
    {READ_DEFECT_10, "read defect list(10)"},   
    {LOG_SELECT, "log select"},                 
    {LOG_SENSE, "log sense"},                   
    {MODE_SELECT_10, "mode select(10)"},        
    {MODE_SENSE_10, "mode sense(10)"},          
    {SAT_ATA_PASSTHROUGH_16, "ata pass-through(16)"}, 
    {READ_CAPACITY_16, "read capacity(16)"},    
    {REPORT_LUNS, "report luns"},               
    {SAT_ATA_PASSTHROUGH_12, "ata pass-through(12)"}, 
    {READ_DEFECT_12, "read defect list(12)"},   
}

Definition at line 148 of file scsicmds.cpp.

unsigned char scsi_debugmode = 0

Definition at line 56 of file scsicmds.cpp.

const char* scsicmds_c_cvsid
Initial value:
"$Id: scsicmds.cpp 3915 2014-06-19 18:24:57Z dpgilbert $"
  SCSICMDS_H_CVSID

Definition at line 52 of file scsicmds.cpp.

char spare_buff[128] [static]

Definition at line 2080 of file scsicmds.cpp.

const char* strs_for_asc_5d[] [static]

Definition at line 1960 of file scsicmds.cpp.

const char* strs_for_asc_b[] [static]
Initial value:
 {
          "WARNING",
               "WARNING - SPECIFIED TEMPERATURE EXCEEDED",
               "WARNING - ENCLOSURE DEGRADED"}

Definition at line 2075 of file scsicmds.cpp.

Definition at line 58 of file scsicmds.cpp.

const char* TapeAlertsMessageTable[] [static]

Definition at line 1587 of file scsicmds.cpp.

const char* vendor_specific = "<vendor specific>" [static]

Definition at line 171 of file scsicmds.cpp.