4 * Home page of code is: http://smartmontools.sourceforge.net
5 * Address of support mailing list: smartmontools-support@lists.sourceforge.net
7 * Copyright (C) 2003-9 Philip Williams, Bruce Allen
8 * Copyright (C) 2008-9 Christian Franke <smartmontools-support@lists.sourceforge.net>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option)
15 * You should have received a copy of the GNU General Public License
16 * (for example COPYING); if not, write to the Free
17 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include "knowndrives.h"
33 #include <io.h> // access()
38 const char *knowndrives_c_cvsid
="$Id: knowndrives.cpp,v 1.207 2009/07/04 23:24:37 manfred99 Exp $"
39 ATACMDS_H_CVSID CONFIG_H_CVSID EXTERN_H_CVSID INT64_H_CVSID KNOWNDRIVES_H_CVSID UTILITY_H_CVSID
;
41 #define MODEL_STRING_LENGTH 40
42 #define FIRMWARE_STRING_LENGTH 8
43 #define TABLEPRINTWIDTH 19
46 /* Table of settings for known drives terminated by an element containing all
47 * zeros. The drivesettings structure is described in knowndrives.h. Note
48 * that lookupdrive() will search knowndrives[] from the start to end or
49 * until it finds the first match, so the order in knowndrives[] is important
50 * for distinct entries that could match the same drive. */
52 // Note that the table just below uses EXTENDED REGULAR EXPRESSIONS.
53 // A good on-line reference for these is:
54 // http://www.zeus.com/extra/docsystem/docroot/apps/web/docs/modules/access/regex.html
56 // Starting with CVS version 1.179 of this file, the regular expressions
57 // for drive model and firmware must match the full string. The effect of
58 // "^FULLSTRING$" is identical to "FULLSTRING". The special characters '^'
59 // and '$' are no longer required, but still allowed. The form ".*SUBSTRING.*"
60 // can be used if substring match is desired.
62 static const drive_settings builtin_knowndrives
[] = {
63 // BEGIN drivedb.h (DO NOT DELETE - used by Makefile)
76 { "Transcend Solid-State Drive",
77 "TS(8|16|32|64|128)GSSD25-(M|S)",
80 { "Transcend Solid-State Drive V series",
81 "TS(8|16|32|64|128|192)GSSD25S-(M|S)",
84 { "Marvell SSD SD88SA024BA0 (SUN branded)",
85 "MARVELL SD88SA024BA0 SUN24G 0902M0054V",
88 { "HP 1TB SATA disk GB1000EAFJL",
92 { "IBM Deskstar 60GXP series", // ER60A46A firmware
93 "(IBM-|Hitachi )?IC35L0[12346]0AVER07.*",
97 { "IBM Deskstar 60GXP series", // All other firmware
98 "(IBM-|Hitachi )?IC35L0[12346]0AVER07.*",
100 "IBM Deskstar 60GXP drives may need upgraded SMART firmware.\n"
101 "Please see http://www.geocities.com/dtla_update/index.html#rel and\n"
102 "http://www-3.ibm.com/pc/support/site.wss/document.do?lndocid=MIGR-42215 or\n"
103 "http://www-1.ibm.com/support/docview.wss?uid=psg1MIGR-42215",
106 { "IBM Deskstar 40GV & 75GXP series (A5AA/A6AA firmware)",
107 "(IBM-)?DTLA-30[57]0[123467][05].*",
108 "T[WX][123468AG][OF]A[56]AA",
111 { "IBM Deskstar 40GV & 75GXP series (all other firmware)",
112 "(IBM-)?DTLA-30[57]0[123467][05].*",
114 "IBM Deskstar 40GV and 75GXP drives may need upgraded SMART firmware.\n"
115 "Please see http://www.geocities.com/dtla_update/ and\n"
116 "http://www-3.ibm.com/pc/support/site.wss/document.do?lndocid=MIGR-42215 or\n"
117 "http://www-1.ibm.com/support/docview.wss?uid=psg1MIGR-42215",
120 { "", // ExcelStor J240, J340, J360, J680, and J880
121 "ExcelStor Technology J(24|34|36|68|88)0",
124 { "", // Fujitsu M1623TAU
130 { "Fujitsu MHG series",
131 "FUJITSU MHG2...ATU?.*",
136 { "Fujitsu MHH series",
137 "FUJITSU MHH2...ATU?.*",
142 { "Fujitsu MHJ series",
143 "FUJITSU MHJ2...ATU?.*",
148 { "Fujitsu MHK series",
149 "FUJITSU MHK2...ATU?.*",
154 { "", // Fujitsu MHL2300AT
157 "This drive's firmware has a harmless Drive Identity Structure\n"
158 "checksum error bug.",
161 { "", // MHM2200AT, MHM2150AT, MHM2100AT, MHM2060AT
162 "FUJITSU MHM2(20|15|10|06)0AT",
164 "This drive's firmware has a harmless Drive Identity Structure\n"
165 "checksum error bug.",
168 { "Fujitsu MHN series",
174 { "", // Fujitsu MHR2020AT
180 { "", // Fujitsu MHR2040AT
182 "", // Tested on 40BA
184 "-v 9,seconds -v 192,emergencyretractcyclect "
185 "-v 198,offlinescanuncsectorct -v 200,writeerrorcount"
187 { "Fujitsu MHSxxxxAT family",
188 "FUJITSU MHS20[6432]0AT( .)?",
191 "-v 9,seconds -v 192,emergencyretractcyclect "
192 "-v 198,offlinescanuncsectorct -v 200,writeerrorcount "
193 "-v 201,detectedtacount"
195 { "Fujitsu MHT series",
196 "FUJITSU MHT2...(AH|AS|AT|BH)U?.*",
201 { "Fujitsu MHU series",
202 "FUJITSU MHU2...ATU?.*",
207 { "Fujitsu MHV series",
208 "FUJITSU MHV2...(AH|AS|AT|BH|BS|BT).*",
213 { "Fujitsu MPA..MPG series",
214 "FUJITSU MP[A-G]3...A[HTEV]U?.*",
219 { "Fujitsu MHY2 BH series",
220 "FUJITSU MHY2(04|06|08|10|12|16|20|25)0BH.*",
223 { "Fujitsu MHW2 BH series",
224 "FUJITSU MHW2(04|06|08|10|12|16)0BH.*",
227 { "Fujitsu MHW2 BJ series",
228 "FUJITSU MHW2(08|12|16)0BJ.*",
231 { "Fujitsu MHZ2 BH series",
232 "FUJITSU MHZ2(04|08|12|16|20|25|32)0BH.*",
235 { "Fujitsu MHZ2 BJ series",
236 "FUJITSU MHZ2(08|12|16|20|25|32)0BJ.*",
241 { "Fujitsu MHZ2 BS series",
242 "FUJITSU MHZ2(12|25)0BS.*",
245 { "", // Samsung SV4012H (known firmware)
249 "-v 9,halfminutes -F samsung"
251 { "", // Samsung SV4012H (all other firmware)
254 "May need -F samsung disabled; see manual for details.",
255 "-v 9,halfminutes -F samsung"
257 { "", // Samsung SV0412H (known firmware)
261 "-v 9,halfminutes -v 194,10xCelsius -F samsung"
263 { "", // Samsung SV0412H (all other firmware)
266 "May need -F samsung disabled; see manual for details.",
267 "-v 9,halfminutes -v 194,10xCelsius -F samsung"
269 { "", // Samsung SV1204H (known firmware)
273 "-v 9,halfminutes -v 194,10xCelsius -F samsung"
275 { "", // Samsung SV1204H (all other firmware)
278 "May need -F samsung disabled; see manual for details.",
279 "-v 9,halfminutes -v 194,10xCelsius -F samsung"
281 { "", // SAMSUNG SV0322A tested with FW JK200-35
285 { "", // SAMSUNG SP40A2H with RR100-07 firmware
289 "-v 9,halfminutes -F samsung"
291 { "", // SAMSUNG SP80A4H with RT100-06 firmware
295 "-v 9,halfminutes -F samsung"
297 { "", // SAMSUNG SP8004H with QW100-61 firmware
301 "-v 9,halfminutes -F samsung"
303 { "SAMSUNG SpinPoint F1 DT series", // tested with HD103UJ/1AA01113
304 "SAMSUNG HD(083G|16[12]G|25[12]H|32[12]H|50[12]I|642J|75[23]L|10[23]U)J",
307 { "SAMSUNG SpinPoint F1 RE series", // tested with HE103UJ/1AA01113
308 "SAMSUNG HE(252H|322H|502I|642J|753L|103U)J",
311 { "SAMSUNG SpinPoint S250 series", // tested with HD200HJ/KF100-06
312 "SAMSUNG HD(162|200|250)HJ",
315 { "SAMSUNG SpinPoint T133 series", // tested with HD300LJ/ZT100-12, HD400LJ/ZZ100-14, HD401LJ/ZZ100-15
316 "SAMSUNG HD(250KD|(30[01]|320|40[01])L[DJ])",
319 { "SAMSUNG SpinPoint T166 series", // tested with HD501LJ/CR100-10
320 "SAMSUNG HD(080G|160H|32[01]K|403L|50[01]L)J",
323 { "SAMSUNG SpinPoint P120 series", // VF100-37 firmware, tested with SP2514N/VF100-37
324 "SAMSUNG SP(16[01]3|2[05][01]4)[CN]",
329 { "SAMSUNG SpinPoint P120 series", // other firmware, tested with SP2504C/VT100-33
330 "SAMSUNG SP(16[01]3|2[05][01]4)[CN]",
332 "May need -F samsung3 enabled; see manual for details.",
335 { "SAMSUNG SpinPoint P80 SD series", // tested with HD160JJ/ZM100-33
336 "SAMSUNG HD(080H|120I|160J)J",
339 { "SAMSUNG SpinPoint P80 series", // BH100-35 firmware, tested with SP0842N/BH100-35
340 "SAMSUNG SP(0451|08[0124]2|12[0145]3|16[0145]4)[CN]",
345 { "SAMSUNG SpinPoint P80 series", // firmware *-35 or later
346 "SAMSUNG SP(0451|08[0124]2|12[0145]3|16[0145]4)[CN]",
348 "May need -F samsung3 enabled; see manual for details.",
351 { "SAMSUNG SpinPoint P80 series", // firmware *-25...34, tested with SP1614C/SW100-25 and -34
352 "SAMSUNG SP(0451|08[0124]2|12[0145]3|16[0145]4)[CN]",
353 ".*-(2[5-9]|3[0-4])",
355 "-v 9,halfminutes -v 198,increasing"
357 { "SAMSUNG SpinPoint P80 series", // firmware *-23...24, tested with
360 // SP1604N/TM100-23 and -24
361 "SAMSUNG SP(0451|08[0124]2|12[0145]3|16[0145]4)[CN]",
364 "-v 9,halfminutes -F samsung2"
366 { "SAMSUNG SpinPoint P80 series", // unknown firmware
367 "SAMSUNG SP(0451|08[0124]2|12[0145]3|16[0145]4)[CN]",
369 "May need -F samsung2 or -F samsung3 enabled; see manual for details.",
373 // TODO: Make the entries below more specific.
374 // These entries produce misleading results, because newer
375 // Samsung disks reuse the version numbers *-NN.
376 { "", // All Samsung drives with '.*-25' firmware
379 "May need -F samsung2 disabled; see manual for details.",
380 "-v 9,halfminutes -F samsung2"
382 { "", // All Samsung drives with '.*-26 or later (currently to -39)' firmware
384 ".*-(2[6789]|3[0-9])",
388 { "", // Samsung ALL OTHER DRIVES
391 "May need -F samsung or -F samsung2 enabled; see manual for details.",
395 { "Maxtor Fireball 541DX family",
396 "Maxtor 2B0(0[468]|1[05]|20)H1",
399 "-v 9,minutes -v 194,unknown"
401 { "Maxtor Fireball 3 family",
402 "Maxtor 2F0[234]0[JL]0",
407 { "Maxtor DiamondMax 1280 ATA family", // no self-test log, ATA2-Fast
408 "Maxtor 8(1280A2|2160A4|2560A4|3840A6|4000A6|5120A8)",
413 { "Maxtor DiamondMax 2160 Ultra ATA family",
414 "Maxtor 8(2160D2|3228D3|3240D3|4320D4|6480D6|8400D8|8455D8)",
419 { "Maxtor DiamondMax 2880 Ultra ATA family",
420 "Maxtor 9(0510D4|0576D4|0648D5|0720D5|0840D6|0845D6|0864D6|1008D7|1080D8|1152D8)",
425 { "Maxtor DiamondMax 3400 Ultra ATA family",
426 "Maxtor 9(1(360|350|202)D8|1190D7|10[12]0D6|0840D5|06[48]0D4|0510D3|1(350|202)E8|1010E6|0840E5|0640E4)",
431 { "Maxtor DiamondMax D540X-4G family",
432 "Maxtor 4G(120J6|160J[68])",
435 "-v 9,minutes -v 194,unknown"
437 { "Maxtor DiamondMax D540X-4K family",
438 "MAXTOR 4K(020H1|040H2|060H3|080H4)",
441 { "Maxtor DiamondMax Plus D740X family",
442 "MAXTOR 6L0(20[JL]1|40[JL]2|60[JL]3|80[JL]4)",
445 { "Maxtor DiamondMax Plus 5120 Ultra ATA 33 family",
446 "Maxtor 9(0512D2|0680D3|0750D3|0913D4|1024D4|1360D6|1536D6|1792D7|2048D8)",
451 { "Maxtor DiamondMax Plus 6800 Ultra ATA 66 family",
452 "Maxtor 9(2732U8|2390U7|204[09]U6|1707U5|1366U4|1024U3|0845U3|0683U2)",
457 { "Maxtor DiamondMax D540X-4D",
458 "Maxtor 4D0(20H1|40H2|60H3|80H4)",
461 "-v 9,minutes -v 194,unknown"
463 { "Maxtor DiamondMax 16 family",
464 "Maxtor 4(R0[68]0[JL]0|R1[26]0L0|A160J0|R120L4)",
469 { "Maxtor DiamondMax 4320 Ultra ATA family",
470 "Maxtor (91728D8|91512D7|91303D6|91080D5|90845D4|90645D3|90648D[34]|90432D2)",
475 { "Maxtor DiamondMax 17 VL family",
476 "Maxtor 9(0431U1|0641U2|0871U2|1301U3|1741U4)",
481 { "Maxtor DiamondMax 20 VL family",
482 "Maxtor (94091U8|93071U6|92561U5|92041U4|91731U4|91531U3|91361U3|91021U2|90841U2|90651U2)",
487 { "Maxtor DiamondMax VL 30 family", // U: ATA66, H: ATA100
488 "Maxtor (33073U4|32049U3|31536U2|30768U1|33073H4|32305H3|31536H2|30768H1)",
493 { "Maxtor DiamondMax 36 family",
494 "Maxtor (93652U8|92739U6|91826U4|91369U3|90913U2|90845U2|90435U1)",
499 { "Maxtor DiamondMax 40 ATA 66 series",
500 "Maxtor 9(0684U2|1024U2|1362U3|1536U3|2049U4|2562U5|3073U6|4098U8)",
505 { "Maxtor DiamondMax Plus 40 series (Ultra ATA 66 and Ultra ATA 100)",
506 "Maxtor (54098[UH]8|53073[UH]6|52732[UH]6|52049[UH]4|51536[UH]3|51369[UH]3|51024[UH]2)",
511 { "Maxtor DiamondMax 40 VL Ultra ATA 100 series",
512 "Maxtor 3(1024H1|1535H2|2049H2|3073H3|4098H4)( B)?",
517 { "Maxtor DiamondMax Plus 45 Ulta ATA 100 family",
518 "Maxtor 5(4610H6|4098H6|3073H4|2049H3|1536H2|1369H2|1023H2)",
523 { "Maxtor DiamondMax 60 ATA 66 family",
524 "Maxtor 9(1023U2|1536U2|2049U3|2305U3|3073U4|4610U6|6147U8)",
529 { "Maxtor DiamondMax 60 ATA 100 family",
530 "Maxtor 9(1023H2|1536H2|2049H3|2305H3|3073H4|4098H6|4610H6|6147H8)",
535 { "Maxtor DiamondMax Plus 60 family",
536 "Maxtor 5T0(60H6|40H4|30H3|20H2|10H1)",
541 { "Maxtor DiamondMax 80 family",
542 "Maxtor (98196H8|96147H6)",
547 { "Maxtor DiamondMax 536DX family",
548 "Maxtor 4W(100H6|080H6|060H4|040H3|030H2)",
553 { "Maxtor DiamondMax Plus 8 family",
554 "Maxtor 6(E0[234]|K04)0L0",
559 { "Maxtor DiamondMax 10 family (ATA/133 and SATA/150)",
560 "Maxtor 6(B(30|25|20|16|12|10|08)0[MPRS]|L(080[MLP]|(100|120)[MP]|160[MP]|200[MPRS]|250[RS]|300[RS]))0",
565 { "Maxtor DiamondMax 10 family (SATA/300)",
566 "Maxtor 6V(080E|160E|200E|250F|300F|320F)0",
569 { "Maxtor DiamondMax Plus 9 family",
570 "Maxtor 6Y((060|080|120|160)L0|(060|080|120|160|200|250)P0|(060|080|120|160|200|250)M0)",
575 { "Maxtor DiamondMax 11 family",
576 "Maxtor 6H[45]00[FR]0",
579 { "Maxtor DiamondMax 17",
580 "Maxtor 6G(080L|160[PE])0",
583 { "Seagate Maxtor DiamondMax 20",
584 "MAXTOR STM3(40|80|160)[28]1[12]0?AS?",
587 { "Seagate Maxtor DiamondMax 21",
588 "MAXTOR STM3(160215|(250|320)820|320620|500630)AS?",
591 { "Seagate Maxtor DiamondMax 22", // fixed firmware
592 "(MAXTOR )?STM3(500320|750330|1000340)AS?",
593 "MX1A", // http://seagate.custkb.com/seagate/crm/selfservice/search.jsp?DocId=207969
596 { "Seagate Maxtor DiamondMax 22", // fixed firmware
597 "(MAXTOR )?STM3(160813|320614|640323|1000334)AS?",
598 "MX1B", // http://seagate.custkb.com/seagate/crm/selfservice/search.jsp?DocId=207975
601 { "Seagate Maxtor DiamondMax 22", // buggy firmware
602 "(MAXTOR )?STM3(500320|750330|1000340)AS?",
604 "There are known problems with these drives,\n"
605 "AND THIS FIRMWARE VERSION IS AFFECTED,\n"
606 "see the following Seagate web pages:\n"
607 "http://seagate.custkb.com/seagate/crm/selfservice/search.jsp?DocId=207931\n"
608 "http://seagate.custkb.com/seagate/crm/selfservice/search.jsp?DocId=207969",
611 { "Seagate Maxtor DiamondMax 22", // unknown firmware
612 "(MAXTOR )?STM3(160813|32061[34]|500320|640323|750330|10003(34|40))AS?",
614 "There are known problems with these drives,\n"
615 "see the following Seagate web pages:\n"
616 "http://seagate.custkb.com/seagate/crm/selfservice/search.jsp?DocId=207931\n"
617 "http://seagate.custkb.com/seagate/crm/selfservice/search.jsp?DocId=207969\n"
618 "http://seagate.custkb.com/seagate/crm/selfservice/search.jsp?DocId=207975",
621 { "Seagate Maxtor DiamondMax 23",
622 "STM3((160|250)31|(320|500)41|(750|1000)52)8AS?",
625 { "Maxtor MaXLine Plus II",
631 { "Maxtor MaXLine II family",
632 "Maxtor [45]A(25|30|32)0[JN]0",
637 { "Maxtor MaXLine III family (ATA/133 and SATA/150)",
638 "Maxtor 7L(25|30)0[SR]0",
643 { "Maxtor MaXLine III family (SATA/300)",
644 "Maxtor 7V(25|30)0F0",
647 { "Maxtor MaXLine Pro 500 family", // There is also a 7H500R0 model, but I
648 "Maxtor 7H500F0", // haven't added it because I suspect
649 "", // it might need vendoropts_9_minutes
650 "", "" // and nobody has submitted a report yet
652 { "", // HITACHI_DK14FA-20B
653 "HITACHI_DK14FA-20B",
656 "-v 9,minutes -v 193,loadunload"
658 { "HITACHI Travelstar DK23XX/DK23XXB series",
659 "HITACHI_DK23..-..B?",
662 "-v 9,minutes -v 193,loadunload"
664 { "Hitachi Endurastar J4K20/N4K20 (formerly DK23FA-20J)",
665 "(HITACHI_DK23FA-20J|HTA422020F9AT[JN]0)",
668 "-v 9,minutes -v 193,loadunload"
670 { "Hitachi Endurastar J4K30/N4K30",
671 "HE[JN]4230[23]0F9AT00",
674 "-v 9,minutes -v 193,loadunload"
676 { "Hitachi Travelstar C4K60 family", // 1.8" slim drive
677 "HTC4260[23]0G5CE00|HTC4260[56]0G8CE00",
680 "-v 9,minutes -v 193,loadunload"
682 { "IBM Travelstar 4GT family",
683 "IBM-DTCA-2(324|409)0",
686 { "IBM Travelstar 6GN family",
687 "IBM-DBCA-20(324|486|648)0",
690 { "IBM Travelstar 25GS, 18GT, and 12GN family",
691 "IBM-DARA-2(25|18|15|12|09|06)000",
694 { "IBM Travelstar 14GS",
698 { "IBM Travelstar 4LP",
699 "IBM-DTNA-2(180|216)0",
702 { "IBM Travelstar 48GH, 30GN, and 15GN family",
703 "(IBM-|Hitachi )?IC25(T048ATDA05|N0(30|20|15|12|10|07|06|05)ATDA04)-.",
706 { "IBM Travelstar 32GH, 30GT, and 20GN family",
707 "IBM-DJSA-2(32|30|20|10|05)",
710 { "IBM Travelstar 4GN family",
711 "IBM-DKLA-2(216|324|432)0",
714 { "IBM/Hitachi Travelstar 60GH and 40GN family",
715 "(IBM-|Hitachi )?IC25(T060ATC[SX]05|N0[4321]0ATC[SX]04)-.",
718 { "IBM/Hitachi Travelstar 40GNX family",
719 "(IBM-|Hitachi )?IC25N0[42]0ATC[SX]05-.",
722 { "Hitachi Travelstar 80GN family",
723 "(Hitachi )?IC25N0[23468]0ATMR04-.",
726 { "Hitachi Travelstar 4K40",
727 "(Hitachi )?HTS4240[234]0M9AT00",
730 { "Hitachi Travelstar 4K120",
731 "(Hitachi )?(HTS4212(60|80|10|12)H9AT00|HTS421260G9AT00)",
734 { "Hitachi Travelstar 5K80 family",
735 "(Hitachi )?HTS5480[8642]0M9AT00",
738 { "Hitachi Travelstar 5K100 series",
739 "(Hitachi )?HTS5410[1864]0G9(AT|SA)00",
742 { "Hitachi Travelstar E5K100 series",
743 "(Hitachi )?HTE541040G9(AT|SA)00",
746 { "Hitachi Travelstar 5K120",
747 "(Hitachi )?HTS5412(60|80|10|12)H9(AT|SA)00",
750 { "Hitachi Travelstar 5K160 series",
751 "(Hitachi |HITACHI )?HTS5416([468]0|1[26])J9(AT|SA)00",
754 { "Hitachi Travelstar E5K160 series",
755 "(Hitachi )?HTE5416(12|16|60|80)J9(AT|SA)00",
758 { "Hitachi Travelstar 5K250 series",
759 "(Hitachi |HITACHI )?HTS5425(80|12|16|20|25)K9(A3|SA)00",
762 { "Hitachi Travelstar 7K60",
763 "(Hitachi )?HTS726060M9AT00",
766 { "Hitachi Travelstar E7K60",
767 "(Hitachi )?HTE7260[46]0M9AT00",
770 { "Hitachi Travelstar 7K100",
771 "(Hitachi )?HTS7210[168]0G9(AT|SA)00",
774 { "Hitachi Travelstar E7K100",
775 "(Hitachi )?HTE7210[168]0G9(AT|SA)00",
778 { "Hitachi Travelstar 7K200",
779 "(Hitachi )?HTS7220(80|10|12|16|20)K9(A3|SA)00",
782 { "IBM Deskstar 14GXP and 16GP series",
783 "IBM-DTTA-3(7101|7129|7144|5032|5043|5064|5084|5101|5129|5168)0",
786 { "IBM Deskstar 25GP and 22GXP family",
787 "IBM-DJNA-3(5(101|152|203|250)|7(091|135|180|220))0",
790 { "IBM Deskstar 37GP and 34GXP family",
791 "IBM-DPTA-3(5(375|300|225|150)|7(342|273|205|136))0",
794 { "IBM/Hitachi Deskstar 120GXP family",
795 "(IBM-)?IC35L((020|040|060|080|120)AVVA|0[24]0AVVN)07-[01]",
798 { "IBM/Hitachi Deskstar GXP-180 family",
799 "(IBM-)?IC35L(030|060|090|120|180)AVV207-[01]",
802 { "Hitachi Deskstar 7K80 series",
803 "(Hitachi )?HDS7280([48]0PLAT20|(40)?PLA320|80PLA380).*",
806 { "Hitachi Deskstar 7K160",
807 "(Hitachi )?HDS7216(80|16)PLA[3T]80.*",
810 { "Hitachi Deskstar 7K250 series",
811 "(Hitachi )?HDS7225((40|80|12|16)VLAT20|(12|16|25)VLAT80|(80|12|16|25)VLSA80)",
814 { "Hitachi Deskstar 7K250 (SUN branded)",
815 "HITACHI HDS7225SBSUN250G.*",
818 { "Hitachi Deskstar T7K250 series",
819 "(Hitachi )?HDT7225((25|20|16)DLA(T80|380))",
822 { "Hitachi Deskstar 7K400 series",
823 "(Hitachi )?HDS724040KL(AT|SA)80",
826 { "Hitachi Deskstar 7K500 series",
827 "(Hitachi )?HDS725050KLA(360|T80)",
830 { "Hitachi Deskstar P7K500 series",
831 "(Hitachi )?HDP7250(16|25|32|40|50)GLA(36|38|T8)0",
834 { "Hitachi Deskstar T7K500",
835 "(Hitachi )?HDT7250(25|32|40|50)VLA(360|380|T80)",
838 { "Hitachi Deskstar 7K1000",
839 "(Hitachi )?HDS7210(50|75|10)KLA330",
842 { "Hitachi Deskstar 7K1000.B",
843 "(Hitachi )?HDT7210((16|25)SLA380|(32|50|64|75|10)SLA360)",
846 { "Hitachi Ultrastar 7K1000",
847 "(Hitachi )?HUA7210(50|75|10)KLA330",
850 { "Toshiba 2.5\" HDD series (10-20 GB)",
851 "TOSHIBA MK(101[67]GAP|15[67]GAP|20(1[678]GAP|(18|23)GAS))",
854 { "Toshiba 2.5\" HDD series (30-60 GB)",
855 "TOSHIBA MK((6034|4032)GSX|(6034|4032)GAX|(6026|4026|4019|3019)GAXB?|(6025|6021|4025|4021|4018|3025|3021|3018)GAS|(4036|3029)GACE?|(4018|3017)GAP)",
858 { "Toshiba 2.5\" HDD series (80 GB and above)",
859 "TOSHIBA MK(80(25GAS|26GAX|32GAX|32GSX)|10(31GAS|32GAX)|12(33GAS|34G[AS]X)|2035GSS)",
862 { "Toshiba 2.5\" HDD MK..52GSX series",
863 "TOSHIBA MK(80|12|16|25|32)52GSX",
866 { "Toshiba 1.8\" HDD series",
867 "TOSHIBA MK[23468]00[4-9]GA[HL]",
870 { "", // TOSHIBA MK6022GAX
874 { "", // TOSHIBA MK6409MAV
878 { "Toshiba MKx019GAXB (SUN branded)",
879 "TOS MK[34]019GAXB SUN[34]0G",
882 { "Seagate Momentus family",
883 "ST9(20|28|40|48)11A",
886 { "Seagate Momentus 42 family",
887 "ST9(2014|3015|4019)A",
890 { "Seagate Momentus 4200.2 series",
891 "ST9(100822|808210|60821|50212|402113|30219)A",
894 { "Seagate Momentus 5400.2 series",
895 "ST9(808211|60822|408114|308110|120821|10082[34]|8823|6812|4813|3811)AS?",
898 { "Seagate Momentus 5400.3 series",
899 "ST9(4081[45]|6081[35]|8081[15]|100828|120822|160821)AS?",
902 { "Seagate Momentus 5400.3 ED series",
903 "ST9(4081[45]|6081[35]|8081[15]|100828|120822|160821)AB",
906 { "Seagate Momentus 5400.4 series",
907 "ST9(120817|(160|200|250)827)AS",
910 { "Seagate Momentus 5400.5 series",
911 "ST9((80|120|160)310|(250|320)320)AS",
914 { "Seagate Momentus 5400.6 series",
915 "ST9((12|25)0315AS|500325)ASG?",
918 { "Seagate Momentus 5400 PSD series", // Hybrid drives
919 "ST9(808212|(120|160)8220)AS",
922 { "Seagate Momentus 7200.1 series",
923 "ST9(10021|80825|6023|4015)AS?",
926 { "Seagate Momentus 7200.2 series",
927 "ST9(80813|100821|120823|160823|200420)ASG?",
930 { "Seagate Momentus 7200.3 series",
931 "ST9((80|120|160)411|(250|320)421)ASG?",
934 { "Seagate Medalist 1010, 1721, 2120, 3230 and 4340", // ATA2, with -t permissive
935 "ST3(1010|1721|2120|3230|4340)A",
938 { "Seagate Medalist 2110, 3221, 4321, 6531, and 8641",
939 "ST3(2110|3221|4321|6531|8641)A",
942 { "Seagate U Series X family",
943 "ST3(10014A(CE)?|20014A)",
946 { "Seagate U8 family",
947 "ST3(4313|6811|8410|13021|17221)A",
950 { "Seagate U7 family",
951 "ST3(30012|40012|60012|80022|120020)A",
954 { "Seagate U Series 6 family",
955 "ST3(8002|6002|4081|3061|2041)0A",
958 { "Seagate U Series 5 family",
959 "ST3(40823|30621|20413|15311|10211)A",
962 { "Seagate U4 family",
963 "ST3(2112|4311|6421|8421)A",
966 { "Seagate U8 family",
967 "ST3(8410|4313|17221|13021)A",
970 { "Seagate U10 family",
971 "ST3(20423|15323|10212)A",
974 { "Seagate Barracuda ATA family",
975 "ST3(2804|2724|2043|1362|1022|681)0A",
978 { "Seagate Barracuda ATA II family",
979 "ST3(3063|2042|1532|1021)0A",
982 { "Seagate Barracuda ATA III family",
983 "ST3(40824|30620|20414|15310|10215)A",
986 { "Seagate Barracuda ATA IV family",
987 "ST3(20011|30011|40016|60021|80021)A",
990 { "Seagate Barracuda ATA V family",
991 "ST3(12002(3A|4A|9A|3AS)|800(23A|15A|23AS)|60(015A|210A)|40017A)",
994 { "Seagate Barracuda 5400.1",
998 { "Seagate Barracuda 7200.7 and 7200.7 Plus family",
999 "ST3(200021A|200822AS?|16002[13]AS?|12002[26]AS?|1[26]082[78]AS|8001[13]AS?|8081[79]AS|60014A|40111AS|40014AS?)",
1002 { "Seagate Barracuda 7200.8 family",
1003 "ST3(400[68]32|300[68]31|250[68]23|200826)AS?",
1006 { "Seagate Barracuda 7200.9 family",
1007 "ST3(402111?|80[28]110?|120[28]1[0134]|160[28]1[012]|200827|250[68]24|300[68]22|(320|400)[68]33|500[68](32|41))AS?.*",
1010 { "Seagate Barracuda 7200.10 family",
1011 "ST3((80|160)[28]15|200820|250[34]10|(250|300|320|400)[68]20|500[68]30|750[68]40)AS?",
1014 { "Seagate Barracuda 7200.11 family", // unaffected firmware
1015 "ST3(160813|320[68]13|500[368]20|640[36]23|640[35]30|750[36]30|1000(333|[36]40)|1500341)AS?",
1016 "CC.?.?", // http://seagate.custkb.com/seagate/crm/selfservice/search.jsp?DocId=207957
1019 { "Seagate Barracuda 7200.11 family", // fixed firmware
1020 "ST3(500[368]20|750[36]30|1000340)AS?",
1021 "SD1A", // http://seagate.custkb.com/seagate/crm/selfservice/search.jsp?DocId=207951
1024 { "Seagate Barracuda 7200.11 family", // fixed firmware
1025 "ST3(160813|320[68]13|640[36]23|1000333|1500341)AS?",
1026 "SD1B", // http://seagate.custkb.com/seagate/crm/selfservice/search.jsp?DocId=207957
1029 { "Seagate Barracuda 7200.11 family", // buggy firmware
1030 "ST3(500[368]20|640[35]30|750[36]30|1000340)AS?",
1032 "There are known problems with these drives,\n"
1033 "AND THIS FIRMWARE VERSION IS AFFECTED,\n"
1034 "see the following Seagate web pages:\n"
1035 "http://seagate.custkb.com/seagate/crm/selfservice/search.jsp?DocId=207931\n"
1036 "http://seagate.custkb.com/seagate/crm/selfservice/search.jsp?DocId=207951",
1039 { "Seagate Barracuda 7200.11 family", // unknown firmware
1040 "ST3(160813|320[68]13|500[368]20|640[36]23|640[35]30|750[36]30|1000(333|[36]40)|1500341)AS?",
1042 "There are known problems with these drives,\n"
1043 "see the following Seagate web pages:\n"
1044 "http://seagate.custkb.com/seagate/crm/selfservice/search.jsp?DocId=207931\n"
1045 "http://seagate.custkb.com/seagate/crm/selfservice/search.jsp?DocId=207951\n"
1046 "http://seagate.custkb.com/seagate/crm/selfservice/search.jsp?DocId=207957",
1049 { "Seagate Barracuda 7200.12 family",
1050 "ST3((160|250)318|(320|500)418|500410|(750|1000)528)AS",
1053 { "Seagate Barracuda ES",
1054 "ST3(250[68]2|32062|40062|50063|75064)0NS",
1057 { "Seagate Barracuda ES.2", // fixed firmware
1058 "ST3(25031|50032|75033|100034)0NS",
1059 "SN[01]6", // http://seagate.custkb.com/seagate/crm/selfservice/search.jsp?DocId=207963
1062 { "Seagate Barracuda ES.2", // unknown firmware
1063 "ST3(25031|50032|75033|100034)0NS",
1065 "There are known problems with these drives,\n"
1066 "see the following Seagate web pages:\n"
1067 "http://seagate.custkb.com/seagate/crm/selfservice/search.jsp?DocId=207931\n"
1068 "http://seagate.custkb.com/seagate/crm/selfservice/search.jsp?DocId=207963",
1071 { "Seagate Medalist 17240, 13030, 10231, 8420, and 4310",
1072 "ST3(17240|13030|10231|8420|4310)A",
1075 { "Seagate Medalist 17242, 13032, 10232, 8422, and 4312",
1076 "ST3(1724|1303|1023|842|431)2A",
1079 { "Seagate NL35 family",
1080 "ST3(250623|250823|400632|400832|250824|250624|400633|400833|500641|500841)NS",
1083 { "Seagate SV35.2 Series",
1084 "ST3(160815|250820|320620|500630|750640)(A|S)V",
1087 { "Seagate DB35.3 Series",
1088 "ST3(750640SCE|((80|160)215|(250|320|400)820|500830|750840)(A|S)CE)",
1091 { "Western Digital Protege",
1092 /* Western Digital drives with this comment all appear to use Attribute 9 in
1093 * a non-standard manner. These entries may need to be updated when it
1094 * is understood exactly how Attribute 9 should be interpreted.
1095 * UPDATE: this is probably explained by the WD firmware bug described in the
1096 * smartmontools FAQ */
1097 "WDC WD([2468]00E|1[26]00A)B-.*",
1100 { "Western Digital Caviar family",
1101 /* Western Digital drives with this comment all appear to use Attribute 9 in
1102 * a non-standard manner. These entries may need to be updated when it
1103 * is understood exactly how Attribute 9 should be interpreted.
1104 * UPDATE: this is probably explained by the WD firmware bug described in the
1105 * smartmontools FAQ */
1106 "WDC WD(2|3|4|6|8|10|12|16|18|20|25)00BB-.*",
1109 { "Western Digital Caviar WDxxxAB series",
1110 /* Western Digital drives with this comment all appear to use Attribute 9 in
1111 * a non-standard manner. These entries may need to be updated when it
1112 * is understood exactly how Attribute 9 should be interpreted.
1113 * UPDATE: this is probably explained by the WD firmware bug described in the
1114 * smartmontools FAQ */
1115 "WDC WD(3|4|6|8|25)00AB-.*",
1118 { "Western Digital Caviar WDxxxAA series",
1119 /* Western Digital drives with this comment all appear to use Attribute 9 in
1120 * a non-standard manner. These entries may need to be updated when it
1121 * is understood exactly how Attribute 9 should be interpreted.
1122 * UPDATE: this is probably explained by the WD firmware bug described in the
1123 * smartmontools FAQ */
1124 "WDC WD...?AA(-.*)?",
1127 { "Western Digital Caviar WDxxxBA series",
1128 /* Western Digital drives with this comment all appear to use Attribute 9 in
1129 * a non-standard manner. These entries may need to be updated when it
1130 * is understood exactly how Attribute 9 should be interpreted.
1131 * UPDATE: this is probably explained by the WD firmware bug described in the
1132 * smartmontools FAQ */
1136 { "Western Digital Caviar AC series", // add only 5400rpm/7200rpm (ata33 and faster)
1137 "WDC AC((116|121|125|225|132|232)|([1-4][4-9][0-9])|([1-4][0-9][0-9][0-9]))00[A-Z]?.*",
1140 { "Western Digital Caviar SE family",
1141 /* Western Digital drives with this comment all appear to use Attribute 9 in
1142 * a non-standard manner. These entries may need to be updated when it
1143 * is understood exactly how Attribute 9 should be interpreted.
1144 * UPDATE: this is probably explained by the WD firmware bug described in the
1146 * UPDATE 2: this does not apply to more recent models, at least WD3200AAJB */
1147 "WDC WD(4|6|8|10|12|16|18|20|25|30|32|40|50)00(JB|PB)-.*",
1150 { "Western Digital Caviar Blue EIDE family", // WD Caviar SE EIDE family
1151 /* not completely accurate: at least also WD800JB, WD(4|8|20|25)00BB sold as Caviar Blue */
1152 "WDC WD(16|25|32|40|50)00AAJB-.*",
1155 { "Western Digital Caviar Blue EIDE family", // WD Caviar SE16 EIDE family
1156 "WDC WD(25|32|40|50)00AAKB-.*",
1159 { "Western Digital RE EIDE family",
1160 "WDC WD(12|16|25|32)00SB-.*",
1163 { "Western Digital Caviar Serial ATA family",
1164 "WDC WD(4|8|20|32)00BD-.*",
1167 { "Western Digital Caviar SE Serial ATA family",
1168 "WDC WD(4|8|12|16|20|25|32|40)00(JD|KD|PD)-.*",
1171 { "Western Digital Caviar SE Serial ATA family",
1172 "WDC WD(8|12|16|20|25|30|32|40|50)00JS-.*",
1175 { "Western Digital Caviar SE16 Serial ATA family",
1176 "WDC WD(16|20|25|32|40|50|75)00KS-.*",
1179 { "Western Digital Caviar Blue Serial ATA family", // WD Caviar SE Serial ATA family
1180 /* not completely accurate: at least also WD800BD, (4|8)00JD sold as Caviar Blue */
1181 "WDC WD((8|12|16|25|32)00AABS|(12|16|25|32|40|50)00AAJS)-.*",
1184 { "Western Digital Caviar Blue Serial ATA family", // WD Caviar SE16 Serial ATA family
1185 "WDC WD(16|20|25|32|40|50|64|75)00AAKS-.*",
1188 { "Western Digital RE Serial ATA family",
1189 "WDC WD(12|16|25|32)00(SD|YD|YS)-.*",
1192 { "Western Digital RE2 Serial ATA family",
1193 "WDC WD((40|50|75)00(YR|YS|AYYS)|(16|32|40|50)0[01]ABYS)-.*",
1196 { "Western Digital RE2-GP family",
1197 "WDC WD(5000AB|7500AY|1000FY)PS-.*",
1200 { "Western Digital RE3 Serial ATA family",
1201 "WDC WD((25|32|50)02A|(75|10)02F)BYS-.*",
1204 { "Western Digital Caviar Green family",
1205 "WDC WD((50|64|75)00AA(C|V)S|(50|75)00AADS|10EA(C|V)S|(10|15|20)EADS)-.*",
1208 { "Western Digital Caviar Black family",
1209 "WDC WD((500|640|750)1AA|1001FA)LS-.*",
1212 { "Western Digital AV ATA family",
1213 "WDC WD(8|16|50)00AV(B|J)B-.*",
1216 { "Western Digital AV-GP family",
1217 "WDC WD((16|25|32|50|64|75)00AVVS|(50|75)00AVCS|10EVVS|(10|20)EVCS|WD(10|15|20)EVDS)-.*",
1220 { "Western Digital Raptor family",
1221 "WDC WD((360|740|800)GD|(360|740|1500)ADF[DS])-.*",
1224 { "Western Digital VelociRaptor family",
1225 "WDC WD((1500|3000)B|3000G)LFS-.*",
1228 { "Western Digital Scorpio EIDE family",
1229 "WDC WD(4|6|8|10|12|16)00(UE|VE)-.*",
1232 { "Western Digital Scorpio Blue EIDE family",
1233 "WDC WD(4|6|8|10|12|16|25)00BEVE-.*",
1236 { "Western Digital Scorpio Serial ATA family",
1237 "WDC WD(4|6|8|10|12|16|25)00BEAS-.*",
1240 { "Western Digital Scorpio Blue Serial ATA family",
1241 "WDC WD((4|6|8|10|12|16|25)00BEVS|(8|12|16|25|32|40|50)00BEVT)-.*",
1244 { "Western Digital Scorpio Black Serial ATA family",
1245 "WDC WD(8|12|16|25|32)00B[EJ]KT-.*",
1248 { "Quantum Bigfoot series",
1249 "QUANTUM BIGFOOT TS10.0A",
1252 { "Quantum Fireball lct15 series",
1253 "QUANTUM FIREBALLlct15 ([123]0|22)",
1256 { "Quantum Fireball lct20 series",
1257 "QUANTUM FIREBALLlct20 [234]0",
1260 { "Quantum Fireball CX series",
1261 "QUANTUM FIREBALL CX10.2A",
1264 { "Quantum Fireball CR series",
1265 "QUANTUM FIREBALL CR(4.3|6.4|8.4|13.0)A",
1268 { "Quantum Fireball EX series",
1269 "QUANTUM FIREBALL EX(3.2|6.4)A",
1272 { "Quantum Fireball ST series",
1273 "QUANTUM FIREBALL ST(3.2|4.3|4300)A",
1276 { "Quantum Fireball SE series",
1277 "QUANTUM FIREBALL SE4.3A",
1280 { "Quantum Fireball Plus LM series",
1281 "QUANTUM FIREBALLP LM(10.2|15|20.[45]|30)",
1284 { "Quantum Fireball Plus AS series",
1285 "QUANTUM FIREBALLP AS(10.2|20.5|30.0|40.0)",
1288 { "Quantum Fireball Plus KX series",
1289 "QUANTUM FIREBALLP KX27.3",
1292 { "Quantum Fireball Plus KA series",
1293 "QUANTUM FIREBALLP KA(9|10).1",
1296 // END drivedb.h (DO NOT DELETE - used by Makefile)
1300 /// Drive database class. Stores custom entries read from file.
1301 /// Provides transparent access to concatenation of custom and
1303 class drive_database
1310 /// Get total number of entries.
1311 unsigned size() const
1312 { return m_custom_tab
.size() + m_builtin_size
; }
1314 /// Get number of custom entries.
1315 unsigned custom_size() const
1316 { return m_custom_tab
.size(); }
1319 const drive_settings
& operator[](unsigned i
);
1321 /// Append new custom entry.
1322 void push_back(const drive_settings
& src
);
1324 /// Append builtin table.
1325 void append(const drive_settings
* builtin_tab
, unsigned builtin_size
)
1326 { m_builtin_tab
= builtin_tab
; m_builtin_size
= builtin_size
; }
1329 const drive_settings
* m_builtin_tab
;
1330 unsigned m_builtin_size
;
1332 std::vector
<drive_settings
> m_custom_tab
;
1333 std::vector
<char *> m_custom_strings
;
1335 const char * copy_string(const char * str
);
1337 drive_database(const drive_database
&);
1338 void operator=(const drive_database
&);
1341 drive_database::drive_database()
1342 : m_builtin_tab(0), m_builtin_size(0)
1346 drive_database::~drive_database()
1348 for (unsigned i
= 0; i
< m_custom_strings
.size(); i
++)
1349 delete [] m_custom_strings
[i
];
1352 const drive_settings
& drive_database::operator[](unsigned i
)
1354 return (i
< m_custom_tab
.size() ? m_custom_tab
[i
]
1355 : m_builtin_tab
[i
- m_custom_tab
.size()] );
1358 void drive_database::push_back(const drive_settings
& src
)
1360 drive_settings dest
;
1361 dest
.modelfamily
= copy_string(src
.modelfamily
);
1362 dest
.modelregexp
= copy_string(src
.modelregexp
);
1363 dest
.firmwareregexp
= copy_string(src
.firmwareregexp
);
1364 dest
.warningmsg
= copy_string(src
.warningmsg
);
1365 dest
.presets
= copy_string(src
.presets
);
1366 m_custom_tab
.push_back(dest
);
1369 const char * drive_database::copy_string(const char * src
)
1371 char * dest
= new char[strlen(src
)+1];
1373 m_custom_strings
.push_back(dest
);
1376 delete [] dest
; throw;
1378 return strcpy(dest
, src
);
1382 /// The drive database.
1383 static drive_database knowndrives
;
1386 // Compile regular expression, print message on failure.
1387 static bool compile(regular_expression
& regex
, const char *pattern
)
1389 if (!regex
.compile(pattern
, REG_EXTENDED
)) {
1390 pout("Internal error: unable to compile regular expression \"%s\": %s\n"
1391 "Please inform smartmontools developers at " PACKAGE_BUGREPORT
"\n",
1392 pattern
, regex
.get_errmsg());
1398 // Compile & match a regular expression.
1399 static bool match(const char * pattern
, const char * str
)
1401 regular_expression regex
;
1402 if (!compile(regex
, pattern
))
1404 return regex
.full_match(str
);
1407 // Searches knowndrives[] for a drive with the given model number and firmware
1408 // string. If either the drive's model or firmware strings are not set by the
1409 // manufacturer then values of NULL may be used. Returns the entry of the
1410 // first match in knowndrives[] or 0 if no match if found.
1411 const drive_settings
* lookup_drive(const char * model
, const char * firmware
)
1418 for (unsigned i
= 0; i
< knowndrives
.size(); i
++) {
1419 // Check whether model matches the regular expression in knowndrives[i].
1420 if (!match(knowndrives
[i
].modelregexp
, model
))
1423 // Model matches, now check firmware. "" matches always.
1424 if (!( !*knowndrives
[i
].firmwareregexp
1425 || match(knowndrives
[i
].firmwareregexp
, firmware
)))
1429 return &knowndrives
[i
];
1436 // Parse '-v' and '-F' options in preset string, return false on error.
1437 static bool parse_presets(const char * presets
, unsigned char * opts
, unsigned char & fix_firmwarebug
)
1439 for (int i
= 0; ; ) {
1440 i
+= strspn(presets
+i
, " \t");
1443 char opt
, arg
[40+1+13]; int len
= -1;
1444 if (!(sscanf(presets
+i
, "-%c %40[^ ]%n", &opt
, arg
, &len
) >= 2 && len
> 0))
1447 // Parse "-v N,option"
1448 unsigned char newopts
[MAX_ATTRIBUTE_NUM
] = {0, };
1449 if (parse_attribute_def(arg
, newopts
))
1451 // Set only if not set by user
1452 for (int j
= 0; j
< MAX_ATTRIBUTE_NUM
; j
++)
1453 if (newopts
[j
] && !opts
[j
])
1454 opts
[j
] = newopts
[j
];
1456 else if (opt
== 'F') {
1458 if (!strcmp(arg
, "samsung"))
1460 else if (!strcmp(arg
, "samsung2"))
1462 else if (!strcmp(arg
, "samsung3"))
1466 // Set only if not set by user
1467 if (fix_firmwarebug
== FIX_NOTSPECIFIED
)
1468 fix_firmwarebug
= fix
;
1478 // Shows one entry of knowndrives[], returns #errors.
1479 static int showonepreset(const drive_settings
* dbentry
)
1481 // Basic error check
1483 && dbentry
->modelfamily
1484 && dbentry
->modelregexp
&& *dbentry
->modelregexp
1485 && dbentry
->firmwareregexp
1486 && dbentry
->warningmsg
1487 && dbentry
->presets
)) {
1488 pout("Invalid drive database entry. Please report\n"
1489 "this error to smartmontools developers at " PACKAGE_BUGREPORT
".\n");
1493 // print and check model and firmware regular expressions
1495 regular_expression regex
;
1496 pout("%-*s %s\n", TABLEPRINTWIDTH
, "MODEL REGEXP:", dbentry
->modelregexp
);
1497 if (!compile(regex
, dbentry
->modelregexp
))
1500 pout("%-*s %s\n", TABLEPRINTWIDTH
, "FIRMWARE REGEXP:", *dbentry
->firmwareregexp
?
1501 dbentry
->firmwareregexp
: ".*"); // preserve old output (TODO: Change)
1502 if (*dbentry
->firmwareregexp
&& !compile(regex
, dbentry
->firmwareregexp
))
1505 pout("%-*s %s\n", TABLEPRINTWIDTH
, "MODEL FAMILY:", dbentry
->modelfamily
);
1507 // if there are any presets, then show them
1508 unsigned char fix_firmwarebug
= 0;
1509 bool first_preset
= true;
1510 if (*dbentry
->presets
) {
1511 unsigned char opts
[MAX_ATTRIBUTE_NUM
] = {0,};
1512 if (!parse_presets(dbentry
->presets
, opts
, fix_firmwarebug
)) {
1513 pout("Syntax error in preset option string \"%s\"\n", dbentry
->presets
);
1516 for (int i
= 0; i
< MAX_ATTRIBUTE_NUM
; i
++) {
1519 ataPrintSmartAttribName(out
, i
, opts
);
1520 // Use leading zeros instead of spaces so that everything lines up.
1521 out
[0] = (out
[0] == ' ') ? '0' : out
[0];
1522 out
[1] = (out
[1] == ' ') ? '0' : out
[1];
1523 pout("%-*s %s\n", TABLEPRINTWIDTH
, first_preset
? "ATTRIBUTE OPTIONS:" : "", out
);
1524 first_preset
= false;
1529 pout("%-*s %s\n", TABLEPRINTWIDTH
, "ATTRIBUTE OPTIONS:", "None preset; no -v options are required.");
1531 // describe firmwarefix
1532 if (fix_firmwarebug
) {
1533 const char * fixdesc
;
1534 switch (fix_firmwarebug
) {
1536 fixdesc
= "Fixes byte order in some SMART data (same as -F samsung)";
1539 fixdesc
= "Fixes byte order in some SMART data (same as -F samsung2)";
1542 fixdesc
= "Fixes completed self-test reported as in progress (same as -F samsung3)";
1545 fixdesc
= "UNKNOWN"; errcnt
++;
1548 pout("%-*s %s\n", TABLEPRINTWIDTH
, "OTHER PRESETS:", fixdesc
);
1551 // Print any special warnings
1552 if (*dbentry
->warningmsg
)
1553 pout("%-*s %s\n", TABLEPRINTWIDTH
, "WARNINGS:", dbentry
->warningmsg
);
1557 // Shows all presets for drives in knowndrives[].
1558 // Returns #syntax errors.
1559 int showallpresets()
1561 // loop over all entries in the knowndrives[] table, printing them
1562 // out in a nice format
1564 for (unsigned i
= 0; i
< knowndrives
.size(); i
++) {
1565 errcnt
+= showonepreset(&knowndrives
[i
]);
1569 pout("Total number of entries :%5u\n"
1570 "Entries read from file(s):%5u\n\n",
1571 knowndrives
.size(), knowndrives
.custom_size());
1573 pout("For information about adding a drive to the database see the FAQ on the\n");
1574 pout("smartmontools home page: " PACKAGE_HOMEPAGE
"\n");
1577 pout("\nFound %d syntax error(s) in database.\n"
1578 "Please inform smartmontools developers at " PACKAGE_BUGREPORT
"\n", errcnt
);
1582 // Shows all matching presets for a drive in knowndrives[].
1583 // Returns # matching entries.
1584 int showmatchingpresets(const char *model
, const char *firmware
)
1587 const char * firmwaremsg
= (firmware
? firmware
: "(any)");
1589 for (unsigned i
= 0; i
< knowndrives
.size(); i
++) {
1590 if (!match(knowndrives
[i
].modelregexp
, model
))
1592 if ( firmware
&& *knowndrives
[i
].firmwareregexp
1593 && !match(knowndrives
[i
].firmwareregexp
, firmware
))
1597 pout("Drive found in smartmontools Database. Drive identity strings:\n"
1600 "match smartmontools Drive Database entry:\n",
1601 TABLEPRINTWIDTH
, "MODEL:", model
, TABLEPRINTWIDTH
, "FIRMWARE:", firmwaremsg
);
1603 pout("and match these additional entries:\n");
1604 showonepreset(&knowndrives
[i
]);
1608 pout("No presets are defined for this drive. Its identity strings:\n"
1611 "do not match any of the known regular expressions.\n",
1612 model
, firmwaremsg
);
1616 // Shows the presets (if any) that are available for the given drive.
1617 void show_presets(const ata_identify_device
* drive
, bool fix_swapped_id
)
1619 char model
[MODEL_STRING_LENGTH
+1], firmware
[FIRMWARE_STRING_LENGTH
+1];
1621 // get the drive's model/firmware strings
1622 format_ata_string(model
, drive
->model
, MODEL_STRING_LENGTH
, fix_swapped_id
);
1623 format_ata_string(firmware
, drive
->fw_rev
, FIRMWARE_STRING_LENGTH
, fix_swapped_id
);
1625 // and search to see if they match values in the table
1626 const drive_settings
* dbentry
= lookup_drive(model
, firmware
);
1629 pout("No presets are defined for this drive. Its identity strings:\n"
1632 "do not match any of the known regular expressions.\n"
1633 "Use -P showall to list all known regular expressions.\n",
1638 // We found a matching drive. Print out all information about it.
1639 pout("Drive found in smartmontools Database. Drive identity strings:\n"
1642 "match smartmontools Drive Database entry:\n",
1643 TABLEPRINTWIDTH
, "MODEL:", model
, TABLEPRINTWIDTH
, "FIRMWARE:", firmware
);
1644 showonepreset(dbentry
);
1647 // Sets preset vendor attribute options in opts by finding the entry
1648 // (if any) for the given drive in knowndrives[]. Values that have
1649 // already been set in opts will not be changed. Returns false if drive
1651 bool apply_presets(const ata_identify_device
*drive
, unsigned char * opts
,
1652 unsigned char & fix_firmwarebug
, bool fix_swapped_id
)
1654 // get the drive's model/firmware strings
1655 char model
[MODEL_STRING_LENGTH
+1], firmware
[FIRMWARE_STRING_LENGTH
+1];
1656 format_ata_string(model
, drive
->model
, MODEL_STRING_LENGTH
, fix_swapped_id
);
1657 format_ata_string(firmware
, drive
->fw_rev
, FIRMWARE_STRING_LENGTH
, fix_swapped_id
);
1659 // Look up the drive in knowndrives[].
1660 const drive_settings
* dbentry
= lookup_drive(model
, firmware
);
1664 if (*dbentry
->presets
) {
1666 if (!parse_presets(dbentry
->presets
, opts
, fix_firmwarebug
))
1667 pout("Syntax error in preset option string \"%s\"\n", dbentry
->presets
);
1673 /////////////////////////////////////////////////////////////////////////////
1674 // Parser for drive database files
1676 // Abstract pointer to read file input.
1677 // Operations supported: c = *p; c = p[1]; ++p;
1678 class stdin_iterator
1681 explicit stdin_iterator(FILE * f
)
1682 : m_f(f
) { get(); get(); }
1684 stdin_iterator
& operator++()
1685 { get(); return *this; }
1687 char operator*() const
1690 char operator[](int i
) const
1704 void stdin_iterator::get()
1708 m_next
= (ch
!= EOF
? ch
: 0);
1711 void stdin_iterator::fail() const
1713 throw std::runtime_error("stdin_iterator: wrong usage");
1717 // Use above as parser input 'pointer'. Can easily be changed later
1718 // to e.g. 'const char *' if above is too slow.
1719 typedef stdin_iterator parse_ptr
;
1721 // Skip whitespace and comments.
1722 static parse_ptr
skip_white(parse_ptr src
, const char * path
, int & line
)
1724 for ( ; ; ++src
) switch (*src
) {
1725 case ' ': case '\t':
1735 // skip '// comment'
1737 while (*src
&& *src
!= '\n')
1743 // skip '/* comment */'
1747 pout("%s(%d): Missing '*/'\n", path
, line
);
1750 char c
= *src
; ++src
;
1753 else if (c
== '*' && *src
== '/')
1767 // Info about a token.
1774 token_info() : type(0), line(0) { }
1778 static parse_ptr
get_token(parse_ptr src
, token_info
& token
, const char * path
, int & line
)
1780 src
= skip_white(src
, path
, line
);
1782 case '{': case '}': case ',':
1784 token
.type
= *src
; token
.line
= line
;
1790 token
.type
= '"'; token
.line
= line
;
1793 for (++src
; *src
!= '"'; ++src
) {
1795 if (!c
|| c
== '\n' || (c
== '\\' && !src
[1])) {
1796 pout("%s(%d): Missing terminating '\"'\n", path
, line
);
1797 token
.type
= '?'; token
.line
= line
;
1803 case 'n' : c
= '\n'; break;
1804 case '\n': ++line
; break;
1805 case '\\': case '"': break;
1807 pout("%s(%d): Unknown escape sequence '\\%c'\n", path
, line
, c
);
1808 token
.type
= '?'; token
.line
= line
;
1814 // Lookahead to detect string constant concatentation
1815 src
= skip_white(++src
, path
, line
);
1816 } while (*src
== '"');
1821 token
.type
= 0; token
.line
= line
;
1825 pout("%s(%d): Syntax error, invalid char '%c'\n", path
, line
, *src
);
1826 token
.type
= '?'; token
.line
= line
;
1827 while (*src
&& *src
!= '\n')
1835 // Parse drive database from abstract input pointer.
1836 static bool parse_drive_database(parse_ptr src
, drive_database
& db
, const char * path
)
1838 int state
= 0, field
= 0;
1839 std::string values
[5];
1842 token_info token
; int line
= 1;
1843 src
= get_token(src
, token
, path
, line
);
1845 // EOF is ok after '}', trailing ',' is also allowed.
1846 if (!token
.type
&& (state
== 0 || state
== 4))
1849 // Check expected token
1850 const char expect
[] = "{\",},";
1851 if (token
.type
!= expect
[state
]) {
1852 if (token
.type
!= '?')
1853 pout("%s(%d): Syntax error, '%c' expected\n", path
, token
.line
, expect
[state
]);
1855 // Skip to next entry
1856 while (token
.type
&& token
.type
!= '{')
1857 src
= get_token(src
, token
, path
, line
);
1864 // Interpret parser state
1866 case 0: // ... ^{...}
1867 state
= 1; field
= 0;
1869 case 1: // {... ^"..." ...}
1872 if (!token
.value
.empty()) {
1873 regular_expression regex
;
1874 if (!regex
.compile(token
.value
.c_str(), REG_EXTENDED
)) {
1875 pout("%s(%d): Error in regular expression: %s\n", path
, token
.line
, regex
.get_errmsg());
1879 else if (field
== 1) {
1880 pout("%s(%d): Missing regular expression for drive model\n", path
, token
.line
);
1885 if (!token
.value
.empty()) {
1886 unsigned char opts
[MAX_ATTRIBUTE_NUM
] = {0, }; unsigned char fix
= 0;
1887 if (!parse_presets(token
.value
.c_str(), opts
, fix
)) {
1888 pout("%s(%d): Syntax error in preset option string\n", path
, token
.line
);
1894 values
[field
] = token
.value
;
1895 state
= (++field
< 5 ? 2 : 3);
1897 case 2: // {... "..."^, ...}
1900 case 3: // {...^}, ...
1902 drive_settings entry
;
1903 entry
.modelfamily
= values
[0].c_str();
1904 entry
.modelregexp
= values
[1].c_str();
1905 entry
.firmwareregexp
= values
[2].c_str();
1906 entry
.warningmsg
= values
[3].c_str();
1907 entry
.presets
= values
[4].c_str();
1908 db
.push_back(entry
);
1912 case 4: // {...}^, ...
1916 pout("Bad state %d\n", state
);
1919 src
= get_token(src
, token
, path
, line
);
1924 // Read drive database from file.
1925 bool read_drive_database(const char * path
)
1927 stdio_file
f(path
, "r");
1929 pout("%s: cannot open drive database file\n", path
);
1933 return parse_drive_database(parse_ptr(f
), knowndrives
, path
);
1936 // Read drive databases from standard places.
1937 bool read_default_drive_databases()
1940 // Read file for local additions: /{,usr/local/}etc/smart_drivedb.h
1941 static const char db1
[] = SMARTMONTOOLS_SYSCONFDIR
"/smart_drivedb.h";
1943 static const char db1
[] = "./smart_drivedb.h";
1945 if (!access(db1
, 0)) {
1946 if (!read_drive_database(db1
))
1950 #ifdef SMARTMONTOOLS_DRIVEDBDIR
1951 // Read file from package: // /usr/{,local/}share/smartmontools/drivedb.h
1952 static const char db2
[] = SMARTMONTOOLS_DRIVEDBDIR
"/drivedb.h";
1953 if (!access(db2
, 0)) {
1954 if (!read_drive_database(db2
))
1960 // Append builtin table.
1961 knowndrives
.append(builtin_knowndrives
,
1962 sizeof(builtin_knowndrives
)/sizeof(builtin_knowndrives
[0]));