smartmontools SVN Rev 5388
Utility to control and monitor storage systems with "S.M.A.R.T."
Macros | Functions | Variables
scsiprint.cpp File Reference
#include "config.h"
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include "scsicmds.h"
#include "atacmds.h"
#include "dev_interface.h"
#include "scsiprint.h"
#include "smartctl.h"
#include "utility.h"
#include "sg_unaligned.h"
Include dependency graph for scsiprint.cpp:

Go to the source code of this file.

Macros

#define __STDC_FORMAT_MACROS   1
 
#define GBUF_SIZE   65532
 
#define ARRAY_SIZE(arr)   (sizeof(arr) / sizeof((arr)[0]))
 
#define LOG_RESP_LEN   252
 
#define LOG_RESP_LONG_LEN   ((62 * 256) + 252)
 
#define LOG_RESP_TAPE_ALERT_LEN   0x144
 
#define SCSI_SUPP_LOG_PAGES_MAX_COUNT   (252 + (62 * 128) + 126)
 
#define SCSI_VERSION_SPC_4   0x6
 
#define SCSI_VERSION_SPC_5   0x7
 
#define SCSI_VERSION_HIGHEST   SCSI_VERSION_SPC_5
 
#define T10_VENDOR_SEAGATE   "SEAGATE"
 
#define T10_VENDOR_HITACHI_1   "HITACHI"
 
#define T10_VENDOR_HITACHI_2   "HL-DT-ST"
 
#define T10_VENDOR_HITACHI_3   "HGST"
 

Functions

static bool seagate_or_hitachi (void)
 
static bool all_ffs (const uint8_t *bp, int b_len)
 
static std::string rtrim (const std::string &s, const char *t=" \t\n\r\f\v")
 
static void scsiGetSupportedLogPages (scsi_device *device)
 
static int scsiGetSmartData (scsi_device *device, bool attribs)
 
static int scsiPrintActiveTapeAlerts (scsi_device *device, int peripheral_type, bool from_health)
 
static void scsiGetStartStopData (scsi_device *device)
 
static void scsiPrintPendingDefectsLPage (scsi_device *device)
 
static void scsiPrintGrownDefectListLen (scsi_device *device)
 
static uint64_t variableLengthIntegerParam (const unsigned char *ucp)
 
static void scsiPrintSeagateCacheLPage (scsi_device *device)
 
static void scsiPrintSeagateFactoryLPage (scsi_device *device)
 
static void scsiPrintErrorCounterLog (scsi_device *device)
 
static int scsiPrintSelfTest (scsi_device *device)
 
static int scsiPrintBackgroundResults (scsi_device *device, bool only_pow_time)
 
static int scsiPrintSSMedia (scsi_device *device)
 
static int scsiPrintZBDeviceStats (scsi_device *device)
 
static int scsiPrintTapeDeviceStats (scsi_device *device)
 
static int scsiPrintFormatStatus (scsi_device *device)
 
static void show_sas_phy_event_info (const json::ref &jref, int peis, unsigned int val, unsigned thresh_val)
 
static void show_sas_port_param (int port_num, unsigned char *ucp, int param_len)
 
static int show_protocol_specific_port_page (unsigned char *resp, int len)
 
static int scsiPrintSasPhy (scsi_device *device, int reset)
 
static int scsiGetDriveInfo (scsi_device *device, uint8_t *peripheral_type, bool &have_zbc, bool all)
 
static int scsiSmartEnable (scsi_device *device)
 
static int scsiSmartDisable (scsi_device *device)
 
static void scsiPrintTemp (scsi_device *device)
 
static void scsiPrintEnviroReporting (scsi_device *device)
 
int scsiPrintMain (scsi_device *device, const scsi_print_options &options)
 

Variables

const char * scsiprint_c_cvsid
 
uint8_t gBuf [GBUF_SIZE]
 
static bool gSmartLPage = false
 
static bool gTempLPage = false
 
static bool gSelfTestLPage = false
 
static bool gStartStopLPage = false
 
static bool gReadECounterLPage = false
 
static bool gWriteECounterLPage = false
 
static bool gVerifyECounterLPage = false
 
static bool gNonMediumELPage = false
 
static bool gLastNErrorEvLPage = false
 
static bool gBackgroundResultsLPage = false
 
static bool gProtocolSpecificLPage = false
 
static bool gTapeAlertsLPage = false
 
static bool gSSMediaLPage = false
 
static bool gFormatStatusLPage = false
 
static bool gEnviroReportingLPage = false
 
static bool gEnviroLimitsLPage = false
 
static bool gUtilizationLPage = false
 
static bool gPendDefectsLPage = false
 
static bool gBackgroundOpLPage = false
 
static bool gLPSMisalignLPage = false
 
static bool gTapeDeviceStatsLPage = false
 
static bool gZBDeviceStatsLPage = false
 
static bool gSeagateCacheLPage = false
 
static bool gSeagateFactoryLPage = false
 
static bool gIecMPage = true
 
static int modese_len = 0
 
static int scsi_version
 
static char scsi_vendor [8+1]
 
static const char * logSenStr = "Log Sense"
 
static const char * logSenRspStr = "Log Sense response"
 
static const char *const severities = "CWI"
 
static const char * self_test_code []
 
static const char * self_test_result []
 
static const char * bms_status []
 
static const char * reassign_status []
 
static const char * peripheral_dt_arr [32]
 
static const char * transport_proto_arr []
 

Macro Definition Documentation

◆ __STDC_FORMAT_MACROS

#define __STDC_FORMAT_MACROS   1

Definition at line 15 of file scsiprint.cpp.

◆ ARRAY_SIZE

#define ARRAY_SIZE (   arr)    (sizeof(arr) / sizeof((arr)[0]))

Definition at line 36 of file scsiprint.cpp.

◆ GBUF_SIZE

#define GBUF_SIZE   65532

Definition at line 31 of file scsiprint.cpp.

◆ LOG_RESP_LEN

#define LOG_RESP_LEN   252

Definition at line 39 of file scsiprint.cpp.

◆ LOG_RESP_LONG_LEN

#define LOG_RESP_LONG_LEN   ((62 * 256) + 252)

Definition at line 40 of file scsiprint.cpp.

◆ LOG_RESP_TAPE_ALERT_LEN

#define LOG_RESP_TAPE_ALERT_LEN   0x144

Definition at line 41 of file scsiprint.cpp.

◆ SCSI_SUPP_LOG_PAGES_MAX_COUNT

#define SCSI_SUPP_LOG_PAGES_MAX_COUNT   (252 + (62 * 128) + 126)

Definition at line 44 of file scsiprint.cpp.

◆ SCSI_VERSION_HIGHEST

#define SCSI_VERSION_HIGHEST   SCSI_VERSION_SPC_5

Definition at line 84 of file scsiprint.cpp.

◆ SCSI_VERSION_SPC_4

#define SCSI_VERSION_SPC_4   0x6

Definition at line 82 of file scsiprint.cpp.

◆ SCSI_VERSION_SPC_5

#define SCSI_VERSION_SPC_5   0x7

Definition at line 83 of file scsiprint.cpp.

◆ T10_VENDOR_HITACHI_1

#define T10_VENDOR_HITACHI_1   "HITACHI"

Definition at line 90 of file scsiprint.cpp.

◆ T10_VENDOR_HITACHI_2

#define T10_VENDOR_HITACHI_2   "HL-DT-ST"

Definition at line 91 of file scsiprint.cpp.

◆ T10_VENDOR_HITACHI_3

#define T10_VENDOR_HITACHI_3   "HGST"

Definition at line 92 of file scsiprint.cpp.

◆ T10_VENDOR_SEAGATE

#define T10_VENDOR_SEAGATE   "SEAGATE"

Definition at line 89 of file scsiprint.cpp.

Function Documentation

◆ all_ffs()

static bool all_ffs ( const uint8_t *  bp,
int  b_len 
)
static

Definition at line 112 of file scsiprint.cpp.

◆ rtrim()

static std::string rtrim ( const std::string &  s,
const char *  t = " \t\n\r\f\v" 
)
static

Definition at line 124 of file scsiprint.cpp.

◆ scsiGetDriveInfo()

static int scsiGetDriveInfo ( scsi_device device,
uint8_t *  peripheral_type,
bool &  have_zbc,
bool  all 
)
static

Definition at line 2470 of file scsiprint.cpp.

◆ scsiGetSmartData()

static int scsiGetSmartData ( scsi_device device,
bool  attribs 
)
static

Definition at line 338 of file scsiprint.cpp.

◆ scsiGetStartStopData()

static void scsiGetStartStopData ( scsi_device device)
static

Definition at line 454 of file scsiprint.cpp.

◆ scsiGetSupportedLogPages()

static void scsiGetSupportedLogPages ( scsi_device device)
static

Definition at line 133 of file scsiprint.cpp.

◆ scsiPrintActiveTapeAlerts()

static int scsiPrintActiveTapeAlerts ( scsi_device device,
int  peripheral_type,
bool  from_health 
)
static

Definition at line 394 of file scsiprint.cpp.

◆ scsiPrintBackgroundResults()

static int scsiPrintBackgroundResults ( scsi_device device,
bool  only_pow_time 
)
static

Definition at line 1247 of file scsiprint.cpp.

◆ scsiPrintEnviroReporting()

static void scsiPrintEnviroReporting ( scsi_device device)
static

Definition at line 2969 of file scsiprint.cpp.

◆ scsiPrintErrorCounterLog()

static void scsiPrintErrorCounterLog ( scsi_device device)
static

Definition at line 878 of file scsiprint.cpp.

◆ scsiPrintFormatStatus()

static int scsiPrintFormatStatus ( scsi_device device)
static

Definition at line 1864 of file scsiprint.cpp.

◆ scsiPrintGrownDefectListLen()

static void scsiPrintGrownDefectListLen ( scsi_device device)
static

Definition at line 611 of file scsiprint.cpp.

◆ scsiPrintMain()

int scsiPrintMain ( scsi_device device,
const scsi_print_options options 
)

Definition at line 3126 of file scsiprint.cpp.

◆ scsiPrintPendingDefectsLPage()

static void scsiPrintPendingDefectsLPage ( scsi_device device)
static

Definition at line 538 of file scsiprint.cpp.

◆ scsiPrintSasPhy()

static int scsiPrintSasPhy ( scsi_device device,
int  reset 
)
static

Definition at line 2372 of file scsiprint.cpp.

◆ scsiPrintSeagateCacheLPage()

static void scsiPrintSeagateCacheLPage ( scsi_device device)
static

Definition at line 718 of file scsiprint.cpp.

◆ scsiPrintSeagateFactoryLPage()

static void scsiPrintSeagateFactoryLPage ( scsi_device device)
static

Definition at line 787 of file scsiprint.cpp.

◆ scsiPrintSelfTest()

static int scsiPrintSelfTest ( scsi_device device)
static

Definition at line 1035 of file scsiprint.cpp.

◆ scsiPrintSSMedia()

static int scsiPrintSSMedia ( scsi_device device)
static

Definition at line 1404 of file scsiprint.cpp.

◆ scsiPrintTapeDeviceStats()

static int scsiPrintTapeDeviceStats ( scsi_device device)
static

Definition at line 1593 of file scsiprint.cpp.

◆ scsiPrintTemp()

static void scsiPrintTemp ( scsi_device device)
static

Definition at line 2945 of file scsiprint.cpp.

◆ scsiPrintZBDeviceStats()

static int scsiPrintZBDeviceStats ( scsi_device device)
static

Definition at line 1464 of file scsiprint.cpp.

◆ scsiSmartDisable()

static int scsiSmartDisable ( scsi_device device)
static

Definition at line 2908 of file scsiprint.cpp.

◆ scsiSmartEnable()

static int scsiSmartEnable ( scsi_device device)
static

Definition at line 2871 of file scsiprint.cpp.

◆ seagate_or_hitachi()

static bool seagate_or_hitachi ( void  )
static

Definition at line 99 of file scsiprint.cpp.

◆ show_protocol_specific_port_page()

static int show_protocol_specific_port_page ( unsigned char *  resp,
int  len 
)
static

Definition at line 2348 of file scsiprint.cpp.

◆ show_sas_phy_event_info()

static void show_sas_phy_event_info ( const json::ref jref,
int  peis,
unsigned int  val,
unsigned  thresh_val 
)
static

Definition at line 1964 of file scsiprint.cpp.

◆ show_sas_port_param()

static void show_sas_port_param ( int  port_num,
unsigned char *  ucp,
int  param_len 
)
static

Definition at line 2167 of file scsiprint.cpp.

◆ variableLengthIntegerParam()

static uint64_t variableLengthIntegerParam ( const unsigned char *  ucp)
static

Definition at line 704 of file scsiprint.cpp.

Variable Documentation

◆ bms_status

const char* bms_status[]
static
Initial value:
= {
"no scans active",
"scan is active",
"pre-scan is active",
"halted due to fatal error",
"halted due to a vendor specific pattern of error",
"halted due to medium formatted without P-List",
"halted - vendor specific cause",
"halted due to temperature out of range",
"waiting until BMS interval timer expires",
}

Definition at line 1216 of file scsiprint.cpp.

◆ gBackgroundOpLPage

bool gBackgroundOpLPage = false
static

Definition at line 65 of file scsiprint.cpp.

◆ gBackgroundResultsLPage

bool gBackgroundResultsLPage = false
static

Definition at line 56 of file scsiprint.cpp.

◆ gBuf

uint8_t gBuf[GBUF_SIZE]

Definition at line 38 of file scsiprint.cpp.

◆ gEnviroLimitsLPage

bool gEnviroLimitsLPage = false
static

Definition at line 62 of file scsiprint.cpp.

◆ gEnviroReportingLPage

bool gEnviroReportingLPage = false
static

Definition at line 61 of file scsiprint.cpp.

◆ gFormatStatusLPage

bool gFormatStatusLPage = false
static

Definition at line 60 of file scsiprint.cpp.

◆ gIecMPage

bool gIecMPage = true
static

Definition at line 75 of file scsiprint.cpp.

◆ gLastNErrorEvLPage

bool gLastNErrorEvLPage = false
static

Definition at line 55 of file scsiprint.cpp.

◆ gLPSMisalignLPage

bool gLPSMisalignLPage = false
static

Definition at line 66 of file scsiprint.cpp.

◆ gNonMediumELPage

bool gNonMediumELPage = false
static

Definition at line 54 of file scsiprint.cpp.

◆ gPendDefectsLPage

bool gPendDefectsLPage = false
static

Definition at line 64 of file scsiprint.cpp.

◆ gProtocolSpecificLPage

bool gProtocolSpecificLPage = false
static

Definition at line 57 of file scsiprint.cpp.

◆ gReadECounterLPage

bool gReadECounterLPage = false
static

Definition at line 51 of file scsiprint.cpp.

◆ gSeagateCacheLPage

bool gSeagateCacheLPage = false
static

Definition at line 71 of file scsiprint.cpp.

◆ gSeagateFactoryLPage

bool gSeagateFactoryLPage = false
static

Definition at line 72 of file scsiprint.cpp.

◆ gSelfTestLPage

bool gSelfTestLPage = false
static

Definition at line 49 of file scsiprint.cpp.

◆ gSmartLPage

bool gSmartLPage = false
static

Definition at line 47 of file scsiprint.cpp.

◆ gSSMediaLPage

bool gSSMediaLPage = false
static

Definition at line 59 of file scsiprint.cpp.

◆ gStartStopLPage

bool gStartStopLPage = false
static

Definition at line 50 of file scsiprint.cpp.

◆ gTapeAlertsLPage

bool gTapeAlertsLPage = false
static

Definition at line 58 of file scsiprint.cpp.

◆ gTapeDeviceStatsLPage

bool gTapeDeviceStatsLPage = false
static

Definition at line 67 of file scsiprint.cpp.

◆ gTempLPage

bool gTempLPage = false
static

Definition at line 48 of file scsiprint.cpp.

◆ gUtilizationLPage

bool gUtilizationLPage = false
static

Definition at line 63 of file scsiprint.cpp.

◆ gVerifyECounterLPage

bool gVerifyECounterLPage = false
static

Definition at line 53 of file scsiprint.cpp.

◆ gWriteECounterLPage

bool gWriteECounterLPage = false
static

Definition at line 52 of file scsiprint.cpp.

◆ gZBDeviceStatsLPage

bool gZBDeviceStatsLPage = false
static

Definition at line 68 of file scsiprint.cpp.

◆ logSenRspStr

const char* logSenRspStr = "Log Sense response"
static

Definition at line 95 of file scsiprint.cpp.

◆ logSenStr

const char* logSenStr = "Log Sense"
static

Definition at line 94 of file scsiprint.cpp.

◆ modese_len

int modese_len = 0
static

Definition at line 78 of file scsiprint.cpp.

◆ peripheral_dt_arr

const char* peripheral_dt_arr[32]
static

Definition at line 2413 of file scsiprint.cpp.

◆ reassign_status

const char* reassign_status[]
static
Initial value:
= {
"Reserved [0x0]",
"Require Write or Reassign Blocks command",
"Successfully reassigned",
"Reserved [0x3]",
"Reassignment by disk failed",
"Recovered via rewrite in-place",
"Reassigned by app, has valid data",
"Reassigned by app, has no valid data",
"Unsuccessfully reassigned by app",
}

Definition at line 1228 of file scsiprint.cpp.

◆ scsi_vendor

char scsi_vendor[8+1]
static

Definition at line 88 of file scsiprint.cpp.

◆ scsi_version

int scsi_version
static

Definition at line 81 of file scsiprint.cpp.

◆ scsiprint_c_cvsid

const char* scsiprint_c_cvsid
Initial value:
= "$Id: scsiprint.cpp 5337 2022-02-27 07:53:55Z dpgilbert $"
#define SCSIPRINT_H_CVSID
Definition: scsiprint.h:19

Definition at line 33 of file scsiprint.cpp.

◆ self_test_code

const char* self_test_code[]
static
Initial value:
= {
"Default ",
"Background short",
"Background long ",
"Reserved(3) ",
"Abort background",
"Foreground short",
"Foreground long ",
"Reserved(7) "
}

Definition at line 1000 of file scsiprint.cpp.

◆ self_test_result

const char* self_test_result[]
static
Initial value:
= {
"Completed ",
"Aborted (by user command)",
"Aborted (device reset ?) ",
"Unknown error, incomplete",
"Completed, segment failed",
"Failed in first segment ",
"Failed in second segment ",
"Failed in segment",
"Reserved(8) ",
"Reserved(9) ",
"Reserved(10) ",
"Reserved(11) ",
"Reserved(12) ",
"Reserved(13) ",
"Reserved(14) ",
"Self test in progress ..."
}

Definition at line 1011 of file scsiprint.cpp.

◆ severities

const char* const severities = "CWI"
static

Definition at line 391 of file scsiprint.cpp.

◆ transport_proto_arr

const char* transport_proto_arr[]
static
Initial value:
= {
"Fibre channel (FCP-4)",
"Parallel SCSI (SPI-4)",
"SSA",
"IEEE 1394 (SBP-3)",
"RDMA (SRP)",
"iSCSI",
"SAS (SPL-4)",
"ADT",
"ATA (ACS-2)",
"UAS",
"SOP",
"PCIe",
"0xc",
"0xd",
"0xe",
"None given [0xf]"
}

Definition at line 2449 of file scsiprint.cpp.