smartmontools  SVN Rev 4039
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_sata_version (const ata_identify_device *drive)
 
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 void print_device_statistics_page (const unsigned char *data, int page, bool &need_trailer)
 
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 (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 2460 of file ataprint.cpp.

static void ataPrintSCTCapability ( const ata_identify_device drive)
static

Definition at line 1085 of file ataprint.cpp.

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

Definition at line 2331 of file ataprint.cpp.

static int ataPrintSCTStatus ( const ata_sct_status_response sts)
static

Definition at line 2221 of file ataprint.cpp.

static int ataPrintSCTTempHist ( const ata_sct_temperature_history_table tmh)
static

Definition at line 2274 of file ataprint.cpp.

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

Definition at line 2058 of file ataprint.cpp.

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

Definition at line 1227 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 951 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 1685 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_error_log_state_desc ( unsigned  state)
static

Definition at line 1704 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 1204 of file ataprint.cpp.

static const char* get_sata_curspeed ( const ata_identify_device drive)
static

Definition at line 567 of file ataprint.cpp.

static const char* get_sata_maxspeed ( const ata_identify_device drive)
static

Definition at line 559 of file ataprint.cpp.

static const char* get_sata_speed ( int  level)
static

Definition at line 547 of file ataprint.cpp.

static const char* get_sata_version ( const ata_identify_device drive)
static

Definition at line 528 of file ataprint.cpp.

static const char* GetLogName ( unsigned  logaddr)
static

Definition at line 1150 of file ataprint.cpp.

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

Definition at line 1134 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 701 of file ataprint.cpp.

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

Definition at line 2344 of file ataprint.cpp.

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

Definition at line 2368 of file ataprint.cpp.

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

Definition at line 2388 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 1508 of file ataprint.cpp.

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

Definition at line 1437 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 576 of file ataprint.cpp.

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

Definition at line 2426 of file ataprint.cpp.

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

Definition at line 1100 of file ataprint.cpp.

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

Definition at line 1243 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 1311 of file ataprint.cpp.

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

Definition at line 1619 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 975 of file ataprint.cpp.

static void PrintSmartCapability ( const ata_smart_values data)
static

Definition at line 880 of file ataprint.cpp.

static void PrintSmartConveyanceSelfTestPollingTime ( const ata_smart_values data)
static

Definition at line 938 of file ataprint.cpp.

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

Definition at line 1720 of file ataprint.cpp.

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

Definition at line 903 of file ataprint.cpp.

static void PrintSmartExtendedSelfTestPollingTime ( const ata_smart_values data)
static

Definition at line 928 of file ataprint.cpp.

static int PrintSmartExtErrorLog ( const ata_smart_exterrlog log,
unsigned  nsectors,
unsigned  max_errors 
)
static

Definition at line 1835 of file ataprint.cpp.

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

print_error_only

Definition at line 1983 of file ataprint.cpp.

static void PrintSmartOfflineCollectCap ( const ata_smart_values data)
static

Definition at line 840 of file ataprint.cpp.

static void PrintSmartOfflineStatus ( const ata_smart_values data)
static

Definition at line 731 of file ataprint.cpp.

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

Definition at line 751 of file ataprint.cpp.

static void PrintSmartShortSelfTestPollingTime ( const ata_smart_values data)
static

Definition at line 918 of file ataprint.cpp.

static void PrintSmartTotalTimeCompleteOffline ( const ata_smart_values data)
static

Definition at line 833 of file ataprint.cpp.

static const char* sct_device_state_msg ( unsigned char  state)
static

Definition at line 2207 of file ataprint.cpp.

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

Definition at line 2185 of file ataprint.cpp.

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

Definition at line 2177 of file ataprint.cpp.

Variable Documentation

const char* ataprint_cpp_cvsid
Initial value:
= "$Id: ataprint.cpp 3999 2014-10-06 15:57:52Z 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 1348 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" },
{ 0, 0 }
}

Definition at line 1353 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 1365 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" },
{ 0, 0 }
}

Definition at line 1372 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 1384 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 1392 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 1410 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 1418 of file ataprint.cpp.

const devstat_entry_info* devstat_infos[]
Initial value:
= {
}
const devstat_entry_info devstat_info_0x06[]
Definition: ataprint.cpp:1410
const devstat_entry_info devstat_info_0x00[]
Definition: ataprint.cpp:1348
const devstat_entry_info devstat_info_0x03[]
Definition: ataprint.cpp:1372
const devstat_entry_info devstat_info_0x04[]
Definition: ataprint.cpp:1384
const devstat_entry_info devstat_info_0x05[]
Definition: ataprint.cpp:1392
const devstat_entry_info devstat_info_0x01[]
Definition: ataprint.cpp:1353
const devstat_entry_info devstat_info_0x07[]
Definition: ataprint.cpp:1418
const devstat_entry_info devstat_info_0x02[]
Definition: ataprint.cpp:1365

Definition at line 1424 of file ataprint.cpp.

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

Definition at line 1435 of file ataprint.cpp.