📄 knowndrives.cpp
字号:
/* * knowndrives.cpp * * Home page of code is: http://smartmontools.sourceforge.net * Address of support mailing list: smartmontools-support@lists.sourceforge.net * * Copyright (C) 2003-8 Philip Williams, Bruce Allen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * You should have received a copy of the GNU General Public License * (for example COPYING); if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */#include "config.h"#include "int64.h"#include <stdio.h>#include "atacmds.h"#include "ataprint.h"#include "extern.h"#include "knowndrives.h"#include "utility.h" // includes <regex.h>const char *knowndrives_c_cvsid="$Id: knowndrives.cpp,v 1.166 2008/02/02 18:10:48 chrfranke Exp $"ATACMDS_H_CVSID ATAPRINT_H_CVSID CONFIG_H_CVSID EXTERN_H_CVSID INT64_H_CVSID KNOWNDRIVES_H_CVSID UTILITY_H_CVSID;#define MODEL_STRING_LENGTH 40#define FIRMWARE_STRING_LENGTH 8#define TABLEPRINTWIDTH 19// See vendorattributeargs[] array in atacmds.cpp for definitions.#define PRESET_9_MINUTES { 9, 1 }#define PRESET_9_TEMP { 9, 2 }#define PRESET_9_SECONDS { 9, 3 }#define PRESET_9_HALFMINUTES { 9, 4 }#define PRESET_192_EMERGENCYRETRACTCYCLECT { 192, 1 }#define PRESET_193_LOADUNLOAD { 193, 1 }#define PRESET_194_10XCELSIUS { 194, 1 }#define PRESET_194_UNKNOWN { 194, 2 }#define PRESET_198_OFFLINESCANUNCSECTORCT { 198, 1 }#define PRESET_200_WRITEERRORCOUNT { 200, 1 }#define PRESET_201_DETECTEDTACOUNT { 201, 1 } #define PRESET_220_TEMP { 220, 1 }/* Arrays of preset vendor-specific attribute options for use in * knowndrives[]. */extern int64_t bytes;// to hold onto exit code for atexit routineextern int exitstatus;// These three are common to several models.const unsigned char vendoropts_9_minutes[][2] = { PRESET_9_MINUTES, {0,0}};const unsigned char vendoropts_9_halfminutes[][2] = { PRESET_9_HALFMINUTES, {0,0}};const unsigned char vendoropts_9_seconds[][2] = { PRESET_9_SECONDS, {0,0}};const unsigned char vendoropts_Maxtor_4D080H4[][2] = { PRESET_9_MINUTES, PRESET_194_UNKNOWN, {0,0}};const unsigned char vendoropts_Fujitsu_MHS2020AT[][2] = { PRESET_9_SECONDS, PRESET_192_EMERGENCYRETRACTCYCLECT, PRESET_198_OFFLINESCANUNCSECTORCT, PRESET_200_WRITEERRORCOUNT, PRESET_201_DETECTEDTACOUNT, {0,0}};const unsigned char vendoropts_Fujitsu_MHR2040AT[][2] = { PRESET_9_SECONDS, PRESET_192_EMERGENCYRETRACTCYCLECT, PRESET_198_OFFLINESCANUNCSECTORCT, PRESET_200_WRITEERRORCOUNT, {0,0}};const unsigned char vendoropts_Samsung_SV4012H[][2] = { PRESET_9_HALFMINUTES, {0,0}};const unsigned char vendoropts_Samsung_SV1204H[][2] = { PRESET_9_HALFMINUTES, PRESET_194_10XCELSIUS, {0,0}};const unsigned char vendoropts_Hitachi_DK23XX[][2] = { PRESET_9_MINUTES, PRESET_193_LOADUNLOAD, {0,0}};const char same_as_minus_F[]="Fixes byte order in some SMART data (same as -F samsung)";const char same_as_minus_F2[]="Fixes byte order in some SMART data (same as -F samsung2)";const char same_as_minus_F3[]="Fixes completed self-test reported as in progress (same as -F samsung3)";const char may_need_minus_F_disabled[] ="May need -F samsung disabled; see manual for details.";const char may_need_minus_F2_disabled[]="May need -F samsung2 disabled; see manual for details.";const char may_need_minus_F2_enabled[] ="May need -F samsung2 enabled; see manual for details.";const char may_need_minus_F_enabled[] ="May need -F samsung or -F samsung2 enabled; see manual for details.";const char may_need_minus_F3_enabled[] ="May need -F samsung3 enabled; see manual for details.";/* Special-purpose functions for use in knowndrives[]. */void specialpurpose_reverse_samsung(smartmonctrl *con){ if (con->fixfirmwarebug==FIX_NOTSPECIFIED) con->fixfirmwarebug = FIX_SAMSUNG;}void specialpurpose_reverse_samsung2(smartmonctrl *con){ if (con->fixfirmwarebug==FIX_NOTSPECIFIED) con->fixfirmwarebug = FIX_SAMSUNG2;}void specialpurpose_fix_samsung3(smartmonctrl *con){ if (con->fixfirmwarebug==FIX_NOTSPECIFIED) con->fixfirmwarebug = FIX_SAMSUNG3;}/* Table of settings for known drives terminated by an element containing all * zeros. The drivesettings structure is described in knowndrives.h. Note * that lookupdrive() will search knowndrives[] from the start to end or * until it finds the first match, so the order in knowndrives[] is important * for distinct entries that could match the same drive. */// Note that the table just below uses EXTENDED REGULAR EXPRESSIONS.// A good on-line reference for these is:// http://www.zeus.com/extra/docsystem/docroot/apps/web/docs/modules/access/regex.htmlconst drivesettings knowndrives[] = { { "IBM Deskstar 60GXP series", // ER60A46A firmware "(IBM-|Hitachi )?IC35L0[12346]0AVER07", "^ER60A46A$", NULL, NULL, NULL, NULL }, { "IBM Deskstar 60GXP series", // All other firmware "(IBM-|Hitachi )?IC35L0[12346]0AVER07", ".*", "IBM Deskstar 60GXP drives may need upgraded SMART firmware.\n" "Please see http://www.geocities.com/dtla_update/index.html#rel and\n" "http://www-3.ibm.com/pc/support/site.wss/document.do?lndocid=MIGR-42215 or\n" "http://www-1.ibm.com/support/docview.wss?uid=psg1MIGR-42215", NULL, NULL, NULL }, { "IBM Deskstar 40GV & 75GXP series (A5AA/A6AA firmware)", "(IBM-)?DTLA-30[57]0[123467][05]", "^T[WX][123468AG][OF]A[56]AA$", NULL, NULL, NULL, NULL }, { "IBM Deskstar 40GV & 75GXP series (all other firmware)", "(IBM-)?DTLA-30[57]0[123467][05]", ".*", "IBM Deskstar 40GV and 75GXP drives may need upgraded SMART firmware.\n" "Please see http://www.geocities.com/dtla_update/ and\n" "http://www-3.ibm.com/pc/support/site.wss/document.do?lndocid=MIGR-42215 or\n" "http://www-1.ibm.com/support/docview.wss?uid=psg1MIGR-42215", NULL, NULL, NULL }, { NULL, // ExcelStor J240, J340, J360, J680, and J880 "^ExcelStor Technology J(24|34|36|68|88)0$", ".*", NULL, NULL, NULL, NULL }, { NULL, // Fujitsu M1623TAU "^FUJITSU M1623TAU$", ".*", NULL, vendoropts_9_seconds, NULL, NULL }, { "Fujitsu MHG series", "^FUJITSU MHG2...ATU?", ".*", NULL, vendoropts_9_seconds, NULL, NULL }, { "Fujitsu MHH series", "^FUJITSU MHH2...ATU?", ".*", NULL, vendoropts_9_seconds, NULL, NULL }, { "Fujitsu MHJ series", "^FUJITSU MHJ2...ATU?", ".*", NULL, vendoropts_9_seconds, NULL, NULL }, { "Fujitsu MHK series", "^FUJITSU MHK2...ATU?", ".*", NULL, vendoropts_9_seconds, NULL, NULL }, { NULL, // Fujitsu MHL2300AT "^FUJITSU MHL2300AT$", ".*", "This drive's firmware has a harmless Drive Identity Structure\n" "checksum error bug.", vendoropts_9_seconds, NULL, NULL }, { NULL, // MHM2200AT, MHM2150AT, MHM2100AT, MHM2060AT "^FUJITSU MHM2(20|15|10|06)0AT$", ".*", "This drive's firmware has a harmless Drive Identity Structure\n" "checksum error bug.", vendoropts_9_seconds, NULL, NULL }, { "Fujitsu MHN series", "^FUJITSU MHN2...AT$", ".*", NULL, vendoropts_9_seconds, NULL, NULL }, { NULL, // Fujitsu MHR2020AT "^FUJITSU MHR2020AT$", ".*", NULL, vendoropts_9_seconds, NULL, NULL }, { NULL, // Fujitsu MHR2040AT "^FUJITSU MHR2040AT$", ".*", // Tested on 40BA NULL, vendoropts_Fujitsu_MHR2040AT, NULL, NULL }, { "Fujitsu MHSxxxxAT family", "^FUJITSU MHS20[6432]0AT( .)?$", ".*", NULL, vendoropts_Fujitsu_MHS2020AT, NULL, NULL }, { "Fujitsu MHT series", "^FUJITSU MHT2...(AH|AS|AT|BH)U?", ".*", NULL, vendoropts_9_seconds, NULL, NULL }, { "Fujitsu MHU series", "^FUJITSU MHU2...ATU?", ".*", NULL, vendoropts_9_seconds, NULL, NULL }, { "Fujitsu MHV series", "^FUJITSU MHV2...(AH|AS|AT|BH|BS|BT)", ".*", NULL, vendoropts_9_seconds, NULL, NULL }, { "Fujitsu MPA..MPG series", "^FUJITSU MP[A-G]3...A[HTEV]U?", ".*", NULL, vendoropts_9_seconds, NULL, NULL }, { "Fujitsu MHW2 BH", "^FUJITSU MHW2(04|06|08|10|12|16)0BH$", ".*", NULL, NULL, NULL, NULL }, { NULL, // Samsung SV4012H (known firmware) "^SAMSUNG SV4012H$", "^RM100-08$", NULL, vendoropts_Samsung_SV4012H, specialpurpose_reverse_samsung, same_as_minus_F }, { NULL, // Samsung SV4012H (all other firmware) "^SAMSUNG SV4012H$", ".*", may_need_minus_F_disabled, vendoropts_Samsung_SV4012H, specialpurpose_reverse_samsung, same_as_minus_F }, { NULL, // Samsung SV0412H (known firmware) "^SAMSUNG SV0412H$", "^SK100-01$", NULL, vendoropts_Samsung_SV1204H, specialpurpose_reverse_samsung, same_as_minus_F }, { NULL, // Samsung SV0412H (all other firmware) "^SAMSUNG SV0412H$", ".*", may_need_minus_F_disabled, vendoropts_Samsung_SV1204H, specialpurpose_reverse_samsung, same_as_minus_F }, { NULL, // Samsung SV1204H (known firmware) "^SAMSUNG SV1204H$", "^RK100-1[3-5]$", NULL, vendoropts_Samsung_SV1204H, specialpurpose_reverse_samsung, same_as_minus_F }, { NULL, // Samsung SV1204H (all other firmware) "^SAMSUNG SV1204H$", ".*", may_need_minus_F_disabled, vendoropts_Samsung_SV1204H, specialpurpose_reverse_samsung, same_as_minus_F }, { NULL, // SAMSUNG SV0322A tested with FW JK200-35 "^SAMSUNG SV0322A$", ".*", NULL, NULL, NULL, NULL }, { NULL, // SAMSUNG SP40A2H with RR100-07 firmware "^SAMSUNG SP40A2H$", "^RR100-07$", NULL, vendoropts_9_halfminutes, specialpurpose_reverse_samsung, same_as_minus_F }, { NULL, // SAMSUNG SP8004H with QW100-61 firmware "^SAMSUNG SP8004H$", "^QW100-61$", NULL, vendoropts_9_halfminutes, specialpurpose_reverse_samsung, same_as_minus_F }, { "SAMSUNG SpinPoint T133 series", // tested with HD300LJ/ZT100-12, HD400LJ/ZZ100-14, HD401LJ/ZZ100-15 "^SAMSUNG HD(250KD|(30[01]|320|40[01])L[DJ])$", ".*", NULL, NULL, NULL, NULL }, { "SAMSUNG SpinPoint T166 series", // tested with HD501LJ/CR100-10 "^SAMSUNG HD(080G|160H|32[01]K|403L|50[01]L)J$", ".*", NULL, NULL, NULL, NULL }, { "SAMSUNG SpinPoint P120 series", // VF100-37 firmware, tested with SP2514N/VF100-37 "^SAMSUNG SP(16[01]3|2[05][01]4)[CN]$", "^VF100-37$", NULL, NULL, specialpurpose_fix_samsung3, same_as_minus_F3 }, { "SAMSUNG SpinPoint P120 series", // other firmware, tested with SP2504C/VT100-33 "^SAMSUNG SP(16[01]3|2[05][01]4)[CN]$", ".*", may_need_minus_F3_enabled, NULL, NULL, NULL }, { "SAMSUNG SpinPoint P80 SD series", // tested with HD160JJ/ZM100-33 "^SAMSUNG HD(080H|120I|160J)J$", ".*", NULL, NULL, NULL, NULL }, { "SAMSUNG SpinPoint P80 series", // BH100-35 firmware, tested with SP0842N/BH100-35 "^SAMSUNG SP(0451|08[0124]2|12[0145]3|16[0145]4)[CN]$", "^BH100-35$", NULL, NULL, specialpurpose_fix_samsung3, same_as_minus_F3 }, { "SAMSUNG SpinPoint P80 series", // firmware *-35 or later "^SAMSUNG SP(0451|08[0124]2|12[0145]3|16[0145]4)[CN]$", ".*-3[5-9]$", may_need_minus_F3_enabled, NULL, NULL, NULL }, { "SAMSUNG SpinPoint P80 series", // firmware *-25...34, tested with SP1614C/SW100-25 and -34 "^SAMSUNG SP(0451|08[0124]2|12[0145]3|16[0145]4)[CN]$", ".*-(2[5-9]|3[0-4])$", NULL, vendoropts_9_halfminutes, NULL, NULL }, { NULL, // Any other Samsung disk with *-23 *-24 firmware // SAMSUNG SP1213N (TL100-23 firmware) // SAMSUNG SP0802N (TK100-23 firmware) // Samsung SP1604N, tested with FW TM100-23 and TM100-24 "^SAMSUNG .*$", ".*-2[34]$", NULL, vendoropts_Samsung_SV4012H, specialpurpose_reverse_samsung2, same_as_minus_F2 }, { NULL, // All Samsung drives with '.*-25' firmware "^SAMSUNG.*", ".*-25$", may_need_minus_F2_disabled, vendoropts_Samsung_SV4012H, specialpurpose_reverse_samsung2, same_as_minus_F2 }, { NULL, // All Samsung drives with '.*-26 or later (currently to -39)' firmware "^SAMSUNG.*", ".*-(2[6789]|3[0-9])$", NULL, vendoropts_Samsung_SV4012H, NULL, NULL }, { NULL, // Samsung ALL OTHER DRIVES "^SAMSUNG.*", ".*", may_need_minus_F_enabled, NULL, NULL, NULL }, { "Maxtor Fireball 541DX family", "^Maxtor 2B0(0[468]|1[05]|20)H1$", ".*", NULL, vendoropts_Maxtor_4D080H4, NULL, NULL }, { "Maxtor Fireball 3 family", "^Maxtor 2F0[234]0[JL]0$", ".*", NULL, vendoropts_9_minutes, NULL, NULL }, { "Maxtor DiamondMax 2160 Ultra ATA family", "^Maxtor 8(2160D2|3228D3|3240D3|4320D4|6480D6|8400D8|8455D8)$", ".*", NULL, vendoropts_9_minutes, NULL, NULL }, { "Maxtor DiamondMax 2880 Ultra ATA family", "^Maxtor 9(0510D4|0576D4|0648D5|0720D5|0840D6|0845D6|0864D6|1008D7|1080D8|1152D8)$", ".*", NULL, vendoropts_9_minutes, NULL, NULL }, { "Maxtor DiamondMax 3400 Ultra ATA family", "^Maxtor 9(1(360|350|202)D8|1190D7|10[12]0D6|0840D5|06[48]0D4|0510D3|1(350|202)E8|1010E6|0840E5|0640E4)$", ".*", NULL, vendoropts_9_minutes, NULL, NULL }, { "Maxtor DiamondMax D540X-4G family", "^Maxtor 4G(120J6|160J[68])$", ".*", NULL, vendoropts_Maxtor_4D080H4, NULL, NULL }, { "Maxtor DiamondMax D540X-4K family", "^MAXTOR 4K(020H1|040H2|060H3|080H4)$", ".*", NULL, NULL, NULL, NULL }, { "Maxtor DiamondMax Plus D740X family", "^MAXTOR 6L0(20[JL]1|40[JL]2|60[JL]3|80[JL]4)$", ".*", NULL, NULL, NULL, NULL }, { "Maxtor DiamondMax Plus 5120 Ultra ATA 33 family", "^Maxtor 9(0512D2|0680D3|0750D3|0913D4|1024D4|1360D6|1536D6|1792D7|2048D8)$", ".*", NULL, vendoropts_9_minutes, NULL, NULL }, { "Maxtor DiamondMax Plus 6800 Ultra ATA 66 family", "^Maxtor 9(2732U8|2390U7|2049U6|1707U5|1366U4|1024U3|0845U3|0683U2)$",
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -