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

Defines

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

Define 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 2370 of file ataprint.cpp.

static void ataPrintSCTCapability ( const ata_identify_device drive) [static]

Definition at line 1046 of file ataprint.cpp.

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

Definition at line 2241 of file ataprint.cpp.

static int ataPrintSCTStatus ( const ata_sct_status_response sts) [static]

Definition at line 2143 of file ataprint.cpp.

static int ataPrintSCTTempHist ( const ata_sct_temperature_history_table tmh) [static]

Definition at line 2184 of file ataprint.cpp.

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

Definition at line 1980 of file ataprint.cpp.

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

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

static int find_msb ( unsigned short  word) [static]

Definition at line 415 of file ataprint.cpp.

static std::string format_milliseconds ( unsigned  msec) [static]

Definition at line 1607 of file ataprint.cpp.

static std::string format_st_er_desc ( const ata_smart_errorlog_struct data) [inline, static]

Definition at line 390 of file ataprint.cpp.

static std::string format_st_er_desc ( const ata_smart_exterrlog_error_log data) [inline, static]

Definition at line 402 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 const char* get_ata_major_version ( const ata_identify_device drive) [static]

Definition at line 423 of file ataprint.cpp.

static const char* get_ata_minor_version ( const ata_identify_device drive) [static]

Definition at line 440 of file ataprint.cpp.

static const char* get_error_log_state_desc ( unsigned  state) [static]

Definition at line 1626 of file ataprint.cpp.

static const char* get_log_rw ( unsigned  logaddr) [static]

Definition at line 1162 of file ataprint.cpp.

static const char* get_sata_curspeed ( const ata_identify_device drive) [static]

Definition at line 538 of file ataprint.cpp.

static const char* get_sata_maxspeed ( const ata_identify_device drive) [static]

Definition at line 530 of file ataprint.cpp.

static const char* get_sata_speed ( int  level) [static]

Definition at line 518 of file ataprint.cpp.

static const char* get_sata_version ( const ata_identify_device drive) [static]

Definition at line 500 of file ataprint.cpp.

static const char* GetLogName ( unsigned  logaddr) [static]

Definition at line 1112 of file ataprint.cpp.

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

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

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

Definition at line 2254 of file ataprint.cpp.

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

Definition at line 2278 of file ataprint.cpp.

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

Definition at line 2298 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 
) [static]

Definition at line 1459 of file ataprint.cpp.

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

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

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

Definition at line 2336 of file ataprint.cpp.

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

Definition at line 1061 of file ataprint.cpp.

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

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

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

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

static void PrintSmartCapability ( const ata_smart_values data) [static]

Definition at line 841 of file ataprint.cpp.

static void PrintSmartConveyanceSelfTestPollingTime ( const ata_smart_values data) [static]

Definition at line 899 of file ataprint.cpp.

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

Definition at line 1642 of file ataprint.cpp.

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

Definition at line 864 of file ataprint.cpp.

static void PrintSmartExtendedSelfTestPollingTime ( const ata_smart_values data) [static]

Definition at line 889 of file ataprint.cpp.

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

Definition at line 1757 of file ataprint.cpp.

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

print_error_only

Definition at line 1905 of file ataprint.cpp.

static void PrintSmartOfflineCollectCap ( const ata_smart_values data) [static]

Definition at line 801 of file ataprint.cpp.

static void PrintSmartOfflineStatus ( const ata_smart_values data) [static]

Definition at line 692 of file ataprint.cpp.

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

Definition at line 712 of file ataprint.cpp.

static void PrintSmartShortSelfTestPollingTime ( const ata_smart_values data) [static]

Definition at line 879 of file ataprint.cpp.

static void PrintSmartTotalTimeCompleteOffline ( const ata_smart_values data) [static]

Definition at line 794 of file ataprint.cpp.

static const char* sct_device_state_msg ( unsigned char  state) [static]

Definition at line 2129 of file ataprint.cpp.

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

Definition at line 2107 of file ataprint.cpp.

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

Definition at line 2099 of file ataprint.cpp.


Variable Documentation

const char* ataprint_cpp_cvsid
Initial value:
"$Id: ataprint.cpp 3880 2014-03-05 17:38:44Z chrfranke $"
                                  ATAPRINT_H_CVSID

Definition at line 43 of file ataprint.cpp.

Initial value:
 {
  {  2, "List of supported log pages" },
  {  0, 0 }
}

Definition at line 1305 of file ataprint.cpp.

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 1310 of file ataprint.cpp.

Initial value:
 {
  {  2, "Free-Fall Statistics" },
  {  4, "Number of Free-Fall Events Detected" },
  {  4, "Overlimit Shock Events" },
  {  0, 0 }
}

Definition at line 1322 of file ataprint.cpp.

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 1329 of file ataprint.cpp.

Initial value:
 {
  {  2, "General Errors Statistics" },
  {  4, "Number of Reported Uncorrectable Errors" },

  {  4, "Resets Between Cmd Acceptance and Completion" },
  {  0, 0 }
}

Definition at line 1341 of file ataprint.cpp.

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 1349 of file ataprint.cpp.

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 1367 of file ataprint.cpp.

Initial value:
 {
  {  2, "Solid State Device Statistics" },
  {  1, "Percentage Used Endurance Indicator" },
  {  0, 0 }
}

Definition at line 1375 of file ataprint.cpp.

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

Definition at line 1392 of file ataprint.cpp.