|
smartmontools SVN Rev 3317
Utility to control and monitor storage systems with "S.M.A.R.T."
|
#include <stdio.h>#include <string.h>#include <errno.h>#include <stdlib.h>#include <ctype.h>#include "config.h"#include "int64.h"#include "atacmds.h"#include "utility.h"#include "dev_ata_cmd_set.h"
Go to the source code of this file.
| #define P | ( | n | ) | (' ' <= p[n] && p[n] <= '~' ? (int)p[n] : '.') |
| #define SMART_CYL_HI 0xC2 |
Definition at line 50 of file atacmds.cpp.
| #define SMART_CYL_LOW 0x4F |
Definition at line 49 of file atacmds.cpp.
| #define SRET_STATUS_HI_EXCEEDED 0x2C |
Definition at line 56 of file atacmds.cpp.
| #define SRET_STATUS_MID_EXCEEDED 0xF4 |
Definition at line 57 of file atacmds.cpp.
| int ata_find_attr_index | ( | unsigned char | id, |
| const ata_smart_values & | smartval | ||
| ) |
Definition at line 2312 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 1931 of file atacmds.cpp.
| void ata_format_id_string | ( | char * | out, |
| const unsigned char * | in, | ||
| int | n | ||
| ) |
Definition at line 749 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 1885 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 1812 of file atacmds.cpp.
| int ata_get_rotation_rate | ( | const ata_identify_device * | id | ) |
Definition at line 927 of file atacmds.cpp.
| void ata_get_size_info | ( | const ata_identify_device * | id, |
| ata_size_info & | sizes | ||
| ) |
Definition at line 645 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 2302 of file atacmds.cpp.
| int ata_get_wwn | ( | const ata_identify_device * | id, |
| unsigned & | oui, | ||
| uint64_t & | unique_id | ||
| ) |
Definition at line 907 of file atacmds.cpp.
| bool ata_nodata_command | ( | ata_device * | device, |
| unsigned char | command, | ||
| int | sector_count | ||
| ) |
Definition at line 788 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 818 of file atacmds.cpp.
| unsigned char ata_return_temperature_value | ( | const ata_smart_values * | data, |
| const ata_vendor_attr_defs & | defs | ||
| ) |
Definition at line 2325 of file atacmds.cpp.
| bool ata_set_features | ( | ata_device * | device, |
| unsigned char | features, | ||
| int | sector_count | ||
| ) |
Definition at line 800 of file atacmds.cpp.
| int ataCheckPowerMode | ( | ata_device * | device | ) |
Definition at line 775 of file atacmds.cpp.
| int ataDisableAutoOffline | ( | ata_device * | device | ) |
Definition at line 1557 of file atacmds.cpp.
| int ataDisableAutoSave | ( | ata_device * | device | ) |
Definition at line 1534 of file atacmds.cpp.
| int ataDisableSmart | ( | ata_device * | device | ) |
Definition at line 1519 of file atacmds.cpp.
| int ataDoesSmartWork | ( | ata_device * | device | ) |
Definition at line 1569 of file atacmds.cpp.
| int ataEnableAutoOffline | ( | ata_device * | device | ) |
Definition at line 1546 of file atacmds.cpp.
| int ataEnableAutoSave | ( | ata_device * | device | ) |
Definition at line 1527 of file atacmds.cpp.
| int ataEnableSmart | ( | ata_device * | device | ) |
Definition at line 1512 of file atacmds.cpp.
| int ataGetSCTErrorRecoveryControltime | ( | ata_device * | device, |
| unsigned | type, | ||
| unsigned short & | time_limit | ||
| ) |
Definition at line 2583 of file atacmds.cpp.
| static int ataGetSetSCTErrorRecoveryControltime | ( | ata_device * | device, |
| unsigned | type, | ||
| bool | set, | ||
| unsigned short & | time_limit | ||
| ) | [static] |
Definition at line 2498 of file atacmds.cpp.
| int ataIsSmartEnabled | ( | const ata_identify_device * | drive | ) |
Definition at line 958 of file atacmds.cpp.
| int ataPrintSmartSelfTestEntry | ( | unsigned | testnum, |
| unsigned char | test_type, | ||
| unsigned char | test_status, | ||
| unsigned short | timestamp, | ||
| uint64_t | failing_lba, | ||
| bool | print_error_only, | ||
| bool & | print_header | ||
| ) |
Definition at line 2600 of file atacmds.cpp.
| int ataPrintSmartSelfTestlog | ( | const ata_smart_selftestlog * | data, |
| bool | allentries, | ||
| firmwarebug_defs | firmwarebugs | ||
| ) |
Definition at line 2680 of file atacmds.cpp.
| int ataReadErrorLog | ( | ata_device * | device, |
| ata_smart_errorlog * | data, | ||
| firmwarebug_defs | firmwarebugs | ||
| ) |
Definition at line 1401 of file atacmds.cpp.
| bool ataReadExtErrorLog | ( | ata_device * | device, |
| ata_smart_exterrlog * | log, | ||
| unsigned | nsectors, | ||
| firmwarebug_defs | firmwarebugs | ||
| ) |
Definition at line 1468 of file atacmds.cpp.
| bool ataReadExtSelfTestLog | ( | ata_device * | device, |
| ata_smart_extselftestlog * | log, | ||
| unsigned | nsectors | ||
| ) |
Definition at line 1068 of file atacmds.cpp.
| int ataReadLogDirectory | ( | ata_device * | device, |
| ata_smart_log_directory * | data, | ||
| bool | gpl | ||
| ) |
Definition at line 1141 of file atacmds.cpp.
| bool ataReadLogExt | ( | ata_device * | device, |
| unsigned char | logaddr, | ||
| unsigned char | features, | ||
| unsigned | page, | ||
| void * | data, | ||
| unsigned | nsectors | ||
| ) |
Definition at line 1088 of file atacmds.cpp.
| int ataReadSCTStatus | ( | ata_device * | device, |
| ata_sct_status_response * | sts | ||
| ) |
Definition at line 2354 of file atacmds.cpp.
| int ataReadSCTTempHist | ( | ata_device * | device, |
| ata_sct_temperature_history_table * | tmh, | ||
| ata_sct_status_response * | sts | ||
| ) |
Definition at line 2384 of file atacmds.cpp.
| int ataReadSelectiveSelfTestLog | ( | ata_device * | device, |
| struct ata_selective_self_test_log * | data | ||
| ) |
Definition at line 1161 of file atacmds.cpp.
| int ataReadSelfTestLog | ( | ata_device * | device, |
| ata_smart_selftestlog * | data, | ||
| firmwarebug_defs | firmwarebugs | ||
| ) |
Definition at line 1020 of file atacmds.cpp.
| bool ataReadSmartLog | ( | ata_device * | device, |
| unsigned char | logaddr, | ||
| void * | data, | ||
| unsigned | nsectors | ||
| ) |
Definition at line 1120 of file atacmds.cpp.
| int ataReadSmartThresholds | ( | ata_device * | device, |
| struct ata_smart_thresholds_pvt * | data | ||
| ) |
Definition at line 1494 of file atacmds.cpp.
| int ataReadSmartValues | ( | ata_device * | device, |
| struct ata_smart_values * | data | ||
| ) |
Definition at line 974 of file atacmds.cpp.
| int ataSetSCTErrorRecoveryControltime | ( | ata_device * | device, |
| unsigned | type, | ||
| unsigned short | time_limit | ||
| ) |
Definition at line 2589 of file atacmds.cpp.
| int ataSetSCTTempInterval | ( | ata_device * | device, |
| unsigned | interval, | ||
| bool | persistent | ||
| ) |
Definition at line 2447 of file atacmds.cpp.
| int ataSmartStatus2 | ( | ata_device * | device | ) |
Definition at line 1580 of file atacmds.cpp.
| int ataSmartSupport | ( | const ata_identify_device * | drive | ) |
Definition at line 943 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 1587 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 1190 of file atacmds.cpp.
| static void check_multi_sector_sum | ( | const void * | data, |
| unsigned | nsectors, | ||
| const char * | msg | ||
| ) | [static] |
Definition at line 1052 of file atacmds.cpp.
| unsigned char checksum | ( | const void * | data | ) |
Definition at line 703 of file atacmds.cpp.
| std::string create_vendor_attribute_arg_list | ( | ) |
Definition at line 252 of file atacmds.cpp.
| static void fix_exterrlog_lba | ( | ata_smart_exterrlog * | log, |
| unsigned | nsectors | ||
| ) | [static] |
Definition at line 1455 of file atacmds.cpp.
| static void fix_exterrlog_lba_cmd | ( | T & | cmd | ) | [inline, static] |
Definition at line 1446 of file atacmds.cpp.
| static void fixsamsungerrorlog | ( | ata_smart_errorlog * | data | ) | [static] |
Definition at line 1369 of file atacmds.cpp.
| static void fixsamsungerrorlog2 | ( | ata_smart_errorlog * | data | ) | [static] |
Definition at line 1391 of file atacmds.cpp.
| static void fixsamsungselftestlog | ( | ata_smart_selftestlog * | data | ) | [static] |
Definition at line 1003 of file atacmds.cpp.
| static const char* get_default_attr_name | ( | unsigned char | id, |
| int | rpm | ||
| ) | [static] |
Definition at line 2105 of file atacmds.cpp.
| static ata_attr_raw_format get_default_raw_format | ( | unsigned char | id | ) | [static] |
Definition at line 1862 of file atacmds.cpp.
| ata_device* get_parsed_ata_device | ( | smart_interface * | intf, |
| const char * | dev_name | ||
| ) |
Definition at line 3072 of file atacmds.cpp.
| unsigned char get_unc_attr_id | ( | bool | offline, |
| const ata_vendor_attr_defs & | defs, | ||
| bool & | increase | ||
| ) |
Definition at line 62 of file atacmds.cpp.
| const char* get_valid_firmwarebug_args | ( | ) |
Definition at line 287 of file atacmds.cpp.
| static void invalidate_serno | ( | ata_identify_device * | id | ) | [static] |
Definition at line 323 of file atacmds.cpp.
| int isGeneralPurposeLoggingCapable | ( | const ata_identify_device * | identity | ) |
Definition at line 1745 of file atacmds.cpp.
| int isSmartErrorLogCapable | ( | const ata_smart_values * | data, |
| const ata_identify_device * | identity | ||
| ) |
Definition at line 1707 of file atacmds.cpp.
| int isSmartTestLogCapable | ( | const ata_smart_values * | data, |
| const ata_identify_device * | identity | ||
| ) |
Definition at line 1726 of file atacmds.cpp.
| int isSupportAutomaticTimer | ( | const ata_smart_values * | data | ) |
Definition at line 1786 of file atacmds.cpp.
| int isSupportConveyanceSelfTest | ( | const ata_smart_values * | data | ) |
Definition at line 1802 of file atacmds.cpp.
| int isSupportExecuteOfflineImmediate | ( | const ata_smart_values * | data | ) |
Definition at line 1776 of file atacmds.cpp.
| int isSupportOfflineAbort | ( | const ata_smart_values * | data | ) |
Definition at line 1790 of file atacmds.cpp.
| int isSupportOfflineSurfaceScan | ( | const ata_smart_values * | data | ) |
Definition at line 1794 of file atacmds.cpp.
| int isSupportSelectiveSelfTest | ( | const ata_smart_values * | data | ) |
Definition at line 1806 of file atacmds.cpp.
| int isSupportSelfTest | ( | const ata_smart_values * | data | ) |
Definition at line 1798 of file atacmds.cpp.
| bool parse_attribute_def | ( | const char * | opt, |
| ata_vendor_attr_defs & | defs, | ||
| ata_vendor_def_prior | priority | ||
| ) |
Definition at line 158 of file atacmds.cpp.
| bool parse_firmwarebug_def | ( | const char * | opt, |
| firmwarebug_defs & | firmwarebugs | ||
| ) |
Definition at line 267 of file atacmds.cpp.
| static const char* preg | ( | const ata_register & | r, |
| char(&) | buf[8] | ||
| ) | [static] |
Definition at line 367 of file atacmds.cpp.
| static void prettyprint | ( | const unsigned char * | p, |
| const char * | name | ||
| ) | [static] |
Definition at line 394 of file atacmds.cpp.
| static void print_regs | ( | const char * | prefix, |
| const ata_in_regs & | r, | ||
| const char * | suffix = "\n" |
||
| ) | [static] |
Definition at line 376 of file atacmds.cpp.
| static void print_regs | ( | const char * | prefix, |
| const ata_out_regs & | r, | ||
| const char * | suffix = "\n" |
||
| ) | [static] |
Definition at line 385 of file atacmds.cpp.
| int smartcommandhandler | ( | ata_device * | device, |
| smart_command_set | command, | ||
| int | select, | ||
| char * | data | ||
| ) |
Definition at line 416 of file atacmds.cpp.
| void swap2 | ( | char * | location | ) |
Definition at line 294 of file atacmds.cpp.
| void swap4 | ( | char * | location | ) |
Definition at line 302 of file atacmds.cpp.
| void swap8 | ( | char * | location | ) |
Definition at line 311 of file atacmds.cpp.
| static void swapbytes | ( | char * | out, |
| const char * | in, | ||
| size_t | n | ||
| ) | [static] |
Definition at line 713 of file atacmds.cpp.
| int TestTime | ( | const ata_smart_values * | data, |
| int | testtype | ||
| ) |
Definition at line 1676 of file atacmds.cpp.
| static void trim | ( | char * | out, |
| const char * | in | ||
| ) | [static] |
Definition at line 722 of file atacmds.cpp.
| unsigned char ata_debugmode = 0 |
Definition at line 42 of file atacmds.cpp.
| const char* atacmds_cpp_cvsid |
"$Id: atacmds.cpp 3777 2013-02-19 18:32:15Z samm2 $" ATACMDS_H_CVSID
Definition at line 38 of file atacmds.cpp.
const char* const commandstrings[] [static] |
{
"SMART ENABLE",
"SMART DISABLE",
"SMART AUTOMATIC ATTRIBUTE SAVE",
"SMART IMMEDIATE OFFLINE",
"SMART AUTO OFFLINE",
"SMART STATUS",
"SMART STATUS CHECK",
"SMART READ ATTRIBUTE VALUES",
"SMART READ ATTRIBUTE THRESHOLDS",
"SMART READ LOG",
"IDENTIFY DEVICE",
"IDENTIFY PACKET DEVICE",
"CHECK POWER MODE",
"SMART WRITE LOG",
"WARNING (UNDEFINED COMMAND -- CONTACT DEVELOPERS AT " PACKAGE_BUGREPORT ")\n"
}
Definition at line 348 of file atacmds.cpp.
| bool dont_print_serial_number = false |
Definition at line 46 of file atacmds.cpp.
| const format_name_entry format_names[] |
{
{"raw8" , RAWFMT_RAW8},
{"raw16" , RAWFMT_RAW16},
{"raw48" , RAWFMT_RAW48},
{"hex48" , RAWFMT_HEX48},
{"raw56" , RAWFMT_RAW56},
{"hex56" , RAWFMT_HEX56},
{"raw64" , RAWFMT_RAW64},
{"hex64" , RAWFMT_HEX64},
{"raw16(raw16)" , RAWFMT_RAW16_OPT_RAW16},
{"raw16(avg16)" , RAWFMT_RAW16_OPT_AVG16},
{"raw24(raw8)" , RAWFMT_RAW24_OPT_RAW8},
{"raw24/raw24" , RAWFMT_RAW24_DIV_RAW24},
{"raw24/raw32" , RAWFMT_RAW24_DIV_RAW32},
{"sec2hour" , RAWFMT_SEC2HOUR},
{"min2hour" , RAWFMT_MIN2HOUR},
{"halfmin2hour" , RAWFMT_HALFMIN2HOUR},
{"msec24hour32" , RAWFMT_MSEC24_HOUR32},
{"tempminmax" , RAWFMT_TEMPMINMAX},
{"temp10x" , RAWFMT_TEMP10X},
}
Definition at line 112 of file atacmds.cpp.
| const char* map_old_vendor_opts[][2] |
{
{ "9,halfminutes" , "9,halfmin2hour,Power_On_Half_Minutes"},
{ "9,minutes" , "9,min2hour,Power_On_Minutes"},
{ "9,seconds" , "9,sec2hour,Power_On_Seconds"},
{ "9,temp" , "9,tempminmax,Temperature_Celsius"},
{"192,emergencyretractcyclect" , "192,raw48,Emerg_Retract_Cycle_Ct"},
{"193,loadunload" , "193,raw24/raw24"},
{"194,10xCelsius" , "194,temp10x,Temperature_Celsius_x10"},
{"194,unknown" , "194,raw48,Unknown_Attribute"},
{"197,increasing" , "197,raw48+,Total_Pending_Sectors"},
{"198,offlinescanuncsectorct" , "198,raw48,Offline_Scan_UNC_SectCt"},
{"198,increasing" , "198,raw48+,Total_Offl_Uncorrectabl"},
{"200,writeerrorcount" , "200,raw48,Write_Error_Count"},
{"201,detectedtacount" , "201,raw48,Detected_TA_Count"},
{"220,temp" , "220,tempminmax,Temperature_Celsius"},
}
Definition at line 137 of file atacmds.cpp.
| const unsigned num_format_names = sizeof(format_names)/sizeof(format_names[0]) |
Definition at line 134 of file atacmds.cpp.
| const unsigned num_old_vendor_opts = sizeof(map_old_vendor_opts)/sizeof(map_old_vendor_opts[0]) |
Definition at line 154 of file atacmds.cpp.
1.7.4