smartmontools  SVN Rev 4115
Utility to control and monitor storage systems with "S.M.A.R.T."
Classes | Macros | 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
 

Macros

#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)
 
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 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]
 

Macro Definition Documentation

#define DEXCPT_DISABLE   0xf7

Definition at line 1299 of file scsicmds.cpp.

#define DEXCPT_ENABLE   0x08

Definition at line 1297 of file scsicmds.cpp.

#define EWASC_DISABLE   0xef

Definition at line 1300 of file scsicmds.cpp.

#define EWASC_ENABLE   0x10

Definition at line 1298 of file scsicmds.cpp.

#define SCSI_IEC_MP_BYTE2_ENABLED   0x10

Definition at line 1388 of file scsicmds.cpp.

#define SCSI_IEC_MP_BYTE2_TEST_MASK   0x4

Definition at line 1389 of file scsicmds.cpp.

#define SCSI_IEC_MP_INTERVAL_T   0

Definition at line 1392 of file scsicmds.cpp.

#define SCSI_IEC_MP_MRIE   6

Definition at line 1391 of file scsicmds.cpp.

#define SCSI_IEC_MP_REPORT_COUNT   1

Definition at line 1393 of file scsicmds.cpp.

#define TEST_DISABLE   0xfb

Definition at line 1301 of file scsicmds.cpp.

Function Documentation

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

Definition at line 994 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 2714 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 1356 of file scsicmds.cpp.

int scsi_IsWarningEnabled ( const struct scsi_iec_mode_page iecp)

Definition at line 1372 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 1503 of file scsicmds.cpp.

int scsiCountFailedSelfTests ( scsi_device fd,
int  noisy 
)

Definition at line 2320 of file scsicmds.cpp.

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

Definition at line 2195 of file scsicmds.cpp.

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

Definition at line 2242 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 2398 of file scsicmds.cpp.

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

Definition at line 2157 of file scsicmds.cpp.

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

Definition at line 1309 of file scsicmds.cpp.

int scsiFetchTransportProtocol ( scsi_device device,
int  modese_len 
)

Definition at line 2653 of file scsicmds.cpp.

const char* scsiGetIEString ( UINT8  asc,
UINT8  ascq 
)

Definition at line 2057 of file scsicmds.cpp.

int scsiGetProtPBInfo ( scsi_device device,
unsigned char *  rc16_12_31p 
)

Definition at line 1247 of file scsicmds.cpp.

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

Definition at line 2433 of file scsicmds.cpp.

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

Definition at line 2479 of file scsicmds.cpp.

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

Definition at line 1202 of file scsicmds.cpp.

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

Definition at line 1480 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 1266 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 1126 of file scsicmds.cpp.

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

Definition at line 1168 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 1045 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 1083 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 2370 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 2582 of file scsicmds.cpp.

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

Definition at line 1403 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 2087 of file scsicmds.cpp.

int scsiSmartExtendCapSelfTest ( scsi_device device)

Definition at line 2132 of file scsicmds.cpp.

int scsiSmartExtendSelfTest ( scsi_device device)

Definition at line 2109 of file scsicmds.cpp.

int scsiSmartSelfTestAbort ( scsi_device device)

Definition at line 2144 of file scsicmds.cpp.

int scsiSmartShortCapSelfTest ( scsi_device device)

Definition at line 2121 of file scsicmds.cpp.

int scsiSmartShortSelfTest ( scsi_device device)

Definition at line 2098 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 1922 of file scsicmds.cpp.

const char* scsiTapeAlertsTapeDevice ( unsigned short  code)

Definition at line 1786 of file scsicmds.cpp.

int scsiTestUnitReady ( scsi_device device)

Definition at line 1021 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 2687 of file scsicmds.cpp.

Variable Documentation

const char* ChangerTapeAlertsMessageTable[]
static

Definition at line 1795 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)"},
}
#define SAT_ATA_PASSTHROUGH_12
Definition: scsicmds.h:101
#define READ_DEFECT_10
Definition: scsicmds.h:79
#define LOG_SELECT
Definition: scsicmds.h:49
#define READ_DEFECT_12
Definition: scsicmds.h:82
#define REQUEST_SENSE
Definition: scsicmds.h:70
#define INQUIRY
Definition: scsicmds.h:67
#define START_STOP_UNIT
Definition: scsicmds.h:85
#define MODE_SELECT_10
Definition: scsicmds.h:64
#define TEST_UNIT_READY
Definition: scsicmds.h:46
#define READ_CAPACITY_10
Definition: scsicmds.h:91
#define SAT_ATA_PASSTHROUGH_16
Definition: scsicmds.h:104
#define LOG_SENSE
Definition: scsicmds.h:52
#define SEND_DIAGNOSTIC
Definition: scsicmds.h:76
#define MODE_SENSE_10
Definition: scsicmds.h:58
#define RECEIVE_DIAGNOSTIC
Definition: scsicmds.h:73
#define MODE_SELECT
Definition: scsicmds.h:61
#define REPORT_LUNS
Definition: scsicmds.h:88
#define MODE_SENSE
Definition: scsicmds.h:55
#define READ_CAPACITY_16
Definition: scsicmds.h:94

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 4081 2015-05-10 16:42:50Z chrfranke $"
#define SCSICMDS_H_CVSID
Definition: scsicmds.h:35

Definition at line 52 of file scsicmds.cpp.

char spare_buff[128]
static

Definition at line 2054 of file scsicmds.cpp.

const char* strs_for_asc_5d[]
static

Definition at line 1934 of file scsicmds.cpp.

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

Definition at line 2049 of file scsicmds.cpp.

supported_vpd_pages* supported_vpd_pages_p = NULL

Definition at line 58 of file scsicmds.cpp.

const char* TapeAlertsMessageTable[]
static

Definition at line 1561 of file scsicmds.cpp.

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

Definition at line 171 of file scsicmds.cpp.