📄 knowndrives.cpp
字号:
}, { "Seagate Barracuda ATA III family", "^ST3(40824|30620|20414|15310|10215)A$", ".*", NULL, NULL, NULL, NULL }, { "Seagate Barracuda ATA IV family", "^ST3(20011|30011|40016|60021|80021)A$", ".*", NULL, NULL, NULL, NULL }, { "Seagate Barracuda ATA V family", "^ST3(12002(3A|4A|9A|3AS)|800(23A|15A|23AS)|60(015A|210A)|40017A)$", ".*", NULL, NULL, NULL, NULL }, { "Seagate Barracuda 5400.1", "^ST340015A$", ".*", NULL, NULL, NULL, NULL }, { "Seagate Barracuda 7200.7 and 7200.7 Plus family", "^ST3(200021A|200822AS?|16002[13]AS?|12002[26]AS?|1[26]082[78]AS|8001[13]AS?|80817AS|60014A|40111AS|40014AS?)$", ".*", NULL, NULL, NULL, NULL }, { "Seagate Barracuda 7200.8 family", "^ST3(400[68]32|300[68]31|250[68]23|200826)AS?$", ".*", NULL, NULL, NULL, NULL }, { "Seagate Barracuda 7200.9 family", "^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?$", ".*", NULL, NULL, NULL, NULL }, { "Seagate Barracuda 7200.10 family", "^ST3((80|160)[28]15|200820|250[34]10|(250|300|320|400)[68]20|500[68]30|750[68]40)AS?$", ".*", NULL, NULL, NULL, NULL }, { "Seagate Barracuda 7200.11", "^ST3(500[368]2|750[36]3|1000[36]4)0AS?$", ".*", NULL, NULL, NULL, NULL }, { "Seagate Barracuda ES", "^ST3(250[68]2|32062|40062|50063|75064)0NS$", ".*", NULL, NULL, NULL, NULL }, { "Seagate Medalist 17240, 13030, 10231, 8420, and 4310", "^ST3(17240|13030|10231|8420|4310)A$", ".*", NULL, NULL, NULL, NULL }, { "Seagate Medalist 17242, 13032, 10232, 8422, and 4312", "^ST3(1724|1303|1023|842|431)2A$", ".*", NULL, NULL, NULL, NULL }, { "Seagate NL35 family", "^ST3(250623|250823|400632|400832|250824|250624|400633|400833|500641|500841)NS$", ".*", NULL, NULL, NULL, NULL }, { "Western Digital Protege", /* Western Digital drives with this comment all appear to use Attribute 9 in * a non-standard manner. These entries may need to be updated when it * is understood exactly how Attribute 9 should be interpreted. * UPDATE: this is probably explained by the WD firmware bug described in the * smartmontools FAQ */ "^WDC WD([2468]00E|1[26]00A)B-.*$", ".*", NULL, NULL, NULL, NULL }, { "Western Digital Caviar family", /* Western Digital drives with this comment all appear to use Attribute 9 in * a non-standard manner. These entries may need to be updated when it * is understood exactly how Attribute 9 should be interpreted. * UPDATE: this is probably explained by the WD firmware bug described in the * smartmontools FAQ */ "^WDC WD(2|3|4|6|8|10|12|16|18|20|25)00BB-.*$", ".*", NULL, NULL, NULL, NULL }, { "Western Digital Caviar WDxxxAB series", /* Western Digital drives with this comment all appear to use Attribute 9 in * a non-standard manner. These entries may need to be updated when it * is understood exactly how Attribute 9 should be interpreted. * UPDATE: this is probably explained by the WD firmware bug described in the * smartmontools FAQ */ "^WDC WD(3|4|6)00AB-.*$", ".*", NULL, NULL, NULL, NULL }, { "Western Digital Caviar WDxxxAA series", /* Western Digital drives with this comment all appear to use Attribute 9 in * a non-standard manner. These entries may need to be updated when it * is understood exactly how Attribute 9 should be interpreted. * UPDATE: this is probably explained by the WD firmware bug described in the * smartmontools FAQ */ "^WDC WD...?AA(-.*)?$", ".*", NULL, NULL, NULL, NULL }, { "Western Digital Caviar WDxxxBA series", /* Western Digital drives with this comment all appear to use Attribute 9 in * a non-standard manner. These entries may need to be updated when it * is understood exactly how Attribute 9 should be interpreted. * UPDATE: this is probably explained by the WD firmware bug described in the * smartmontools FAQ */ "^WDC WD...BA$", ".*", NULL, NULL, NULL, NULL }, { NULL, // Western Digital Caviar AC12500, AC14300, AC23200, AC24300, AC25100, // AC36400, AC38400 "^WDC AC(125|143|232|243|251|364|384)00.?", ".*", NULL, NULL, NULL, NULL }, { "Western Digital Caviar Serial ATA family", "^WDC WD(4|8|20|32)00BD-.*$", ".*", NULL, NULL, NULL, NULL }, { "Western Digital Caviar SE family", /* Western Digital drives with this comment all appear to use Attribute 9 in * a non-standard manner. These entries may need to be updated when it * is understood exactly how Attribute 9 should be interpreted. * UPDATE: this is probably explained by the WD firmware bug described in the * smartmontools FAQ * UPDATE 2: this does not apply to more recent models, at least WD3200AAJB */ "^WDC WD((4|6|8|10|12|16|18|20|25|30|32|40|50)00(JB|PB|AAJB|AAKB))-.*$", ".*", NULL, NULL, NULL, NULL }, { "Western Digital Caviar SE Serial ATA family", "^WDC WD((4|8|12|16|20|25|32|40)00(JD|KD))-.*$", ".*", NULL, NULL, NULL, NULL }, { "Western Digital Caviar Second Generation Serial ATA family", "^WDC WD((8|12|16|20|25|30|32|40|50|75)00(JS|KS|AABS|AAJS|AAKS))-.*$", ".*", NULL, NULL, NULL, NULL }, { "Western Digital Caviar RE Serial ATA family", "^WDC WD((12|16|25|32|40|50|75)00(SD|YD|YR|YS|ABYS|AYYS))-.*$", ".*", NULL, NULL, NULL, NULL }, { "Western Digital Caviar RE EIDE family", "^WDC WD((12|16|25|32)00SB)-.*$", ".*", NULL, NULL, NULL, NULL }, { "Western Digital Raptor family", "^WDC WD((360|740|800)GD|(360|740|1500)ADFD)-.*$", ".*", NULL, NULL, NULL, NULL }, { "Western Digital Scorpio family", "^WDC WD((4|6|8|10|12|16|20|25)00(UE|VE|BEAS|BEVE|BEVS))-.*$", ".*", NULL, NULL, NULL, NULL }, { NULL, // QUANTUM BIGFOOT TS10.0A "^QUANTUM BIGFOOT TS10.0A$", ".*", NULL, NULL, NULL, NULL }, { NULL, // QUANTUM FIREBALLlct15 20 and QUANTUM FIREBALLlct15 30 "^QUANTUM FIREBALLlct15 [123]0$", ".*", NULL, NULL, NULL, NULL }, { "QUANTUM FIREBALLlct20 series", "^QUANTUM FIREBALLlct20 [234]0$", ".*", NULL, NULL, NULL, NULL }, { NULL, // QUANTUM FIREBALL CX10.2A "^QUANTUM FIREBALL CX10.2A$", ".*", NULL, NULL, NULL, NULL }, { "Quantum Fireball Plus LM series", "^QUANTUM FIREBALLP LM(10.2|15|20.5|30)$", ".*", NULL, NULL, NULL, NULL }, { "Quantum Fireball CR series", "^QUANTUM FIREBALL CR(4.3|8.4)A$", ".*", NULL, NULL, NULL, NULL }, { NULL, // QUANTUM FIREBALLP AS10.2, AS20.5, AS30.0, and AS40.0 "^QUANTUM FIREBALLP AS(10.2|20.5|30.0|40.0)$", ".*", NULL, NULL, NULL, NULL }, { NULL, // QUANTUM FIREBALL EX6.4A "^QUANTUM FIREBALL EX6.4A$", ".*", NULL, NULL, NULL, NULL }, { NULL, // QUANTUM FIREBALL ST3.2A "^QUANTUM FIREBALL ST(3.2|4.3)A$", ".*", NULL, NULL, NULL, NULL }, { NULL, // QUANTUM FIREBALL EX3.2A "^QUANTUM FIREBALL EX3.2A$", ".*", NULL, NULL, NULL, NULL }, { NULL, // QUANTUM FIREBALLP KX27.3 "^QUANTUM FIREBALLP KX27.3$", ".*", NULL, NULL, NULL, NULL }, { "Quantum Fireball Plus KA series", "^QUANTUM FIREBALLP KA(9|10).1$", ".*", NULL, NULL, NULL, NULL }, { "Quantum Fireball SE series", "^QUANTUM FIREBALL SE4.3A$", ".*", NULL, NULL, NULL, NULL }, /*------------------------------------------------------------ * End of table. Do not add entries below this marker. *------------------------------------------------------------ */ {NULL, NULL, NULL, NULL, NULL, NULL, NULL}};// Searches knowndrives[] for a drive with the given model number and firmware// string. If either the drive's model or firmware strings are not set by the// manufacturer then values of NULL may be used. Returns the index of the// first match in knowndrives[] or -1 if no match if found.int lookupdrive(const char *model, const char *firmware){ regex_t regex; int i, index; const char *empty = ""; model = model ? model : empty; firmware = firmware ? firmware : empty; for (i = 0, index = -1; index == -1 && knowndrives[i].modelregexp; i++) { // Attempt to compile regular expression. if (compileregex(®ex, knowndrives[i].modelregexp, REG_EXTENDED)) goto CONTINUE; // Check whether model matches the regular expression in knowndrives[i]. if (!regexec(®ex, model, 0, NULL, 0)) { // model matches, now check firmware. if (!knowndrives[i].firmwareregexp) // The firmware regular expression in knowndrives[i] is NULL, which is // considered a match. index = i; else { // Compare firmware against the regular expression in knowndrives[i]. regfree(®ex); // Recycle regex. if (compileregex(®ex, knowndrives[i].firmwareregexp, REG_EXTENDED)) goto CONTINUE; if (!regexec(®ex, firmware, 0, NULL, 0)) index = i; } } CONTINUE: regfree(®ex); } return index;}// Shows all presets for drives in knowndrives[].void showonepreset(const drivesettings *drivetable){ const unsigned char (* presets)[2] = drivetable->vendoropts; int first_preset = 1; // Basic error check if (!drivetable || !drivetable->modelregexp){ pout("Null known drive table pointer. Please report\n" "this error to smartmontools developers at " PACKAGE_BUGREPORT ".\n"); return; } // print model and firmware regular expressions pout("%-*s %s\n", TABLEPRINTWIDTH, "MODEL REGEXP:", drivetable->modelregexp); pout("%-*s %s\n", TABLEPRINTWIDTH, "FIRMWARE REGEXP:", drivetable->firmwareregexp ? drivetable->firmwareregexp : ""); pout("%-*s %s\n", TABLEPRINTWIDTH, "MODEL FAMILY:", drivetable->modelfamily ? drivetable->modelfamily : ""); // if there are any presets, then show them if (presets && (*presets)[0]) while (1) { char out[256]; const int attr = (*presets)[0], val = (*presets)[1]; unsigned char fakearray[MAX_ATTRIBUTE_NUM]; // if we are at the end of the attribute list, break out if (!attr) break; // This is a hack. ataPrintSmartAttribName() needs a pointer to an // "array" to dereference, so we provide such a pointer. fakearray[attr]=val; ataPrintSmartAttribName(out, attr, fakearray); // Use leading zeros instead of spaces so that everything lines up. out[0] = (out[0] == ' ') ? '0' : out[0]; out[1] = (out[1] == ' ') ? '0' : out[1]; pout("%-*s %s\n", TABLEPRINTWIDTH, first_preset ? "ATTRIBUTE OPTIONS:" : "", out); first_preset = 0; presets++; } else pout("%-*s %s\n", TABLEPRINTWIDTH, "ATTRIBUTE OPTIONS:", "None preset; no -v options are required."); // Is a special purpose function defined? If so, describe it if (drivetable->specialpurpose){ pout("%-*s ", TABLEPRINTWIDTH, "OTHER PRESETS:"); pout("%s\n", drivetable->functiondesc ? drivetable->functiondesc : "A special purpose function " "is defined for this drive"); } // Print any special warnings if (drivetable->warningmsg){ pout("%-*s ", TABLEPRINTWIDTH, "WARNINGS:"); pout("%s\n", drivetable->warningmsg); } return;}// Shows all presets for drives in knowndrives[].// Returns <0 on syntax error in regular expressions.int showallpresets(void){ int i; int rc = 0; regex_t regex; // loop over all entries in the knowndrives[] table, printing them // out in a nice format for (i=0; knowndrives[i].modelregexp; i++){ showonepreset(&knowndrives[i]); pout("\n"); } // Check all regular expressions for (i=0; knowndrives[i].modelregexp; i++){ if (compileregex(®ex, knowndrives[i].modelregexp, REG_EXTENDED)) rc = -1; if (knowndrives[i].firmwareregexp) { if (compileregex(®ex, knowndrives[i].firmwareregexp, REG_EXTENDED)) rc = -1; } } pout("For information about adding a drive to the database see the FAQ on the\n"); pout("smartmontools home page: " PACKAGE_HOMEPAGE "\n"); return rc;}// Shows all matching presets for a drive in knowndrives[].// Returns # matching entries.int showmatchingpresets(const char *model, const char *firmware){ int i; int cnt = 0; const char * firmwaremsg = (firmware ? firmware : "(any)"); regex_t regex; for (i=0; knowndrives[i].modelregexp; i++){ if (i > 0) regfree(®ex); if (compileregex(®ex, knowndrives[i].modelregexp, REG_EXTENDED)) continue; if (regexec(®ex, model, 0, NULL, 0)) continue; if (firmware && knowndrives[i].firmwareregexp) { regfree(®ex); if (compileregex(®ex, knowndrives[i].firmwareregexp, REG_EXTENDED)) continue; if (regexec(®ex, firmware, 0, NULL, 0)) continue; } if (++cnt == 1) pout("Drive found in smartmontools Database. Drive identity strings:\n" "%-*s %s\n" "%-*s %s\n" "match smartmontools Drive Database entry:\n", TABLEPRINTWIDTH, "MODEL:", model, TABLEPRINTWIDTH, "FIRMWARE:", firmwaremsg); else if (cnt == 2) pout("and match these additional entries:\n"); showonepreset(&knowndrives[i]); pout("\n"); } regfree(®ex); if (cnt == 0) pout("No presets are defined for this drive. Its identity strings:\n" "MODEL: %s\n" "FIRMWARE: %s\n" "do not match any of the known regular expressions.\n", model, firmwaremsg); return cnt;}// Shows the presets (if any) that are available for the given drive.void showpresets(const struct ata_identify_device *drive){ int i; char model[MODEL_STRING_LENGTH+1], firmware[FIRMWARE_STRING_LENGTH+1]; // get the drive's model/firmware strings format_ata_string(model, (char *)drive->model, MODEL_STRING_LENGTH); format_ata_string(firmware, (char *)drive->fw_rev, FIRMWARE_STRING_LENGTH); // and search to see if they match values in the table if ((i = lookupdrive(model, firmware)) < 0) { // no matches found pout("No presets are defined for this drive. Its identity strings:\n" "MODEL: %s\n" "FIRMWARE: %s\n" "do not match any of the known regular expressions.\n" "Use -P showall to list all known regular expressions.\n", model, firmware); return; } // We found a matching drive. Print out all information about it. pout("Drive found in smartmontools Database. Drive identity strings:\n" "%-*s %s\n" "%-*s %s\n" "match smartmontools Drive Database entry:\n", TABLEPRINTWIDTH, "MODEL:", model, TABLEPRINTWIDTH, "FIRMWARE:", firmware); showonepreset(&knowndrives[i]); return;}// Sets preset vendor attribute options in opts by finding the entry// (if any) for the given drive in knowndrives[]. Values that have// already been set in opts will not be changed. Returns <0 if drive// not recognized else index >=0 into drive database.int applypresets(const struct ata_identify_device *drive, unsigned char **optsptr, smartmonctrl *con) { int i; unsigned char *opts; char model[MODEL_STRING_LENGTH+1], firmware[FIRMWARE_STRING_LENGTH+1]; if (*optsptr==NULL) bytes+=MAX_ATTRIBUTE_NUM; if (*optsptr==NULL && !(*optsptr=(unsigned char *)calloc(MAX_ATTRIBUTE_NUM,1))){ pout("Unable to allocate memory in applypresets()"); bytes-=MAX_ATTRIBUTE_NUM; EXIT(1); } opts=*optsptr; // get the drive's model/firmware strings format_ata_string(model, (char *)drive->model, MODEL_STRING_LENGTH); format_ata_string(firmware, (char *)drive->fw_rev, FIRMWARE_STRING_LENGTH); // Look up the drive in knowndrives[]. if ((i = lookupdrive(model, firmware)) >= 0) { // if vendoropts is non-NULL then Attribute interpretation presets if (knowndrives[i].vendoropts) { const unsigned char (* presets)[2]; // For each attribute in list of attribute/val pairs... presets = knowndrives[i].vendoropts; while (1) { const int attr = (*presets)[0]; const int val = (*presets)[1]; if (!attr) break; // ... set attribute if user hasn't already done so. if (!opts[attr]) opts[attr] = val; presets++; } } // If a special-purpose function is defined for this drive then // call it. Note that if command line arguments or Directives // over-ride this choice, then the specialpurpose function that is // called must deal with this. if (knowndrives[i].specialpurpose) (*knowndrives[i].specialpurpose)(con); } // return <0 if drive wasn't recognized, or index>=0 into database // if it was return i;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -