smartmontools SVN Rev 5640
Utility to control and monitor storage systems with "S.M.A.R.T."
|
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include "config.h"
#include "scsicmds.h"
#include "dev_interface.h"
#include "utility.h"
#include "sg_unaligned.h"
Go to the source code of this file.
Classes | |
struct | scsi_sa_var_map |
struct | scsi_opcode_name |
Macros | |
#define | RSOC_RESP_SZ 4096 |
#define | RSOC_ALL_CMDS_CTDP_0 8 |
#define | RSOC_ALL_CMDS_CTDP_1 20 |
#define | RSOC_1_CMD_CTDP_0 36 |
#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 |
Enumerations | |
enum | scsi_sa_t { scsi_sa_none = 0 , scsi_sa_b1b4n5 , scsi_sa_b8b7n16 } |
Functions | |
static scsi_cmd_support | chk_lsense_spc (scsi_device *device) |
static int | my_isprint (uint8_t ch) |
static int | trimTrailingSpaces (char *b) |
static void | dStrHexHelper (const uint8_t *up, int len, int no_ascii, void(*out)(const char *s, void *ctx), void *ctx=nullptr) |
void | dStrHexFp (const uint8_t *up, int len, int no_ascii, FILE *fp) |
void | dStrHex (const uint8_t *up, int len, int no_ascii) |
bool | is_scsi_cdb (const uint8_t *cdbp, int clen) |
const char * | scsi_get_opcode_name (const uint8_t *cdbp) |
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) |
char * | scsi_get_sense_key_str (int sense_key, int buff_len, char *buff) |
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_t *pBuf, int bufLen, int known_resp_len) |
int | scsiLogSelect (scsi_device *device, int pcr, int sp, int pc, int pagenum, int subpagenum, uint8_t *pBuf, int bufLen) |
int | scsiModeSense (scsi_device *device, int pagenum, int subpagenum, int pc, uint8_t *pBuf, int bufLen) |
int | scsiModeSelect (scsi_device *device, int sp, uint8_t *pBuf, int bufLen) |
int | scsiModeSense10 (scsi_device *device, int pagenum, int subpagenum, int pc, uint8_t *pBuf, int bufLen) |
int | scsiModeSelect10 (scsi_device *device, int sp, uint8_t *pBuf, int bufLen) |
int | scsiStdInquiry (scsi_device *device, uint8_t *pBuf, int bufLen) |
int | scsiInquiryVpd (scsi_device *device, int vpd_page, uint8_t *pBuf, int bufLen) |
int | scsiRequestSense (scsi_device *device, struct scsi_sense_disect *sense_info) |
int | scsiSetPowerCondition (scsi_device *device, int power_cond, int pcond_modifier) |
int | scsiSendDiagnostic (scsi_device *device, int functioncode, uint8_t *pBuf, int bufLen) |
static int | _testunitready (scsi_device *device, struct scsi_sense_disect *sinfop) |
int | scsiTestUnitReady (scsi_device *device) |
int | scsiReadDefect10 (scsi_device *device, int req_plist, int req_glist, int dl_format, uint8_t *pBuf, int bufLen) |
int | scsiReadDefect12 (scsi_device *device, int req_plist, int req_glist, int dl_format, int addrDescIndex, uint8_t *pBuf, int bufLen) |
bool | scsi_pass_through_yield_sense (scsi_device *device, scsi_cmnd_io *iop, scsi_sense_disect &sinfo) |
int | scsiReadCapacity10 (scsi_device *device, unsigned int *last_lbap, unsigned int *lb_sizep) |
int | scsiReadCapacity16 (scsi_device *device, uint8_t *pBuf, int bufLen) |
int | scsiRSOCcmd (scsi_device *device, bool rctd, uint8_t rep_opt, uint8_t opcode, uint16_t serv_act, uint8_t *pBuf, int bufLen, int &rspLen) |
uint64_t | scsiGetSize (scsi_device *device, bool avoid_rcap16, struct scsi_readcap_resp *srrp) |
int | scsiModePageOffset (const uint8_t *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_t *currenttemp, uint8_t *triptemp) |
int | scsiCheckIE (scsi_device *device, int hasIELogPage, int hasTempLogPage, uint8_t *asc, uint8_t *ascq, uint8_t *currenttemp, uint8_t *triptemp) |
const char * | scsiTapeAlertsTapeDevice (unsigned short code) |
const char * | scsiTapeAlertsChangerDevice (unsigned short code) |
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, int allocLen) |
void | scsiDecodeNonMediumErrPage (unsigned char *resp, struct scsiNonMediumError *nmep, int allocLen) |
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 uint8_t *in, int n) |
char * | scsiGetIEString (uint8_t asc, uint8_t ascq, char *b, int blen) |
Variables | |
const char * | scsicmds_c_cvsid |
static const char * | logSenStr = "Log Sense" |
unsigned char | scsi_debugmode = 0 |
supported_vpd_pages * | supported_vpd_pages_p = nullptr |
static struct scsi_sa_var_map | sa_var_a [] |
static struct scsi_opcode_name | opcode_name_arr [] |
static const char * | vendor_specific = "<vendor specific>" |
static const char * | sense_key_desc [] |
static const char * | TapeAlertsMessageTable [] |
static const char * | ChangerTapeAlertsMessageTable [] |
static const char * | wn = "Warning" |
static const char * | wn1_9 [] |
static const char * | five_d_t [] |
static const char * | impfail = "impending failure" |
static const char * | impending0_c [] |
static const char * | pred = "prediction threshold exceeded" |
#define DEXCPT_DISABLE 0xf7 |
Definition at line 1828 of file scsicmds.cpp.
#define DEXCPT_ENABLE 0x08 |
Definition at line 1826 of file scsicmds.cpp.
#define EWASC_DISABLE 0xef |
Definition at line 1829 of file scsicmds.cpp.
#define EWASC_ENABLE 0x10 |
Definition at line 1827 of file scsicmds.cpp.
#define RSOC_1_CMD_CTDP_0 36 |
Definition at line 52 of file scsicmds.cpp.
#define RSOC_ALL_CMDS_CTDP_0 8 |
Definition at line 50 of file scsicmds.cpp.
#define RSOC_ALL_CMDS_CTDP_1 20 |
Definition at line 51 of file scsicmds.cpp.
#define RSOC_RESP_SZ 4096 |
Definition at line 49 of file scsicmds.cpp.
#define SCSI_IEC_MP_BYTE2_ENABLED 0x10 |
Definition at line 1913 of file scsicmds.cpp.
#define SCSI_IEC_MP_BYTE2_TEST_MASK 0x4 |
Definition at line 1914 of file scsicmds.cpp.
#define SCSI_IEC_MP_INTERVAL_T 0 |
Definition at line 1917 of file scsicmds.cpp.
#define SCSI_IEC_MP_MRIE 6 |
Definition at line 1916 of file scsicmds.cpp.
#define SCSI_IEC_MP_REPORT_COUNT 1 |
Definition at line 1918 of file scsicmds.cpp.
#define TEST_DISABLE 0xfb |
Definition at line 1830 of file scsicmds.cpp.
enum scsi_sa_t |
Enumerator | |
---|---|
scsi_sa_none | |
scsi_sa_b1b4n5 | |
scsi_sa_b8b7n16 |
Definition at line 440 of file scsicmds.cpp.
|
static |
Definition at line 1425 of file scsicmds.cpp.
|
static |
Definition at line 56 of file scsicmds.cpp.
void dStrHex | ( | const uint8_t * | up, |
int | len, | ||
int | no_ascii | ||
) |
Definition at line 368 of file scsicmds.cpp.
void dStrHexFp | ( | const uint8_t * | up, |
int | len, | ||
int | no_ascii, | ||
FILE * | fp | ||
) |
Definition at line 344 of file scsicmds.cpp.
|
static |
Definition at line 248 of file scsicmds.cpp.
bool is_scsi_cdb | ( | const uint8_t * | cdbp, |
int | clen | ||
) |
Definition at line 391 of file scsicmds.cpp.
|
inlinestatic |
Definition at line 230 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 747 of file scsicmds.cpp.
void scsi_do_sense_disect | ( | const struct scsi_cmnd_io * | io_buf, |
struct scsi_sense_disect * | out | ||
) |
Definition at line 565 of file scsicmds.cpp.
void scsi_format_id_string | ( | char * | out, |
const uint8_t * | in, | ||
int | n | ||
) |
Definition at line 3117 of file scsicmds.cpp.
const char * scsi_get_opcode_name | ( | const uint8_t * | cdbp | ) |
Definition at line 511 of file scsicmds.cpp.
char * scsi_get_sense_key_str | ( | int | sense_key, |
int | buff_len, | ||
char * | buff | ||
) |
Definition at line 695 of file scsicmds.cpp.
int scsi_IsExceptionControlEnabled | ( | const struct scsi_iec_mode_page * | iecp | ) |
Definition at line 1885 of file scsicmds.cpp.
int scsi_IsWarningEnabled | ( | const struct scsi_iec_mode_page * | iecp | ) |
Definition at line 1899 of file scsicmds.cpp.
bool scsi_pass_through_yield_sense | ( | scsi_device * | device, |
scsi_cmnd_io * | iop, | ||
scsi_sense_disect & | sinfo | ||
) |
Definition at line 1543 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 718 of file scsicmds.cpp.
int scsiCheckIE | ( | scsi_device * | device, |
int | hasIELogPage, | ||
int | hasTempLogPage, | ||
uint8_t * | asc, | ||
uint8_t * | ascq, | ||
uint8_t * | currenttemp, | ||
uint8_t * | triptemp | ||
) |
Definition at line 2028 of file scsicmds.cpp.
int scsiCountFailedSelfTests | ( | scsi_device * | fd, |
int | noisy | ||
) |
Definition at line 2722 of file scsicmds.cpp.
void scsiDecodeErrCounterPage | ( | unsigned char * | resp, |
struct scsiErrorCounter * | ecp, | ||
int | allocLen | ||
) |
Definition at line 2609 of file scsicmds.cpp.
void scsiDecodeNonMediumErrPage | ( | unsigned char * | resp, |
struct scsiNonMediumError * | nmep, | ||
int | allocLen | ||
) |
Definition at line 2654 of file scsicmds.cpp.
const char * scsiErrString | ( | int | scsiErr | ) |
Definition at line 630 of file scsicmds.cpp.
int scsiFetchControlGLTSD | ( | scsi_device * | device, |
int | modese_len, | ||
int | current | ||
) |
Definition at line 2801 of file scsicmds.cpp.
int scsiFetchExtendedSelfTestTime | ( | scsi_device * | device, |
int * | durationSec, | ||
int | modese_len | ||
) |
Definition at line 2557 of file scsicmds.cpp.
int scsiFetchIECmpage | ( | scsi_device * | device, |
struct scsi_iec_mode_page * | iecp, | ||
int | modese_len | ||
) |
Definition at line 1838 of file scsicmds.cpp.
int scsiFetchTransportProtocol | ( | scsi_device * | device, |
int | modese_len | ||
) |
Definition at line 3057 of file scsicmds.cpp.
char * scsiGetIEString | ( | uint8_t | asc, |
uint8_t | ascq, | ||
char * | b, | ||
int | blen | ||
) |
Definition at line 3198 of file scsicmds.cpp.
int scsiGetRPM | ( | scsi_device * | device, |
int | modese_len, | ||
int * | form_factorp, | ||
int * | haw_zbcp | ||
) |
Definition at line 2838 of file scsicmds.cpp.
int scsiGetSetCache | ( | scsi_device * | device, |
int | modese_len, | ||
short int * | wcep, | ||
short int * | rcdp | ||
) |
Definition at line 2883 of file scsicmds.cpp.
uint64_t scsiGetSize | ( | scsi_device * | device, |
bool | avoid_rcap16, | ||
struct scsi_readcap_resp * | srrp | ||
) |
Definition at line 1713 of file scsicmds.cpp.
int scsiGetTemp | ( | scsi_device * | device, |
uint8_t * | currenttemp, | ||
uint8_t * | triptemp | ||
) |
Definition at line 2000 of file scsicmds.cpp.
int scsiInquiryVpd | ( | scsi_device * | device, |
int | vpd_page, | ||
uint8_t * | pBuf, | ||
int | bufLen | ||
) |
Definition at line 1210 of file scsicmds.cpp.
int scsiLogSelect | ( | scsi_device * | device, |
int | pcr, | ||
int | sp, | ||
int | pc, | ||
int | pagenum, | ||
int | subpagenum, | ||
uint8_t * | pBuf, | ||
int | bufLen | ||
) |
Definition at line 962 of file scsicmds.cpp.
int scsiLogSense | ( | scsi_device * | device, |
int | pagenum, | ||
int | subpagenum, | ||
uint8_t * | pBuf, | ||
int | bufLen, | ||
int | known_resp_len | ||
) |
Definition at line 873 of file scsicmds.cpp.
int scsiModePageOffset | ( | const uint8_t * | resp, |
int | len, | ||
int | modese_len | ||
) |
Definition at line 1795 of file scsicmds.cpp.
int scsiModeSelect | ( | scsi_device * | device, |
int | sp, | ||
uint8_t * | pBuf, | ||
int | bufLen | ||
) |
Definition at line 1040 of file scsicmds.cpp.
int scsiModeSelect10 | ( | scsi_device * | device, |
int | sp, | ||
uint8_t * | pBuf, | ||
int | bufLen | ||
) |
Definition at line 1123 of file scsicmds.cpp.
int scsiModeSense | ( | scsi_device * | device, |
int | pagenum, | ||
int | subpagenum, | ||
int | pc, | ||
uint8_t * | pBuf, | ||
int | bufLen | ||
) |
Definition at line 994 of file scsicmds.cpp.
int scsiModeSense10 | ( | scsi_device * | device, |
int | pagenum, | ||
int | subpagenum, | ||
int | pc, | ||
uint8_t * | pBuf, | ||
int | bufLen | ||
) |
Definition at line 1079 of file scsicmds.cpp.
int scsiReadCapacity10 | ( | scsi_device * | device, |
unsigned int * | last_lbap, | ||
unsigned int * | lb_sizep | ||
) |
Definition at line 1609 of file scsicmds.cpp.
int scsiReadCapacity16 | ( | scsi_device * | device, |
uint8_t * | pBuf, | ||
int | bufLen | ||
) |
Definition at line 1645 of file scsicmds.cpp.
int scsiReadDefect10 | ( | scsi_device * | device, |
int | req_plist, | ||
int | req_glist, | ||
int | dl_format, | ||
uint8_t * | pBuf, | ||
int | bufLen | ||
) |
Definition at line 1472 of file scsicmds.cpp.
int scsiReadDefect12 | ( | scsi_device * | device, |
int | req_plist, | ||
int | req_glist, | ||
int | dl_format, | ||
int | addrDescIndex, | ||
uint8_t * | pBuf, | ||
int | bufLen | ||
) |
Definition at line 1506 of file scsicmds.cpp.
int scsiRequestSense | ( | scsi_device * | device, |
struct scsi_sense_disect * | sense_info | ||
) |
Definition at line 1268 of file scsicmds.cpp.
int scsiRSOCcmd | ( | scsi_device * | device, |
bool | rctd, | ||
uint8_t | rep_opt, | ||
uint8_t | opcode, | ||
uint16_t | serv_act, | ||
uint8_t * | pBuf, | ||
int | bufLen, | ||
int & | rspLen | ||
) |
Definition at line 1672 of file scsicmds.cpp.
int scsiSelfTestInProgress | ( | scsi_device * | fd, |
int * | inProgress | ||
) |
Definition at line 2773 of file scsicmds.cpp.
int scsiSendDiagnostic | ( | scsi_device * | device, |
int | functioncode, | ||
uint8_t * | pBuf, | ||
int | bufLen | ||
) |
Definition at line 1392 of file scsicmds.cpp.
int scsiSetControlGLTSD | ( | scsi_device * | device, |
int | enabled, | ||
int | modese_len | ||
) |
Definition at line 2987 of file scsicmds.cpp.
int scsiSetExceptionControlAndWarning | ( | scsi_device * | device, |
int | enabled, | ||
const struct scsi_iec_mode_page * | iecp | ||
) |
Definition at line 1928 of file scsicmds.cpp.
int scsiSetPowerCondition | ( | scsi_device * | device, |
int | power_cond, | ||
int | pcond_modifier | ||
) |
Definition at line 1361 of file scsicmds.cpp.
int scsiSimpleSenseFilter | ( | const struct scsi_sense_disect * | sinfo | ) |
Definition at line 587 of file scsicmds.cpp.
int scsiSmartDefaultSelfTest | ( | scsi_device * | device | ) |
Definition at line 2487 of file scsicmds.cpp.
int scsiSmartExtendCapSelfTest | ( | scsi_device * | device | ) |
Definition at line 2532 of file scsicmds.cpp.
int scsiSmartExtendSelfTest | ( | scsi_device * | device | ) |
Definition at line 2509 of file scsicmds.cpp.
int scsiSmartSelfTestAbort | ( | scsi_device * | device | ) |
Definition at line 2544 of file scsicmds.cpp.
int scsiSmartShortCapSelfTest | ( | scsi_device * | device | ) |
Definition at line 2521 of file scsicmds.cpp.
int scsiSmartShortSelfTest | ( | scsi_device * | device | ) |
Definition at line 2498 of file scsicmds.cpp.
int scsiStdInquiry | ( | scsi_device * | device, |
uint8_t * | pBuf, | ||
int | bufLen | ||
) |
Definition at line 1163 of file scsicmds.cpp.
const char * scsiTapeAlertsChangerDevice | ( | unsigned short | code | ) |
Definition at line 2477 of file scsicmds.cpp.
const char * scsiTapeAlertsTapeDevice | ( | unsigned short | code | ) |
Definition at line 2329 of file scsicmds.cpp.
int scsiTestUnitReady | ( | scsi_device * | device | ) |
Definition at line 1456 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 3090 of file scsicmds.cpp.
|
static |
Definition at line 236 of file scsicmds.cpp.
|
static |
Definition at line 2338 of file scsicmds.cpp.
|
static |
Definition at line 3161 of file scsicmds.cpp.
|
static |
Definition at line 3172 of file scsicmds.cpp.
|
static |
Definition at line 3170 of file scsicmds.cpp.
|
static |
Definition at line 42 of file scsicmds.cpp.
|
static |
Definition at line 478 of file scsicmds.cpp.
|
static |
Definition at line 3188 of file scsicmds.cpp.
|
static |
Definition at line 451 of file scsicmds.cpp.
unsigned char scsi_debugmode = 0 |
Definition at line 45 of file scsicmds.cpp.
const char* scsicmds_c_cvsid |
Definition at line 39 of file scsicmds.cpp.
|
static |
Definition at line 668 of file scsicmds.cpp.
supported_vpd_pages* supported_vpd_pages_p = nullptr |
Definition at line 47 of file scsicmds.cpp.
|
static |
Definition at line 2085 of file scsicmds.cpp.
|
static |
Definition at line 506 of file scsicmds.cpp.
|
static |
Definition at line 3147 of file scsicmds.cpp.
|
static |
Definition at line 3149 of file scsicmds.cpp.