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

Go to the source code of this file.

Classes

struct  devstat_entry_info
 

Macros

#define P(n)   (' ' <= p[n] && p[n] <= '~' ? (int)p[n] : '.')
 

Functions

static const char * infofound (const char *output)
 
static bool is_permissive ()
 
static std::string format_st_er_desc (unsigned char CR, unsigned char FR, unsigned char ST, unsigned char ER, unsigned short SC, const ata_smart_errorlog_error_struct *lba28_regs, const ata_smart_exterrlog_error *lba48_regs)
 
static std::string format_st_er_desc (const ata_smart_errorlog_struct *data)
 
static std::string format_st_er_desc (const ata_smart_exterrlog_error_log *data)
 
static const char * get_form_factor (unsigned short word168)
 
static int find_msb (unsigned short word)
 
static const char * get_ata_major_version (const ata_identify_device *drive)
 
static const char * get_ata_minor_version (const ata_identify_device *drive)
 
static const char * get_pata_version (unsigned short word222, char(&buf)[32])
 
static const char * get_sata_version (unsigned short word222, char(&buf)[32])
 
static const char * get_sata_speed (int level)
 
static const char * get_sata_maxspeed (const ata_identify_device *drive)
 
static const char * get_sata_curspeed (const ata_identify_device *drive)
 
static void print_drive_info (const ata_identify_device *drive, const ata_size_info &sizes, int rpm, const drive_settings *dbentry)
 
static const char * OfflineDataCollectionStatus (unsigned char status_byte)
 
static void PrintSmartOfflineStatus (const ata_smart_values *data)
 
static void PrintSmartSelfExecStatus (const ata_smart_values *data, firmwarebug_defs firmwarebugs)
 
static void PrintSmartTotalTimeCompleteOffline (const ata_smart_values *data)
 
static void PrintSmartOfflineCollectCap (const ata_smart_values *data)
 
static void PrintSmartCapability (const ata_smart_values *data)
 
static void PrintSmartErrorLogCapability (const ata_smart_values *data, const ata_identify_device *identity)
 
static void PrintSmartShortSelfTestPollingTime (const ata_smart_values *data)
 
static void PrintSmartExtendedSelfTestPollingTime (const ata_smart_values *data)
 
static void PrintSmartConveyanceSelfTestPollingTime (const ata_smart_values *data)
 
static int find_failed_attr (const ata_smart_values *data, const ata_smart_thresholds_pvt *thresholds, const ata_vendor_attr_defs &defs, int onlyfailed)
 
static void PrintSmartAttribWithThres (const ata_smart_values *data, const ata_smart_thresholds_pvt *thresholds, const ata_vendor_attr_defs &defs, int rpm, int onlyfailed, unsigned char format)
 
static void ataPrintSCTCapability (const ata_identify_device *drive)
 
static void PrintGeneralSmartValues (const ata_smart_values *data, const ata_identify_device *drive, firmwarebug_defs firmwarebugs)
 
static unsigned GetNumLogSectors (const ata_smart_log_directory *logdir, unsigned logaddr, bool gpl)
 
static const char * GetLogName (unsigned logaddr)
 
static const char * get_log_rw (unsigned logaddr)
 
const ata_smart_log_directoryfake_logdir (ata_smart_log_directory *logdir, const ata_print_options &options)
 
static void PrintLogDirectories (const ata_smart_log_directory *gplogdir, const ata_smart_log_directory *smartlogdir)
 
static void PrintLogPages (const char *type, const unsigned char *data, unsigned char logaddr, unsigned page, unsigned num_pages, unsigned max_pages)
 
static const char * get_device_statistics_page_name (int page)
 
static void print_device_statistics_page (const unsigned char *data, int page)
 
static bool print_device_statistics (ata_device *device, unsigned nsectors, const std::vector< int > &single_pages, bool all_pages, bool ssd_page, bool use_gplog)
 
static void PrintSataPhyEventCounters (const unsigned char *data, bool reset)
 
static std::string format_milliseconds (unsigned msec)
 
static const char * get_error_log_state_desc (unsigned state)
 
static int PrintSmartErrorlog (const ata_smart_errorlog *data, firmwarebug_defs firmwarebugs)
 
static int PrintSmartExtErrorLog (ata_device *device, const firmwarebug_defs &firmwarebugs, const ata_smart_exterrlog *log, unsigned nsectors, unsigned max_errors)
 
static int PrintSmartExtSelfTestLog (const ata_smart_extselftestlog *log, unsigned nsectors, unsigned max_entries)
 
static void ataPrintSelectiveSelfTestLog (const ata_selective_self_test_log *log, const ata_smart_values *sv)
 
static const char * sct_ptemp (signed char x, char(&buf)[20])
 
static const char * sct_pbar (int x, char(&buf)[64])
 
static const char * sct_device_state_msg (unsigned char state)
 
static int ataPrintSCTStatus (const ata_sct_status_response *sts)
 
static int ataPrintSCTTempHist (const ata_sct_temperature_history_table *tmh)
 
static void ataPrintSCTErrorRecoveryControl (bool set, unsigned short read_timer, unsigned short write_timer)
 
static void print_aam_level (const char *msg, int level, int recommended=-1)
 
static void print_apm_level (const char *msg, int level)
 
static void print_ata_security_status (const char *msg, unsigned short state)
 
static void print_standby_timer (const char *msg, int timer, const ata_identify_device &drive)
 
int ataPrintMain (ata_device *device, const ata_print_options &options)
 

Variables

const char * ataprint_cpp_cvsid
 
const devstat_entry_info devstat_info_0x00 []
 
const devstat_entry_info devstat_info_0x01 []
 
const devstat_entry_info devstat_info_0x02 []
 
const devstat_entry_info devstat_info_0x03 []
 
const devstat_entry_info devstat_info_0x04 []
 
const devstat_entry_info devstat_info_0x05 []
 
const devstat_entry_info devstat_info_0x06 []
 
const devstat_entry_info devstat_info_0x07 []
 
const devstat_entry_infodevstat_infos []
 
const int num_devstat_infos = sizeof(devstat_infos)/sizeof(devstat_infos[0])
 

Macro Definition Documentation

#define P (   n)    (' ' <= p[n] && p[n] <= '~' ? (int)p[n] : '.')

Function Documentation

int ataPrintMain ( ata_device device,
const ata_print_options options 
)

Definition at line 2526 of file ataprint.cpp.

static void ataPrintSCTCapability ( const ata_identify_device drive)
static

Definition at line 1118 of file ataprint.cpp.

static void ataPrintSCTErrorRecoveryControl ( bool  set,
unsigned short  read_timer,
unsigned short  write_timer 
)
static

Definition at line 2397 of file ataprint.cpp.

static int ataPrintSCTStatus ( const ata_sct_status_response sts)
static

Definition at line 2287 of file ataprint.cpp.

static int ataPrintSCTTempHist ( const ata_sct_temperature_history_table tmh)
static

Definition at line 2340 of file ataprint.cpp.

static void ataPrintSelectiveSelfTestLog ( const ata_selective_self_test_log log,
const ata_smart_values sv 
)
static

Definition at line 2124 of file ataprint.cpp.

const ata_smart_log_directory* fake_logdir ( ata_smart_log_directory logdir,
const ata_print_options options 
)

Definition at line 1261 of file ataprint.cpp.

static int find_failed_attr ( const ata_smart_values data,
const ata_smart_thresholds_pvt thresholds,
const ata_vendor_attr_defs defs,
int  onlyfailed 
)
static

Definition at line 984 of file ataprint.cpp.

static int find_msb ( unsigned short  word)
static

Definition at line 433 of file ataprint.cpp.

static std::string format_milliseconds ( unsigned  msec)
static

Definition at line 1730 of file ataprint.cpp.

static std::string format_st_er_desc ( unsigned char  CR,
unsigned char  FR,
unsigned char  ST,
unsigned char  ER,
unsigned short  SC,
const ata_smart_errorlog_error_struct lba28_regs,
const ata_smart_exterrlog_error lba48_regs 
)
static

Definition at line 74 of file ataprint.cpp.

static std::string format_st_er_desc ( const ata_smart_errorlog_struct data)
inlinestatic

Definition at line 390 of file ataprint.cpp.

static std::string format_st_er_desc ( const ata_smart_exterrlog_error_log data)
inlinestatic

Definition at line 402 of file ataprint.cpp.

static const char* get_ata_major_version ( const ata_identify_device drive)
static

Definition at line 441 of file ataprint.cpp.

static const char* get_ata_minor_version ( const ata_identify_device drive)
static

Definition at line 458 of file ataprint.cpp.

static const char* get_device_statistics_page_name ( int  page)
static

Definition at line 1474 of file ataprint.cpp.

static const char* get_error_log_state_desc ( unsigned  state)
static

Definition at line 1749 of file ataprint.cpp.

static const char* get_form_factor ( unsigned short  word168)
static

Definition at line 415 of file ataprint.cpp.

static const char* get_log_rw ( unsigned  logaddr)
static

Definition at line 1238 of file ataprint.cpp.

static const char* get_pata_version ( unsigned short  word222,
char(&)  buf[32] 
)
static

Definition at line 532 of file ataprint.cpp.

static const char* get_sata_curspeed ( const ata_identify_device drive)
static

Definition at line 583 of file ataprint.cpp.

static const char* get_sata_maxspeed ( const ata_identify_device drive)
static

Definition at line 575 of file ataprint.cpp.

static const char* get_sata_speed ( int  level)
static

Definition at line 560 of file ataprint.cpp.

static const char* get_sata_version ( unsigned short  word222,
char(&)  buf[32] 
)
static

Definition at line 543 of file ataprint.cpp.

static const char* GetLogName ( unsigned  logaddr)
static

Definition at line 1183 of file ataprint.cpp.

static unsigned GetNumLogSectors ( const ata_smart_log_directory logdir,
unsigned  logaddr,
bool  gpl 
)
static

Definition at line 1167 of file ataprint.cpp.

static const char* infofound ( const char *  output)
static

Definition at line 47 of file ataprint.cpp.

static bool is_permissive ( )
static

Definition at line 53 of file ataprint.cpp.

static const char* OfflineDataCollectionStatus ( unsigned char  status_byte)
static

Definition at line 734 of file ataprint.cpp.

static void print_aam_level ( const char *  msg,
int  level,
int  recommended = -1 
)
static

Definition at line 2410 of file ataprint.cpp.

static void print_apm_level ( const char *  msg,
int  level 
)
static

Definition at line 2434 of file ataprint.cpp.

static void print_ata_security_status ( const char *  msg,
unsigned short  state 
)
static

Definition at line 2454 of file ataprint.cpp.

static bool print_device_statistics ( ata_device device,
unsigned  nsectors,
const std::vector< int > &  single_pages,
bool  all_pages,
bool  ssd_page,
bool  use_gplog 
)
static

Definition at line 1555 of file ataprint.cpp.

static void print_device_statistics_page ( const unsigned char *  data,
int  page 
)
static

Definition at line 1483 of file ataprint.cpp.

static void print_drive_info ( const ata_identify_device drive,
const ata_size_info sizes,
int  rpm,
const drive_settings dbentry 
)
static

Definition at line 592 of file ataprint.cpp.

static void print_standby_timer ( const char *  msg,
int  timer,
const ata_identify_device drive 
)
static

Definition at line 2492 of file ataprint.cpp.

static void PrintGeneralSmartValues ( const ata_smart_values data,
const ata_identify_device drive,
firmwarebug_defs  firmwarebugs 
)
static

Definition at line 1133 of file ataprint.cpp.

static void PrintLogDirectories ( const ata_smart_log_directory gplogdir,
const ata_smart_log_directory smartlogdir 
)
static

Definition at line 1277 of file ataprint.cpp.

static void PrintLogPages ( const char *  type,
const unsigned char *  data,
unsigned char  logaddr,
unsigned  page,
unsigned  num_pages,
unsigned  max_pages 
)
static

Definition at line 1345 of file ataprint.cpp.

static void PrintSataPhyEventCounters ( const unsigned char *  data,
bool  reset 
)
static

Definition at line 1664 of file ataprint.cpp.

static void PrintSmartAttribWithThres ( const ata_smart_values data,
const ata_smart_thresholds_pvt thresholds,
const ata_vendor_attr_defs defs,
int  rpm,
int  onlyfailed,
unsigned char  format 
)
static

Definition at line 1008 of file ataprint.cpp.

static void PrintSmartCapability ( const ata_smart_values data)
static

Definition at line 913 of file ataprint.cpp.

static void PrintSmartConveyanceSelfTestPollingTime ( const ata_smart_values data)
static

Definition at line 971 of file ataprint.cpp.

static int PrintSmartErrorlog ( const ata_smart_errorlog data,
firmwarebug_defs  firmwarebugs 
)
static

Definition at line 1765 of file ataprint.cpp.

static void PrintSmartErrorLogCapability ( const ata_smart_values data,
const ata_identify_device identity 
)
static

Definition at line 936 of file ataprint.cpp.

static void PrintSmartExtendedSelfTestPollingTime ( const ata_smart_values data)
static

Definition at line 961 of file ataprint.cpp.

static int PrintSmartExtErrorLog ( ata_device device,
const firmwarebug_defs firmwarebugs,
const ata_smart_exterrlog log,
unsigned  nsectors,
unsigned  max_errors 
)
static

Definition at line 1880 of file ataprint.cpp.

static int PrintSmartExtSelfTestLog ( const ata_smart_extselftestlog log,
unsigned  nsectors,
unsigned  max_entries 
)
static

print_error_only

Definition at line 2049 of file ataprint.cpp.

static void PrintSmartOfflineCollectCap ( const ata_smart_values data)
static

Definition at line 873 of file ataprint.cpp.

static void PrintSmartOfflineStatus ( const ata_smart_values data)
static

Definition at line 764 of file ataprint.cpp.

static void PrintSmartSelfExecStatus ( const ata_smart_values data,
firmwarebug_defs  firmwarebugs 
)
static

Definition at line 784 of file ataprint.cpp.

static void PrintSmartShortSelfTestPollingTime ( const ata_smart_values data)
static

Definition at line 951 of file ataprint.cpp.

static void PrintSmartTotalTimeCompleteOffline ( const ata_smart_values data)
static

Definition at line 866 of file ataprint.cpp.

static const char* sct_device_state_msg ( unsigned char  state)
static

Definition at line 2273 of file ataprint.cpp.

static const char* sct_pbar ( int  x,
char(&)  buf[64] 
)
static

Definition at line 2251 of file ataprint.cpp.

static const char* sct_ptemp ( signed char  x,
char(&)  buf[20] 
)
static

Definition at line 2243 of file ataprint.cpp.

Variable Documentation

const char* ataprint_cpp_cvsid
Initial value:
= "$Id: ataprint.cpp 4104 2015-06-03 18:50:39Z chrfranke $"
#define ATAPRINT_H_CVSID
Definition: ataprint.h:28

Definition at line 43 of file ataprint.cpp.

const devstat_entry_info devstat_info_0x00[]
Initial value:
= {
{ 2, "List of supported log pages" },
{ 0, 0 }
}

Definition at line 1381 of file ataprint.cpp.

const devstat_entry_info devstat_info_0x01[]
Initial value:
= {
{ 2, "General Statistics" },
{ 4, "Lifetime Power-On Resets" },
{ 4, "Power-on Hours" },
{ 6, "Logical Sectors Written" },
{ 6, "Number of Write Commands" },
{ 6, "Logical Sectors Read" },
{ 6, "Number of Read Commands" },
{ 6, "Date and Time TimeStamp" },
{ 4, "Pending Error Count" },
{ 2, "Workload Utilization" },
{ 6, "Utilization Usage Rate" },
{ 0, 0 }
}

Definition at line 1386 of file ataprint.cpp.

const devstat_entry_info devstat_info_0x02[]
Initial value:
= {
{ 2, "Free-Fall Statistics" },
{ 4, "Number of Free-Fall Events Detected" },
{ 4, "Overlimit Shock Events" },
{ 0, 0 }
}

Definition at line 1401 of file ataprint.cpp.

const devstat_entry_info devstat_info_0x03[]
Initial value:
= {
{ 2, "Rotating Media Statistics" },
{ 4, "Spindle Motor Power-on Hours" },
{ 4, "Head Flying Hours" },
{ 4, "Head Load Events" },
{ 4, "Number of Reallocated Logical Sectors" },
{ 4, "Read Recovery Attempts" },
{ 4, "Number of Mechanical Start Failures" },
{ 4, "Number of Realloc. Candidate Logical Sectors" },
{ 4, "Number of High Priority Unload Events" },
{ 0, 0 }
}

Definition at line 1408 of file ataprint.cpp.

const devstat_entry_info devstat_info_0x04[]
Initial value:
= {
{ 2, "General Errors Statistics" },
{ 4, "Number of Reported Uncorrectable Errors" },
{ 4, "Resets Between Cmd Acceptance and Completion" },
{ 0, 0 }
}

Definition at line 1421 of file ataprint.cpp.

const devstat_entry_info devstat_info_0x05[]
Initial value:
= {
{ 2, "Temperature Statistics" },
{ -1, "Current Temperature" },
{ -1, "Average Short Term Temperature" },
{ -1, "Average Long Term Temperature" },
{ -1, "Highest Temperature" },
{ -1, "Lowest Temperature" },
{ -1, "Highest Average Short Term Temperature" },
{ -1, "Lowest Average Short Term Temperature" },
{ -1, "Highest Average Long Term Temperature" },
{ -1, "Lowest Average Long Term Temperature" },
{ 4, "Time in Over-Temperature" },
{ -1, "Specified Maximum Operating Temperature" },
{ 4, "Time in Under-Temperature" },
{ -1, "Specified Minimum Operating Temperature" },
{ 0, 0 }
}

Definition at line 1429 of file ataprint.cpp.

const devstat_entry_info devstat_info_0x06[]
Initial value:
= {
{ 2, "Transport Statistics" },
{ 4, "Number of Hardware Resets" },
{ 4, "Number of ASR Events" },
{ 4, "Number of Interface CRC Errors" },
{ 0, 0 }
}

Definition at line 1447 of file ataprint.cpp.

const devstat_entry_info devstat_info_0x07[]
Initial value:
= {
{ 2, "Solid State Device Statistics" },
{ 1, "Percentage Used Endurance Indicator" },
{ 0, 0 }
}

Definition at line 1455 of file ataprint.cpp.

const devstat_entry_info* devstat_infos[]
Initial value:
= {
}
const devstat_entry_info devstat_info_0x06[]
Definition: ataprint.cpp:1447
const devstat_entry_info devstat_info_0x00[]
Definition: ataprint.cpp:1381
const devstat_entry_info devstat_info_0x03[]
Definition: ataprint.cpp:1408
const devstat_entry_info devstat_info_0x04[]
Definition: ataprint.cpp:1421
const devstat_entry_info devstat_info_0x05[]
Definition: ataprint.cpp:1429
const devstat_entry_info devstat_info_0x01[]
Definition: ataprint.cpp:1386
const devstat_entry_info devstat_info_0x07[]
Definition: ataprint.cpp:1455
const devstat_entry_info devstat_info_0x02[]
Definition: ataprint.cpp:1401

Definition at line 1461 of file ataprint.cpp.

const int num_devstat_infos = sizeof(devstat_infos)/sizeof(devstat_infos[0])

Definition at line 1472 of file ataprint.cpp.