⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smartctl.cpp

📁 硬盘各项性能的测试,如温度容量版本健康度型号
💻 CPP
📖 第 1 页 / 共 3 页
字号:
  con->testcase=-1;  opterr=optopt=0;  badarg = captive = FALSE;    // This miserable construction is needed to get emacs to do proper indenting. Sorry!  while (-1 != (optchar = #ifdef HAVE_GETOPT_LONG                getopt_long(argc, argv, shortopts, longopts, NULL)#else                getopt(argc, argv, shortopts)#endif                )){    switch (optchar){    case 'V':      con->dont_print=FALSE;      printslogan();      printcopy();      exit(0);      break;    case 'q':      if (!strcmp(optarg,"errorsonly")) {        con->printing_switchable     = TRUE;        con->dont_print = FALSE;      } else if (!strcmp(optarg,"silent")) {        con->printing_switchable     = FALSE;        con->dont_print = TRUE;      } else if (!strcmp(optarg,"noserial")) {        con->dont_print_serial = TRUE;      } else {        badarg = TRUE;      }      break;    case 'd':      con->controller_explicit = 1;      if (!strcmp(optarg,"ata")) {        con->controller_type = CONTROLLER_ATA;        con->controller_port = 0;      } else if (!strcmp(optarg,"scsi")) {        con->controller_type = CONTROLLER_SCSI;        con->controller_port = 0;      } else if (!strcmp(optarg,"marvell")) {        con->controller_type = CONTROLLER_MARVELL_SATA;        con->controller_port = 0;      } else if (!strncmp(optarg, "sat", 3)) {        con->controller_type = CONTROLLER_SAT;        con->controller_port = 0;        con->satpassthrulen = 0;        if (strlen(optarg) > 3) {          int k;          char * cp;          cp = strchr(optarg, ',');          if (cp && (1 == sscanf(cp + 1, "%d", &k)) &&              ((0 == k) || (12 == k) || (16 == k)))            con->satpassthrulen = k;          else {            sprintf(extraerror, "Option '-d sat,<n>' requires <n> to be "                    "0, 12 or 16\n");            badarg = TRUE;          }        }      } else if (!strncmp(optarg, "hpt", 3)){        unsigned char i, slash = 0;        con->hpt_data[0] = 0;        con->hpt_data[1] = 0;        con->hpt_data[2] = 0;        con->controller_type = CONTROLLER_HPT;        for (i=4; i < strlen(optarg); i++) {          if(optarg[i] == '/') {            slash++;            if(slash == 3) {              sprintf(extraerror, "Option '-d hpt,L/M/N' supports 2-3 items\n");              badarg = TRUE;              break;            }          }          else if ((optarg[i])>='0' && (optarg[i])<='9') {            if (con->hpt_data[slash]>1) { /* hpt_data[x] max 19 */              badarg = TRUE;              break;            }            con->hpt_data[slash] = con->hpt_data[slash]*10 + optarg[i] - '0';          }          else {            badarg = TRUE;            break;          }        }        if (slash == 0) {          sprintf(extraerror, "Option '-d hpt,L/M/N' requires 2-3 items\n");          badarg = TRUE;        } else if (badarg != TRUE) {          if (con->hpt_data[0]==0 || con->hpt_data[0]>8){            sprintf(extraerror, "Option '-d hpt,L/M/N' no/invalid controller id L supplied\n");            badarg = TRUE;          }          if (con->hpt_data[1]==0 || con->hpt_data[1]>8){            sprintf(extraerror, "Option '-d hpt,L/M/N' no/invalid channel number M supplied\n");            badarg = TRUE;          }          if (slash==2) {            if ( con->hpt_data[2]==0 || con->hpt_data[2]>15) {              sprintf(extraerror, "Option '-d hpt,L/M/N' no/invalid pmport number N supplied\n");              badarg = TRUE;            }          } else {            con->hpt_data[2]=1;          }        }      } else {        // look for RAID-type device        int i;        char *s;                // make a copy of the string to mess with        if (!(s = strdup(optarg))) {          con->dont_print = FALSE;          pout("No memory for argument of -d. Exiting...\n");          exit(FAILCMD);        } else if (!strncmp(s,"3ware,",6)) {            if (split_report_arg2(s, &i)) {                 sprintf(extraerror, "Option -d 3ware,N requires N to be a non-negative integer\n");                 badarg = TRUE;            } else if (i<0 || i>31) {                 sprintf(extraerror, "Option -d 3ware,N (N=%d) must have 0 <= N <= 31\n", i);                 badarg = TRUE;            } else { 	        // NOTE: controller_port == disk number + 1 	        con->controller_type = CONTROLLER_3WARE;                 con->controller_port = i+1;            } 	    free(s);        } else if (!strncmp(s,"cciss,",6)) {             if (split_report_arg2(s, &i)) {                 sprintf(extraerror, "Option -d cciss,N requires N to be a non-negative integer\n");                 badarg = TRUE;             } else if (i<0 || i>127) {                 sprintf(extraerror, "Option -d cciss,N (N=%d) must have 0 <= N <= 127\n", i);                 badarg = TRUE;             } else {               // NOTE: controller_port == drive number               con->controller_type = CONTROLLER_CCISS;               con->controller_port = i+1;             }             free(s);        } else 	    badarg=TRUE;      }      break;    case 'T':      if (!strcmp(optarg,"normal")) {        con->conservative = FALSE;        con->permissive   = 0;      } else if (!strcmp(optarg,"conservative")) {        con->conservative = TRUE;      } else if (!strcmp(optarg,"permissive")) {        if (con->permissive<0xff)          con->permissive++;      } else if (!strcmp(optarg,"verypermissive")) {        con->permissive=0xff;      } else {        badarg = TRUE;      }      break;    case 'b':      if (!strcmp(optarg,"warn")) {        con->checksumfail   = FALSE;        con->checksumignore = FALSE;      } else if (!strcmp(optarg,"exit")) {        con->checksumfail   = TRUE;        con->checksumignore = FALSE;      } else if (!strcmp(optarg,"ignore")) {        con->checksumignore = TRUE;        con->checksumfail   = FALSE;      } else {        badarg = TRUE;      }      break;    case 'r':      {        int i;        char *s;        // split_report_arg() may modify its first argument string, so use a        // copy of optarg in case we want optarg for an error message.        if (!(s = strdup(optarg))) {          con->dont_print = FALSE;          pout("Can't allocate memory to copy argument to -r option"               " - exiting\n");          EXIT(FAILCMD);        }        if (split_report_arg(s, &i)) {          badarg = TRUE;        } else if (!strcmp(s,"ioctl")) {          con->reportataioctl  = con->reportscsiioctl = i;        } else if (!strcmp(s,"ataioctl")) {          con->reportataioctl = i;        } else if (!strcmp(s,"scsiioctl")) {          con->reportscsiioctl = i;        } else {          badarg = TRUE;        }        free(s);      }      break;    case 's':      if (!strcmp(optarg,"on")) {        con->smartenable  = TRUE;        con->smartdisable = FALSE;      } else if (!strcmp(optarg,"off")) {        con->smartdisable = TRUE;        con->smartenable  = FALSE;      } else {        badarg = TRUE;      }      break;    case 'o':      if (!strcmp(optarg,"on")) {        con->smartautoofflineenable  = TRUE;        con->smartautoofflinedisable = FALSE;      } else if (!strcmp(optarg,"off")) {        con->smartautoofflinedisable = TRUE;        con->smartautoofflineenable  = FALSE;      } else {        badarg = TRUE;      }      break;    case 'S':      if (!strcmp(optarg,"on")) {        con->smartautosaveenable  = TRUE;        con->smartautosavedisable = FALSE;      } else if (!strcmp(optarg,"off")) {        con->smartautosavedisable = TRUE;        con->smartautosaveenable  = FALSE;      } else {        badarg = TRUE;      }      break;    case 'H':      con->checksmart = TRUE;                 break;    case 'F':      if (!strcmp(optarg,"none")) {        con->fixfirmwarebug = FIX_NONE;      } else if (!strcmp(optarg,"samsung")) {        con->fixfirmwarebug = FIX_SAMSUNG;      } else if (!strcmp(optarg,"samsung2")) {        con->fixfirmwarebug = FIX_SAMSUNG2;      } else if (!strcmp(optarg,"samsung3")) {        con->fixfirmwarebug = FIX_SAMSUNG3;      } else if (!strcmp(optarg,"swapid")) {        con->fixswappedid = TRUE;      } else {        badarg = TRUE;      }      break;    case 'c':      con->generalsmartvalues = TRUE;      break;    case 'A':      con->smartvendorattrib = TRUE;      break;    case 'l':      if (!strcmp(optarg,"error")) {        con->smarterrorlog = TRUE;      } else if (!strcmp(optarg,"selftest")) {        con->smartselftestlog = TRUE;      } else if (!strcmp(optarg, "selective")) {        con->selectivetestlog = TRUE;      } else if (!strcmp(optarg,"directory")) {        con->smartlogdirectory = TRUE;      } else if (!strcmp(optarg,"background")) {        con->smartbackgroundlog = TRUE;      } else if (!strcmp(optarg,"scttemp")) {        con->scttempsts = con->scttemphist = TRUE;      } else if (!strcmp(optarg,"scttempsts")) {        con->scttempsts = TRUE;      } else if (!strcmp(optarg,"scttemphist")) {        con->scttemphist = TRUE;      } else {        badarg = TRUE;      }      break;    case 'i':      con->driveinfo = TRUE;      break;                case 'a':      con->driveinfo          = TRUE;      con->checksmart         = TRUE;      con->generalsmartvalues = TRUE;      con->smartvendorattrib  = TRUE;      con->smarterrorlog      = TRUE;      con->smartselftestlog   = TRUE;      con->selectivetestlog   = TRUE;      /* con->smartbackgroundlog = TRUE; */      break;    case 'v':      // parse vendor-specific definitions of attributes      if (!strcmp(optarg,"help")) {        char *s;        con->dont_print=FALSE;        printslogan();        if (!(s = create_vendor_attribute_arg_list())) {          pout("Insufficient memory to construct argument list\n");          EXIT(FAILCMD);        }        pout("The valid arguments to -v are:\n\thelp\n%s\n", s);        free(s);        EXIT(0);      }      charp=con->attributedefs;      if (!charp){        pout("Fatal internal error in ParseOpts()\n");        EXIT(FAILCMD);      }      if (parse_attribute_def(optarg, &charp))        badarg = TRUE;      break;        case 'P':      if (!strcmp(optarg, "use")) {        con->ignorepresets = FALSE;      } else if (!strcmp(optarg, "ignore")) {        con->ignorepresets = TRUE;      } else if (!strcmp(optarg, "show")) {        con->showpresets = TRUE;      } else if (!strcmp(optarg, "showall")) {        if (optind < argc) { // -P showall MODEL [FIRMWARE]          int cnt = showmatchingpresets(argv[optind], (optind+1<argc ? argv[optind+1] : NULL));          EXIT(cnt); // report #matches        }        if (showallpresets())          EXIT(FAILCMD); // report regexp syntax error        EXIT(0);      } else {        badarg = TRUE;      }      break;    case 't':      if (!strcmp(optarg,"offline")) {        con->smartexeoffimmediate = TRUE;        con->testcase             = OFFLINE_FULL_SCAN;      } else if (!strcmp(optarg,"short")) {        con->smartshortselftest = TRUE;        con->testcase           = SHORT_SELF_TEST;      } else if (!strcmp(optarg,"long")) {        con->smartextendselftest = TRUE;        con->testcase            = EXTEND_SELF_TEST;      } else if (!strcmp(optarg,"conveyance")) {        con->smartconveyanceselftest = TRUE;        con->testcase            = CONVEYANCE_SELF_TEST;      } else if (!strcmp(optarg,"afterselect,on")) {	// scan remainder of disk after doing selected segments	con->scanafterselect=2;      } else if (!strcmp(optarg,"afterselect,off")) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -