Ticket #730: smartctl.cpp.diff
File smartctl.cpp.diff, 4.1 KB (added by , 9 years ago) |
---|
-
smartctl.cpp
45 45 #include "atacmds.h" 46 46 #include "dev_interface.h" 47 47 #include "ataprint.h" 48 #include "intelliprop.h" 48 49 #include "knowndrives.h" 49 50 #include "scsicmds.h" 50 51 #include "scsiprint.h" … … 174 175 " Do test in captive mode (along with -t)\n\n" 175 176 " -X, --abort\n" 176 177 " 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" 177 181 ); 178 182 std::string examples = smi()->get_app_examples("smartctl"); 179 183 if (!examples.empty()) … … 181 185 } 182 186 183 187 // Values for --long only options, see parse_options() 184 enum { opt_identify = 1000, opt_scan, opt_scan_open, opt_set, opt_smart };188 enum { opt_identify = 1000, opt_scan, opt_scan_open, opt_set, opt_smart, opt_iprop_routecmd }; 185 189 186 190 /* Returns a string containing a formatted list of the valid arguments 187 191 to the option opt or empty on failure. Note 'v' case different */ … … 231 235 return getvalidarglist(opt_smart)+", "+getvalidarglist(opt_set); 232 236 case opt_identify: 233 237 return "n, wn, w, v, wv, wb"; 238 case opt_iprop_routecmd: 239 return "0, 1, 2, 3"; 234 240 case 'v': 235 241 default: 236 242 return ""; … … 309 315 { "set", required_argument, 0, opt_set }, 310 316 { "scan", no_argument, 0, opt_scan }, 311 317 { "scan-open", no_argument, 0, opt_scan_open }, 318 { "iprop-routecmd", required_argument, 0, opt_iprop_routecmd }, 312 319 { 0, 0, 0, 0 } 313 320 }; 314 321 … … 635 642 } 636 643 break; 637 644 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 638 661 case 'a': 639 662 ataopts.drive_info = scsiopts.drive_info = nvmeopts.drive_info = true; 640 663 ataopts.smart_check_status = scsiopts.smart_check_status = nvmeopts.smart_check_status = true; … … 1055 1078 pout("=======> INVALID ARGUMENT TO -%s: %s\n", 1056 1079 (optchar == opt_identify ? "-identify" : 1057 1080 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); 1059 1083 printvalidarglistmessage(optchar); 1060 1084 if (extraerror[0]) 1061 1085 pout("=======> %s", extraerror); … … 1367 1391 1368 1392 // now call appropriate ATA or SCSI routine 1369 1393 int retval = 0; 1370 if (print_type_only) 1394 if (print_type_only){ 1371 1395 pout("%s: Device of type '%s' [%s] opened\n", 1372 1396 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()) { 1376 1405 retval = scsiPrintMain(dev->to_scsi(), scsiopts); 1377 else if (dev->is_nvme())1406 } else if (dev->is_nvme()) { 1378 1407 retval = nvmePrintMain(dev->to_nvme(), nvmeopts); 1379 else1408 } else { 1380 1409 // we should never fall into this branch! 1381 1410 pout("%s: Neither ATA, SCSI nor NVMe device\n", dev->get_info_name()); 1382 1411 } 1383 1412 dev->close(); 1384 1413 return retval; 1385 1414 }