|
smartmontools SVN Rev 5716
Utility to control and monitor storage systems with "S.M.A.R.T."
|
#include "config.h"#include <inttypes.h>#include <stdio.h>#include <string.h>#include <errno.h>#include <stdlib.h>#include <ctype.h>#include "atacmds.h"#include "knowndrives.h"#include "utility.h"#include "dev_ata_cmd_set.h"
Go to the source code of this file.
Classes | |
| struct | format_name_entry |
| class | anonymous_namespace{atacmds.cpp}::parsed_ata_device |
| struct | anonymous_namespace{atacmds.cpp}::parsed_ata_device::parsed_ata_command |
Namespaces | |
| namespace | anonymous_namespace{atacmds.cpp} |
Macros | |
| #define | __STDC_FORMAT_MACROS 1 |
| #define | SMART_CYL_LOW 0x4F |
| #define | SMART_CYL_HI 0xC2 |
| #define | SRET_STATUS_HI_EXCEEDED 0x2C |
| #define | SRET_STATUS_MID_EXCEEDED 0xF4 |
| #define | SWAPV(x) ((x) = get_swapx_val(x)) |
| #define | P(n) (' ' <= p[n] && p[n] <= '~' ? (int)p[n] : '.') |
Functions | |
| unsigned char | get_unc_attr_id (bool offline, const ata_vendor_attr_defs &defs, bool &increase) |
| bool | parse_attribute_def (const char *opt, ata_vendor_attr_defs &defs, ata_vendor_def_prior priority) |
| std::string | create_vendor_attribute_arg_list () |
| bool | parse_firmwarebug_def (const char *opt, firmwarebug_defs &firmwarebugs) |
| const char * | get_valid_firmwarebug_args () |
| void | swap2 (char *location) |
| void | swap4 (char *location) |
| void | swap8 (char *location) |
| template<typename T > | |
| static T | get_swapx_val (T x) |
| static void | invalidate_serno (ata_identify_device *id) |
| static const char * | preg (const ata_register &r, char(&buf)[8]) |
| static void | print_regs (const char *prefix, const ata_in_regs &r, const char *suffix="\n") |
| static void | print_regs (const char *prefix, const ata_out_regs &r, const char *suffix="\n") |
| static void | prettyprint (const unsigned char *p, const char *name) |
| int | smartcommandhandler (ata_device *device, smart_command_set command, int select, char *data) |
| void | ata_get_size_info (const ata_identify_device *id, ata_size_info &sizes) |
| unsigned char | checksum (const void *data) |
| static void | swapbytes (char *out, const char *in, size_t n) |
| static void | trim (char *out, const char *in) |
| void | ata_format_id_string (char *out, const unsigned char *in, int n) |
| int | ataCheckPowerMode (ata_device *device) |
| bool | ata_nodata_command (ata_device *device, unsigned char command, int sector_count) |
| bool | ata_set_features (ata_device *device, unsigned char features, int sector_count) |
| int | ata_read_identity (ata_device *device, ata_identify_device *buf, bool fix_swapped_id, unsigned char *raw_buf) |
| int | ata_get_wwn (const ata_identify_device *id, unsigned &oui, uint64_t &unique_id) |
| int | ata_get_rotation_rate (const ata_identify_device *id) |
| int | ataSmartSupport (const ata_identify_device *drive) |
| int | ataIsSmartEnabled (const ata_identify_device *drive) |
| int | ataReadSmartValues (ata_device *device, struct ata_smart_values *data) |
| static void | fixsamsungselftestlog (ata_smart_selftestlog *data) |
| int | ataReadSelfTestLog (ata_device *device, ata_smart_selftestlog *data, firmwarebug_defs firmwarebugs) |
| static void | check_multi_sector_sum (const void *data, unsigned nsectors, const char *msg) |
| bool | ataReadExtSelfTestLog (ata_device *device, ata_smart_extselftestlog *log, unsigned nsectors) |
| bool | ataWriteLogExt (ata_device *device, unsigned char logaddr, unsigned page, void *data, unsigned nsectors) |
| bool | ataReadLogExt (ata_device *device, unsigned char logaddr, unsigned char features, unsigned page, void *data, unsigned nsectors) |
| bool | ataReadSmartLog (ata_device *device, unsigned char logaddr, void *data, unsigned nsectors) |
| int | ataReadLogDirectory (ata_device *device, ata_smart_log_directory *data, bool gpl) |
| int | ataReadSelectiveSelfTestLog (ata_device *device, struct ata_selective_self_test_log *data) |
| int | ataWriteSelectiveSelfTestLog (ata_device *device, ata_selective_selftest_args &args, const ata_smart_values *sv, uint64_t num_sectors, const ata_selective_selftest_args *prev_args) |
| static void | fixsamsungerrorlog (ata_smart_errorlog *data) |
| static void | fixsamsungerrorlog2 (ata_smart_errorlog *data) |
| int | ataReadErrorLog (ata_device *device, ata_smart_errorlog *data, firmwarebug_defs firmwarebugs) |
| template<class T > | |
| static void | fix_exterrlog_lba_cmd (T &cmd) |
| static void | fix_exterrlog_lba (ata_smart_exterrlog *log, unsigned nsectors) |
| bool | ataReadExtErrorLog (ata_device *device, ata_smart_exterrlog *log, unsigned page, unsigned nsectors, firmwarebug_defs firmwarebugs) |
| int | ataReadSmartThresholds (ata_device *device, struct ata_smart_thresholds_pvt *data) |
| int | ataEnableSmart (ata_device *device) |
| int | ataDisableSmart (ata_device *device) |
| int | ataEnableAutoSave (ata_device *device) |
| int | ataDisableAutoSave (ata_device *device) |
| int | ataEnableAutoOffline (ata_device *device) |
| int | ataDisableAutoOffline (ata_device *device) |
| int | ataDoesSmartWork (ata_device *device) |
| int | ataSmartStatus2 (ata_device *device) |
| int | ataSmartTest (ata_device *device, int testtype, bool force, const ata_selective_selftest_args &selargs, const ata_smart_values *sv, uint64_t num_sectors) |
| int | TestTime (const ata_smart_values *data, int testtype) |
| bool | isSmartErrorLogCapable (const ata_smart_values *data, const ata_identify_device *identity) |
| bool | isSmartTestLogCapable (const ata_smart_values *data, const ata_identify_device *identity) |
| bool | isGeneralPurposeLoggingCapable (const ata_identify_device *identity) |
| ata_attr_state | ata_get_attr_state (const ata_smart_attribute &attr, int attridx, const ata_smart_threshold_entry *thresholds, const ata_vendor_attr_defs &defs, unsigned char *threshval) |
| uint64_t | ata_get_attr_raw_value (const ata_smart_attribute &attr, const ata_vendor_attr_defs &defs) |
| static int | check_temp_word (unsigned word) |
| static bool | check_temp_range (int t, unsigned char ut1, unsigned char ut2, int &lo, int &hi) |
| std::string | ata_format_attr_raw_value (const ata_smart_attribute &attr, const ata_vendor_attr_defs &defs) |
| std::string | ata_get_smart_attr_name (unsigned char id, const ata_vendor_attr_defs &defs, int rpm) |
| int | ata_find_attr_index (unsigned char id, const ata_smart_values &smartval) |
| unsigned char | ata_return_temperature_value (const ata_smart_values *data, const ata_vendor_attr_defs &defs) |
| int | ataReadSCTStatus (ata_device *device, ata_sct_status_response *sts) |
| int | ataReadSCTTempHist (ata_device *device, ata_sct_temperature_history_table *tmh, ata_sct_status_response *sts) |
| static int | ataGetSetSCTFeatureControl (ata_device *device, unsigned short feature_code, unsigned short state, bool persistent, bool set) |
| int | ataGetSetSCTWriteCacheReordering (ata_device *device, bool enable, bool persistent, bool set) |
| int | ataGetSetSCTWriteCache (ata_device *device, unsigned short state, bool persistent, bool set) |
| int | ataSetSCTTempInterval (ata_device *device, unsigned interval, bool persistent) |
| static int | ataGetSetSCTErrorRecoveryControltime (ata_device *device, unsigned type, bool set, unsigned short &time_limit, bool power_on, bool mfg_default) |
| int | ataGetSCTErrorRecoveryControltime (ata_device *device, unsigned type, unsigned short &time_limit, bool power_on) |
| int | ataSetSCTErrorRecoveryControltime (ata_device *device, unsigned type, unsigned short time_limit, bool power_on, bool mfg_default) |
| static const char * | anonymous_namespace{atacmds.cpp}::nextline (const char *s, int &lineno) |
| static int | anonymous_namespace{atacmds.cpp}::name2command (const char *s) |
| static bool | anonymous_namespace{atacmds.cpp}::matchcpy (char *dest, size_t size, const char *src, const regular_expression::match_range &srcmatch) |
| static int | anonymous_namespace{atacmds.cpp}::matchtoi (const char *src, const regular_expression::match_range &srcmatch, int defval) |
| ata_device * | get_parsed_ata_device (smart_interface *intf, const char *dev_name) |
Variables | |
| const char * | atacmds_cpp_cvsid |
| unsigned char | ata_debugmode = 0 |
| bool | dont_print_serial_number = false |
| const format_name_entry | format_names [] |
| const unsigned | num_format_names = sizeof(format_names)/sizeof(format_names[0]) |
| const char *const | map_old_vendor_opts [][2] |
| const unsigned | num_old_vendor_opts = sizeof(map_old_vendor_opts)/sizeof(map_old_vendor_opts[0]) |
| static const char *const | commandstrings [] |
| #define __STDC_FORMAT_MACROS 1 |
Definition at line 15 of file atacmds.cpp.
| #define P | ( | n | ) | (' ' <= p[n] && p[n] <= '~' ? (int)p[n] : '.') |
| #define SMART_CYL_HI 0xC2 |
Definition at line 41 of file atacmds.cpp.
| #define SMART_CYL_LOW 0x4F |
Definition at line 40 of file atacmds.cpp.
| #define SRET_STATUS_HI_EXCEEDED 0x2C |
Definition at line 47 of file atacmds.cpp.
| #define SRET_STATUS_MID_EXCEEDED 0xF4 |
Definition at line 48 of file atacmds.cpp.
| #define SWAPV | ( | x | ) | ((x) = get_swapx_val(x)) |
Definition at line 340 of file atacmds.cpp.
| int ata_find_attr_index | ( | unsigned char | id, |
| const ata_smart_values & | smartval | ||
| ) |
Definition at line 2146 of file atacmds.cpp.
| std::string ata_format_attr_raw_value | ( | const ata_smart_attribute & | attr, |
| const ata_vendor_attr_defs & | defs | ||
| ) |
Definition at line 1920 of file atacmds.cpp.
| void ata_format_id_string | ( | char * | out, |
| const unsigned char * | in, | ||
| int | n | ||
| ) |
Definition at line 762 of file atacmds.cpp.
| uint64_t ata_get_attr_raw_value | ( | const ata_smart_attribute & | attr, |
| const ata_vendor_attr_defs & | defs | ||
| ) |
Definition at line 1846 of file atacmds.cpp.
| ata_attr_state ata_get_attr_state | ( | const ata_smart_attribute & | attr, |
| int | attridx, | ||
| const ata_smart_threshold_entry * | thresholds, | ||
| const ata_vendor_attr_defs & | defs, | ||
| unsigned char * | threshval | ||
| ) |
Definition at line 1796 of file atacmds.cpp.
| int ata_get_rotation_rate | ( | const ata_identify_device * | id | ) |
Definition at line 920 of file atacmds.cpp.
| void ata_get_size_info | ( | const ata_identify_device * | id, |
| ata_size_info & | sizes | ||
| ) |
Definition at line 658 of file atacmds.cpp.
| std::string ata_get_smart_attr_name | ( | unsigned char | id, |
| const ata_vendor_attr_defs & | defs, | ||
| int | rpm | ||
| ) |
Definition at line 2127 of file atacmds.cpp.
| int ata_get_wwn | ( | const ata_identify_device * | id, |
| unsigned & | oui, | ||
| uint64_t & | unique_id | ||
| ) |
Definition at line 900 of file atacmds.cpp.
| bool ata_nodata_command | ( | ata_device * | device, |
| unsigned char | command, | ||
| int | sector_count | ||
| ) |
Definition at line 787 of file atacmds.cpp.
| int ata_read_identity | ( | ata_device * | device, |
| ata_identify_device * | buf, | ||
| bool | fix_swapped_id, | ||
| unsigned char * | raw_buf | ||
| ) |
Definition at line 817 of file atacmds.cpp.
| unsigned char ata_return_temperature_value | ( | const ata_smart_values * | data, |
| const ata_vendor_attr_defs & | defs | ||
| ) |
Definition at line 2159 of file atacmds.cpp.
| bool ata_set_features | ( | ata_device * | device, |
| unsigned char | features, | ||
| int | sector_count | ||
| ) |
Definition at line 799 of file atacmds.cpp.
| int ataCheckPowerMode | ( | ata_device * | device | ) |
Definition at line 777 of file atacmds.cpp.
| int ataDisableAutoOffline | ( | ata_device * | device | ) |
Definition at line 1581 of file atacmds.cpp.
| int ataDisableAutoSave | ( | ata_device * | device | ) |
Definition at line 1558 of file atacmds.cpp.
| int ataDisableSmart | ( | ata_device * | device | ) |
Definition at line 1543 of file atacmds.cpp.
| int ataDoesSmartWork | ( | ata_device * | device | ) |
Definition at line 1593 of file atacmds.cpp.
| int ataEnableAutoOffline | ( | ata_device * | device | ) |
Definition at line 1570 of file atacmds.cpp.
| int ataEnableAutoSave | ( | ata_device * | device | ) |
Definition at line 1551 of file atacmds.cpp.
| int ataEnableSmart | ( | ata_device * | device | ) |
Definition at line 1536 of file atacmds.cpp.
| int ataGetSCTErrorRecoveryControltime | ( | ata_device * | device, |
| unsigned | type, | ||
| unsigned short & | time_limit, | ||
| bool | power_on | ||
| ) |
Definition at line 2510 of file atacmds.cpp.
|
static |
Definition at line 2414 of file atacmds.cpp.
|
static |
Definition at line 2282 of file atacmds.cpp.
| int ataGetSetSCTWriteCache | ( | ata_device * | device, |
| unsigned short | state, | ||
| bool | persistent, | ||
| bool | set | ||
| ) |
Definition at line 2356 of file atacmds.cpp.
| int ataGetSetSCTWriteCacheReordering | ( | ata_device * | device, |
| bool | enable, | ||
| bool | persistent, | ||
| bool | set | ||
| ) |
Definition at line 2349 of file atacmds.cpp.
| int ataIsSmartEnabled | ( | const ata_identify_device * | drive | ) |
Definition at line 951 of file atacmds.cpp.
| int ataReadErrorLog | ( | ata_device * | device, |
| ata_smart_errorlog * | data, | ||
| firmwarebug_defs | firmwarebugs | ||
| ) |
Definition at line 1424 of file atacmds.cpp.
| bool ataReadExtErrorLog | ( | ata_device * | device, |
| ata_smart_exterrlog * | log, | ||
| unsigned | page, | ||
| unsigned | nsectors, | ||
| firmwarebug_defs | firmwarebugs | ||
| ) |
Definition at line 1491 of file atacmds.cpp.
| bool ataReadExtSelfTestLog | ( | ata_device * | device, |
| ata_smart_extselftestlog * | log, | ||
| unsigned | nsectors | ||
| ) |
Definition at line 1061 of file atacmds.cpp.
| int ataReadLogDirectory | ( | ata_device * | device, |
| ata_smart_log_directory * | data, | ||
| bool | gpl | ||
| ) |
Definition at line 1164 of file atacmds.cpp.
| bool ataReadLogExt | ( | ata_device * | device, |
| unsigned char | logaddr, | ||
| unsigned char | features, | ||
| unsigned | page, | ||
| void * | data, | ||
| unsigned | nsectors | ||
| ) |
Definition at line 1111 of file atacmds.cpp.
| int ataReadSCTStatus | ( | ata_device * | device, |
| ata_sct_status_response * | sts | ||
| ) |
Definition at line 2188 of file atacmds.cpp.
| int ataReadSCTTempHist | ( | ata_device * | device, |
| ata_sct_temperature_history_table * | tmh, | ||
| ata_sct_status_response * | sts | ||
| ) |
Definition at line 2220 of file atacmds.cpp.
| int ataReadSelectiveSelfTestLog | ( | ata_device * | device, |
| struct ata_selective_self_test_log * | data | ||
| ) |
Definition at line 1184 of file atacmds.cpp.
| int ataReadSelfTestLog | ( | ata_device * | device, |
| ata_smart_selftestlog * | data, | ||
| firmwarebug_defs | firmwarebugs | ||
| ) |
Definition at line 1013 of file atacmds.cpp.
| bool ataReadSmartLog | ( | ata_device * | device, |
| unsigned char | logaddr, | ||
| void * | data, | ||
| unsigned | nsectors | ||
| ) |
Definition at line 1143 of file atacmds.cpp.
| int ataReadSmartThresholds | ( | ata_device * | device, |
| struct ata_smart_thresholds_pvt * | data | ||
| ) |
Definition at line 1518 of file atacmds.cpp.
| int ataReadSmartValues | ( | ata_device * | device, |
| struct ata_smart_values * | data | ||
| ) |
Definition at line 967 of file atacmds.cpp.
| int ataSetSCTErrorRecoveryControltime | ( | ata_device * | device, |
| unsigned | type, | ||
| unsigned short | time_limit, | ||
| bool | power_on, | ||
| bool | mfg_default | ||
| ) |
Definition at line 2516 of file atacmds.cpp.
| int ataSetSCTTempInterval | ( | ata_device * | device, |
| unsigned | interval, | ||
| bool | persistent | ||
| ) |
Definition at line 2363 of file atacmds.cpp.
| int ataSmartStatus2 | ( | ata_device * | device | ) |
Definition at line 1604 of file atacmds.cpp.
| int ataSmartSupport | ( | const ata_identify_device * | drive | ) |
Definition at line 936 of file atacmds.cpp.
| int ataSmartTest | ( | ata_device * | device, |
| int | testtype, | ||
| bool | force, | ||
| const ata_selective_selftest_args & | selargs, | ||
| const ata_smart_values * | sv, | ||
| uint64_t | num_sectors | ||
| ) |
Definition at line 1611 of file atacmds.cpp.
| bool ataWriteLogExt | ( | ata_device * | device, |
| unsigned char | logaddr, | ||
| unsigned | page, | ||
| void * | data, | ||
| unsigned | nsectors | ||
| ) |
Definition at line 1080 of file atacmds.cpp.
| int ataWriteSelectiveSelfTestLog | ( | ata_device * | device, |
| ata_selective_selftest_args & | args, | ||
| const ata_smart_values * | sv, | ||
| uint64_t | num_sectors, | ||
| const ata_selective_selftest_args * | prev_args | ||
| ) |
Definition at line 1213 of file atacmds.cpp.
|
static |
Definition at line 1045 of file atacmds.cpp.
|
static |
Definition at line 1903 of file atacmds.cpp.
|
inlinestatic |
Definition at line 1892 of file atacmds.cpp.
| unsigned char checksum | ( | const void * | data | ) |
Definition at line 716 of file atacmds.cpp.
| std::string create_vendor_attribute_arg_list | ( | ) |
Definition at line 262 of file atacmds.cpp.
|
static |
Definition at line 1478 of file atacmds.cpp.
|
inlinestatic |
Definition at line 1469 of file atacmds.cpp.
|
static |
Definition at line 1392 of file atacmds.cpp.
|
static |
Definition at line 1414 of file atacmds.cpp.
|
static |
Definition at line 996 of file atacmds.cpp.
| ata_device * get_parsed_ata_device | ( | smart_interface * | intf, |
| const char * | dev_name | ||
| ) |
Definition at line 2838 of file atacmds.cpp.
|
static |
Definition at line 337 of file atacmds.cpp.
| unsigned char get_unc_attr_id | ( | bool | offline, |
| const ata_vendor_attr_defs & | defs, | ||
| bool & | increase | ||
| ) |
Definition at line 53 of file atacmds.cpp.
| const char * get_valid_firmwarebug_args | ( | ) |
Definition at line 297 of file atacmds.cpp.
|
static |
Definition at line 343 of file atacmds.cpp.
| bool isGeneralPurposeLoggingCapable | ( | const ata_identify_device * | identity | ) |
Definition at line 1769 of file atacmds.cpp.
| bool isSmartErrorLogCapable | ( | const ata_smart_values * | data, |
| const ata_identify_device * | identity | ||
| ) |
Definition at line 1731 of file atacmds.cpp.
| bool isSmartTestLogCapable | ( | const ata_smart_values * | data, |
| const ata_identify_device * | identity | ||
| ) |
Definition at line 1750 of file atacmds.cpp.
| bool parse_attribute_def | ( | const char * | opt, |
| ata_vendor_attr_defs & | defs, | ||
| ata_vendor_def_prior | priority | ||
| ) |
Definition at line 149 of file atacmds.cpp.
| bool parse_firmwarebug_def | ( | const char * | opt, |
| firmwarebug_defs & | firmwarebugs | ||
| ) |
Definition at line 277 of file atacmds.cpp.
|
static |
Definition at line 382 of file atacmds.cpp.
|
static |
Definition at line 409 of file atacmds.cpp.
|
static |
Definition at line 391 of file atacmds.cpp.
|
static |
Definition at line 400 of file atacmds.cpp.
| int smartcommandhandler | ( | ata_device * | device, |
| smart_command_set | command, | ||
| int | select, | ||
| char * | data | ||
| ) |
Definition at line 431 of file atacmds.cpp.
| void swap2 | ( | char * | location | ) |
Definition at line 304 of file atacmds.cpp.
| void swap4 | ( | char * | location | ) |
Definition at line 312 of file atacmds.cpp.
| void swap8 | ( | char * | location | ) |
Definition at line 321 of file atacmds.cpp.
|
static |
Definition at line 726 of file atacmds.cpp.
| int TestTime | ( | const ata_smart_values * | data, |
| int | testtype | ||
| ) |
Definition at line 1700 of file atacmds.cpp.
|
static |
Definition at line 735 of file atacmds.cpp.
| unsigned char ata_debugmode = 0 |
Definition at line 33 of file atacmds.cpp.
| const char* atacmds_cpp_cvsid |
Definition at line 29 of file atacmds.cpp.
|
static |
Definition at line 363 of file atacmds.cpp.
| bool dont_print_serial_number = false |
Definition at line 37 of file atacmds.cpp.
| const format_name_entry format_names[] |
Definition at line 103 of file atacmds.cpp.
| const char* const map_old_vendor_opts[][2] |
Definition at line 128 of file atacmds.cpp.
| const unsigned num_format_names = sizeof(format_names)/sizeof(format_names[0]) |
Definition at line 125 of file atacmds.cpp.
| const unsigned num_old_vendor_opts = sizeof(map_old_vendor_opts)/sizeof(map_old_vendor_opts[0]) |
Definition at line 145 of file atacmds.cpp.