Ticket #730: smartctl.cpp.diff

File smartctl.cpp.diff, 4.1 KB (added by Casey Biemiller, 8 years ago)

A diff of smartctl.cpp

  • smartctl.cpp

     
    4545#include "atacmds.h"
    4646#include "dev_interface.h"
    4747#include "ataprint.h"
     48#include "intelliprop.h"
    4849#include "knowndrives.h"
    4950#include "scsicmds.h"
    5051#include "scsiprint.h"
     
    174175"        Do test in captive mode (along with -t)\n\n"
    175176"  -X, --abort\n"
    176177"        Abort any non-captive test on device\n\n"
     178"========================================= INTELLIPROP SPECIFIC COMMAND======\n\n"
     179"  --iprop-routecmd=[0-3]\n"
     180"        Select which drive/port routed commands should be sent to.\n\n"
    177181);
    178182  std::string examples = smi()->get_app_examples("smartctl");
    179183  if (!examples.empty())
     
    181185}
    182186
    183187// Values for  --long only options, see parse_options()
    184 enum { opt_identify = 1000, opt_scan, opt_scan_open, opt_set, opt_smart };
     188enum { opt_identify = 1000, opt_scan, opt_scan_open, opt_set, opt_smart, opt_iprop_routecmd };
    185189
    186190/* Returns a string containing a formatted list of the valid arguments
    187191   to the option opt or empty on failure. Note 'v' case different */
     
    231235    return getvalidarglist(opt_smart)+", "+getvalidarglist(opt_set);
    232236  case opt_identify:
    233237    return "n, wn, w, v, wv, wb";
     238  case opt_iprop_routecmd:
     239    return "0, 1, 2, 3";
    234240  case 'v':
    235241  default:
    236242    return "";
     
    309315    { "set",             required_argument, 0, opt_set },
    310316    { "scan",            no_argument,       0, opt_scan      },
    311317    { "scan-open",       no_argument,       0, opt_scan_open },
     318    { "iprop-routecmd",  required_argument, 0, opt_iprop_routecmd },
    312319    { 0,                 0,                 0, 0   }
    313320  };
    314321
     
    635642      }
    636643      break;
    637644
     645    case opt_iprop_routecmd:
     646      ataopts.iprop_args.issue_intelliprop_cmd = true;
     647      ataopts.iprop_args.is_routed_cmd = true;
     648      if (optarg) {
     649        for (int i = 0; optarg[i]; i++) {
     650          switch (optarg[i]) {
     651            case '0': ataopts.iprop_args.drive_select = 0; break;
     652            case '1': ataopts.iprop_args.drive_select = 1; break;
     653            case '2': ataopts.iprop_args.drive_select = 2; break;
     654            case '3': ataopts.iprop_args.drive_select = 3; break;
     655            default: badarg = true;
     656          }
     657        }
     658      }
     659      break;
     660
    638661    case 'a':
    639662      ataopts.drive_info           = scsiopts.drive_info          = nvmeopts.drive_info          = true;
    640663      ataopts.smart_check_status   = scsiopts.smart_check_status  = nvmeopts.smart_check_status  = true;
     
    10551078      pout("=======> INVALID ARGUMENT TO -%s: %s\n",
    10561079        (optchar == opt_identify ? "-identify" :
    10571080         optchar == opt_set ? "-set" :
    1058          optchar == opt_smart ? "-smart" : optstr), optarg);
     1081         optchar == opt_smart ? "-smart" :
     1082         optchar == opt_iprop_routecmd ? "-iprop_routecmd" : optstr), optarg);
    10591083      printvalidarglistmessage(optchar);
    10601084      if (extraerror[0])
    10611085        pout("=======> %s", extraerror);
     
    13671391
    13681392  // now call appropriate ATA or SCSI routine
    13691393  int retval = 0;
    1370   if (print_type_only)
     1394  if (print_type_only){
    13711395    pout("%s: Device of type '%s' [%s] opened\n",
    13721396         dev->get_info_name(), dev->get_dev_type(), get_protocol_info(dev.get()));
    1373   else if (dev->is_ata())
    1374     retval = ataPrintMain(dev->to_ata(), ataopts);
    1375   else if (dev->is_scsi())
     1397  } else if (dev->is_ata()) {
     1398      //If the command is specific to an IntelliProp controller, go to the proper handling
     1399    if (ataopts.iprop_args.issue_intelliprop_cmd) {
     1400      retval = iprop_main_ata(dev->to_ata(), ataopts.iprop_args);
     1401    } else {
     1402      retval = ataPrintMain(dev->to_ata(), ataopts);
     1403    }
     1404  } else if (dev->is_scsi()) {
    13761405    retval = scsiPrintMain(dev->to_scsi(), scsiopts);
    1377   else if (dev->is_nvme())
     1406  } else if (dev->is_nvme()) {
    13781407    retval = nvmePrintMain(dev->to_nvme(), nvmeopts);
    1379   else
     1408  } else {
    13801409    // we should never fall into this branch!
    13811410    pout("%s: Neither ATA, SCSI nor NVMe device\n", dev->get_info_name());
    1382 
     1411  }
    13831412  dev->close();
    13841413  return retval;
    13851414}