4 * Home page of code is: http://www.smartmontools.org
6 * Copyright (C) 2002-11 Bruce Allen
8 * Copyright (C) 2008-16 Christian Franke
10 * Copyright (C) 2008-15 Christian Franke
11 >>>>>>> 3d8ad6fa4529eb02ae1391a1e937bf57aad3fb74
12 * Copyright (C) 2000 Michael Cornwell <cornwell@acm.org>
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2, or (at your option)
19 * You should have received a copy of the GNU General Public License
20 * (for example COPYING); If not, see <http://www.gnu.org/licenses/>.
22 * This code was originally developed as a Senior Thesis by Michael Cornwell
23 * at the Concurrent Systems Laboratory (now part of the Storage Systems
24 * Research Center), Jack Baskin School of Engineering, University of
25 * California, Santa Cruz. http://ssrc.soe.ucsc.edu/
31 #include <sys/types.h>
44 #if defined(__FreeBSD__)
45 #include <sys/param.h>
50 #include "dev_interface.h"
52 #include "knowndrives.h"
54 #include "scsiprint.h"
55 #include "nvmeprint.h"
60 const char * smartctl_cpp_cvsid
= "$Id: smartctl.cpp 4311 2016-04-27 21:03:01Z chrfranke $"
62 const char * smartctl_cpp_cvsid
= "$Id: smartctl.cpp 4080 2015-05-05 20:31:22Z chrfranke $"
63 >>>>>>> 3d8ad6fa4529eb02ae1391a1e937bf57aad3fb74
64 CONFIG_H_CVSID SMARTCTL_H_CVSID
;
66 // Globals to control printing
67 bool printing_is_switchable
= false;
68 bool printing_is_off
= false;
70 static void printslogan()
72 pout("%s\n", format_version_info("smartctl").c_str());
75 static void UsageSummary()
77 pout("\nUse smartctl -h to get a usage summary\n\n");
81 static std::string
getvalidarglist(int opt
);
83 /* void prints help information for command syntax */
86 printf("Usage: smartctl [options] device\n\n");
88 "============================================ SHOW INFORMATION OPTIONS =====\n\n"
89 " -h, --help, --usage\n"
90 " Display this help and exit\n\n"
91 " -V, --version, --copyright, --license\n"
92 " Print license, copyright, and version information and exit\n\n"
94 " Show identity information for device\n\n"
95 " --identify[=[w][nvb]]\n"
96 " Show words and bits from IDENTIFY DEVICE data (ATA)\n\n"
97 " -g NAME, --get=NAME\n"
98 " Get device setting: all, aam, apm, lookahead, security, wcache, rcache, wcreorder\n\n"
100 " Show all SMART information for device\n\n"
102 " Show all information for device\n\n"
104 " Scan for devices\n\n"
106 " Scan for devices and try to open each device\n\n"
109 "================================== SMARTCTL RUN-TIME BEHAVIOR OPTIONS =====\n\n"
110 " -q TYPE, --quietmode=TYPE (ATA)\n"
111 " Set smartctl quiet mode to one of: errorsonly, silent, noserial\n\n"
112 " -d TYPE, --device=TYPE\n"
113 " Specify device type to one of: %s\n\n"
114 " -T TYPE, --tolerance=TYPE (ATA)\n"
115 " Tolerance: normal, conservative, permissive, verypermissive\n\n"
116 " -b TYPE, --badsum=TYPE (ATA)\n"
117 " Set action on bad checksum to one of: warn, exit, ignore\n\n"
118 " -r TYPE, --report=TYPE\n"
119 " Report transactions (see man page)\n\n"
120 " -n MODE, --nocheck=MODE (ATA)\n"
121 " No check if: never, sleep, standby, idle (see man page)\n\n",
122 getvalidarglist('d').c_str()); // TODO: Use this function also for other options ?
124 "============================== DEVICE FEATURE ENABLE/DISABLE COMMANDS =====\n\n"
125 " -s VALUE, --smart=VALUE\n"
126 " Enable/disable SMART on device (on/off)\n\n"
127 " -o VALUE, --offlineauto=VALUE (ATA)\n"
128 " Enable/disable automatic offline testing on device (on/off)\n\n"
129 " -S VALUE, --saveauto=VALUE (ATA)\n"
130 " Enable/disable Attribute autosave on device (on/off)\n\n"
131 " -s NAME[,VALUE], --set=NAME[,VALUE]\n"
132 " Enable/disable/change device setting: aam,[N|off], apm,[N|off],\n"
133 " lookahead,[on|off], security-freeze, standby,[N|off|now],\n"
134 " wcache,[on|off], rcache,[on|off], wcreorder,[on|off]\n\n"
137 "======================================= READ AND DISPLAY DATA OPTIONS =====\n\n"
139 " Show device SMART health status\n\n"
140 " -c, --capabilities (ATA, NVMe)\n"
141 " Show device SMART capabilities\n\n"
142 " -A, --attributes\n"
143 " Show device SMART vendor-specific Attributes and values\n\n"
144 " -f FORMAT, --format=FORMAT (ATA)\n"
145 " Set output format for attributes: old, brief, hex[,id|val]\n\n"
146 " -l TYPE, --log=TYPE\n"
147 " Show device log. TYPE: error, selftest, selective, directory[,g|s],\n"
148 " xerror[,N][,error], xselftest[,N][,selftest],\n"
149 " background, sasphy[,reset], sataphy[,reset],\n"
150 " scttemp[sts,hist], scttempint,N[,p],\n"
151 " scterc[,N,M], devstat[,N], ssd,\n"
152 " gplog,N[,RANGE], smartlog,N[,RANGE],\n"
153 " nvmelog,N,SIZE\n\n"
154 " -v N,OPTION , --vendorattribute=N,OPTION (ATA)\n"
155 " Set display OPTION for vendor Attribute N (see man page)\n\n"
156 " -F TYPE, --firmwarebug=TYPE (ATA)\n"
157 " Use firmware bug workaround:\n"
159 " -P TYPE, --presets=TYPE (ATA)\n"
160 " Drive-specific presets: use, ignore, show, showall\n\n"
161 " -B [+]FILE, --drivedb=[+]FILE (ATA)\n"
162 " Read and replace [add] drive database from FILE\n"
164 get_valid_firmwarebug_args(),
165 get_drivedb_path_add()
167 #ifdef SMARTMONTOOLS_DRIVEDBDIR
171 get_drivedb_path_default()
176 "============================================ DEVICE SELF-TEST OPTIONS =====\n\n"
177 " -t TEST, --test=TEST\n"
178 " Run test. TEST: offline, short, long, conveyance, force, vendor,N,\n"
179 " select,M-N, pending,N, afterselect,[on|off]\n\n"
181 " Do test in captive mode (along with -t)\n\n"
183 " Abort any non-captive test on device\n\n"
185 std::string examples
= smi()->get_app_examples("smartctl");
186 if (!examples
.empty())
187 printf("%s\n", examples
.c_str());
190 // Values for --long only options, see parse_options()
191 enum { opt_identify
= 1000, opt_scan
, opt_scan_open
, opt_set
, opt_smart
};
193 /* Returns a string containing a formatted list of the valid arguments
194 to the option opt or empty on failure. Note 'v' case different */
195 static std::string
getvalidarglist(int opt
)
199 return "errorsonly, silent, noserial";
201 return smi()->get_valid_dev_types_str() + ", auto, test";
203 return "normal, conservative, permissive, verypermissive";
205 return "warn, exit, ignore";
207 return "ioctl[,N], ataioctl[,N], scsiioctl[,N], nvmeioctl[,N]";
213 return "error, selftest, selective, directory[,g|s], "
214 "xerror[,N][,error], xselftest[,N][,selftest], "
215 "background, sasphy[,reset], sataphy[,reset], "
216 "scttemp[sts,hist], scttempint,N[,p], "
217 "scterc[,N,M], devstat[,N], ssd, "
218 "gplog,N[,RANGE], smartlog,N[,RANGE], "
221 return "use, ignore, show, showall";
223 return "offline, short, long, conveyance, force, vendor,N, select,M-N, "
224 "pending,N, afterselect,[on|off]";
226 return std::string(get_valid_firmwarebug_args()) + ", swapid";
228 return "never, sleep, standby, idle";
230 return "old, brief, hex[,id|val]";
232 return "aam, apm, lookahead, security, wcache, rcache, wcreorder";
234 return "aam,[N|off], apm,[N|off], lookahead,[on|off], security-freeze, "
235 "standby,[N|off|now], wcache,[on|off], rcache,[on|off], wcreorder,[on|off]";
237 return getvalidarglist(opt_smart
)+", "+getvalidarglist(opt_set
);
239 return "n, wn, w, v, wv, wb";
246 /* Prints the message "=======> VALID ARGUMENTS ARE: <LIST> \n", where
247 <LIST> is the list of valid arguments for option opt. */
248 static void printvalidarglistmessage(int opt
)
251 pout("=======> VALID ARGUMENTS ARE:\n\thelp\n%s\n<=======\n",
252 create_vendor_attribute_arg_list().c_str());
255 // getvalidarglist() might produce a multiline or single line string. We
256 // need to figure out which to get the formatting right.
257 std::string s
= getvalidarglist(opt
);
258 char separator
= strchr(s
.c_str(), '\n') ? '\n' : ' ';
259 pout("=======> VALID ARGUMENTS ARE:%c%s%c<=======\n", separator
, s
.c_str(), separator
);
265 // Checksum error mode
266 enum checksum_err_mode_t
{
267 CHECKSUM_ERR_WARN
, CHECKSUM_ERR_EXIT
, CHECKSUM_ERR_IGNORE
270 static checksum_err_mode_t checksum_err_mode
= CHECKSUM_ERR_WARN
;
272 static void scan_devices(const smart_devtype_list
& types
, bool with_open
, char ** argv
);
275 /* Takes command options and sets features to be run */
276 static const char * parse_options(int argc
, char** argv
,
277 ata_print_options
& ataopts
, scsi_print_options
& scsiopts
,
278 nvme_print_options
& nvmeopts
, bool & print_type_only
)
280 // Please update getvalidarglist() if you edit shortopts
281 const char *shortopts
= "h?Vq:d:T:b:r:s:o:S:HcAl:iaxv:P:t:CXF:n:B:f:g:";
282 // Please update getvalidarglist() if you edit longopts
283 struct option longopts
[] = {
284 { "help", no_argument
, 0, 'h' },
285 { "usage", no_argument
, 0, 'h' },
286 { "version", no_argument
, 0, 'V' },
287 { "copyright", no_argument
, 0, 'V' },
288 { "license", no_argument
, 0, 'V' },
289 { "quietmode", required_argument
, 0, 'q' },
290 { "device", required_argument
, 0, 'd' },
291 { "tolerance", required_argument
, 0, 'T' },
292 { "badsum", required_argument
, 0, 'b' },
293 { "report", required_argument
, 0, 'r' },
294 { "smart", required_argument
, 0, opt_smart
},
295 { "offlineauto", required_argument
, 0, 'o' },
296 { "saveauto", required_argument
, 0, 'S' },
297 { "health", no_argument
, 0, 'H' },
298 { "capabilities", no_argument
, 0, 'c' },
299 { "attributes", no_argument
, 0, 'A' },
300 { "log", required_argument
, 0, 'l' },
301 { "info", no_argument
, 0, 'i' },
302 { "all", no_argument
, 0, 'a' },
303 { "xall", no_argument
, 0, 'x' },
304 { "vendorattribute", required_argument
, 0, 'v' },
305 { "presets", required_argument
, 0, 'P' },
306 { "test", required_argument
, 0, 't' },
307 { "captive", no_argument
, 0, 'C' },
308 { "abort", no_argument
, 0, 'X' },
309 { "firmwarebug", required_argument
, 0, 'F' },
310 { "nocheck", required_argument
, 0, 'n' },
311 { "drivedb", required_argument
, 0, 'B' },
312 { "format", required_argument
, 0, 'f' },
313 { "get", required_argument
, 0, 'g' },
314 { "identify", optional_argument
, 0, opt_identify
},
315 { "set", required_argument
, 0, opt_set
},
316 { "scan", no_argument
, 0, opt_scan
},
317 { "scan-open", no_argument
, 0, opt_scan_open
},
321 char extraerror
[256];
322 memset(extraerror
, 0, sizeof(extraerror
));
325 const char * type
= 0; // set to -d optarg
326 smart_devtype_list scan_types
; // multiple -d TYPE options for --scan
327 bool use_default_db
= true; // set false on '-B FILE'
328 bool output_format_set
= false; // set true on '-f FORMAT'
329 int scan
= 0; // set by --scan, --scan-open
330 bool badarg
= false, captive
= false;
331 int testcnt
= 0; // number of self-tests requested
336 while ((optchar
= getopt_long(argc
, argv
, shortopts
, longopts
, 0)) != -1) {
339 printing_is_off
= false;
340 pout("%s", format_version_info("smartctl", true /*full*/).c_str());
344 if (!strcmp(optarg
,"errorsonly")) {
345 printing_is_switchable
= true;
346 printing_is_off
= false;
347 } else if (!strcmp(optarg
,"silent")) {
348 printing_is_switchable
= false;
349 printing_is_off
= true;
350 } else if (!strcmp(optarg
,"noserial")) {
351 dont_print_serial_number
= true;
357 if (!strcmp(optarg
, "test"))
358 print_type_only
= true;
359 else if (!strcmp(optarg
, "auto")) {
365 scan_types
.push_back(optarg
);
369 if (!strcmp(optarg
,"normal")) {
370 failuretest_conservative
= false;
371 failuretest_permissive
= 0;
372 } else if (!strcmp(optarg
,"conservative")) {
373 failuretest_conservative
= true;
374 } else if (!strcmp(optarg
,"permissive")) {
375 if (failuretest_permissive
< 0xff)
376 failuretest_permissive
++;
377 } else if (!strcmp(optarg
,"verypermissive")) {
378 failuretest_permissive
= 0xff;
384 if (!strcmp(optarg
,"warn")) {
385 checksum_err_mode
= CHECKSUM_ERR_WARN
;
386 } else if (!strcmp(optarg
,"exit")) {
387 checksum_err_mode
= CHECKSUM_ERR_EXIT
;
388 } else if (!strcmp(optarg
,"ignore")) {
389 checksum_err_mode
= CHECKSUM_ERR_IGNORE
;
396 int n1
= -1, n2
= -1, len
= strlen(optarg
);
397 char s
[9+1]; unsigned i
= 1;
398 sscanf(optarg
, "%9[a-z]%n,%u%n", s
, &n1
, &i
, &n2
);
399 if (!((n1
== len
|| n2
== len
) && 1 <= i
&& i
<= 4)) {
401 } else if (!strcmp(s
,"ioctl")) {
402 ata_debugmode
= scsi_debugmode
= nvme_debugmode
= i
;
403 } else if (!strcmp(s
,"ataioctl")) {
405 } else if (!strcmp(s
,"scsiioctl")) {
407 } else if (!strcmp(s
,"nvmeioctl")) {
416 case opt_smart
: // --smart
417 if (!strcmp(optarg
,"on")) {
418 ataopts
.smart_enable
= scsiopts
.smart_enable
= true;
419 ataopts
.smart_disable
= scsiopts
.smart_disable
= false;
420 } else if (!strcmp(optarg
,"off")) {
421 ataopts
.smart_disable
= scsiopts
.smart_disable
= true;
422 ataopts
.smart_enable
= scsiopts
.smart_enable
= false;
423 } else if (optchar
== 's') {
424 goto case_s_continued
; // --set, see below
431 if (!strcmp(optarg
,"on")) {
432 ataopts
.smart_auto_offl_enable
= true;
433 ataopts
.smart_auto_offl_disable
= false;
434 } else if (!strcmp(optarg
,"off")) {
435 ataopts
.smart_auto_offl_disable
= true;
436 ataopts
.smart_auto_offl_enable
= false;
442 if (!strcmp(optarg
,"on")) {
443 ataopts
.smart_auto_save_enable
= scsiopts
.smart_auto_save_enable
= true;
444 ataopts
.smart_auto_save_disable
= scsiopts
.smart_auto_save_disable
= false;
445 } else if (!strcmp(optarg
,"off")) {
446 ataopts
.smart_auto_save_disable
= scsiopts
.smart_auto_save_disable
= true;
447 ataopts
.smart_auto_save_enable
= scsiopts
.smart_auto_save_enable
= false;
453 ataopts
.smart_check_status
= scsiopts
.smart_check_status
= nvmeopts
.smart_check_status
= true;
454 scsiopts
.smart_ss_media_log
= true;
457 if (!strcmp(optarg
, "swapid"))
458 ataopts
.fix_swapped_id
= true;
459 else if (!parse_firmwarebug_def(optarg
, ataopts
.firmwarebugs
))
463 ataopts
.smart_general_values
= nvmeopts
.drive_capabilities
= true;
466 ataopts
.smart_vendor_attrib
= scsiopts
.smart_vendor_attrib
= nvmeopts
.smart_vendor_attrib
= true;
469 if (str_starts_with(optarg
, "error")) {
470 int n1
= -1, n2
= -1, len
= strlen(optarg
);
472 sscanf(optarg
, "error%n,%u%n", &n1
, &val
, &n2
);
473 ataopts
.smart_error_log
= scsiopts
.smart_error_log
= true;
475 nvmeopts
.error_log_entries
= 16;
476 else if (n2
== len
&& val
> 0)
477 nvmeopts
.error_log_entries
= val
;
480 } else if (!strcmp(optarg
,"selftest")) {
481 ataopts
.smart_selftest_log
= scsiopts
.smart_selftest_log
= true;
482 } else if (!strcmp(optarg
, "selective")) {
483 ataopts
.smart_selective_selftest_log
= true;
484 } else if (!strcmp(optarg
,"directory")) {
485 ataopts
.smart_logdir
= ataopts
.gp_logdir
= true; // SMART+GPL
486 } else if (!strcmp(optarg
,"directory,s")) {
487 ataopts
.smart_logdir
= true; // SMART
488 } else if (!strcmp(optarg
,"directory,g")) {
489 ataopts
.gp_logdir
= true; // GPL
490 } else if (!strcmp(optarg
,"sasphy")) {
491 scsiopts
.sasphy
= true;
492 } else if (!strcmp(optarg
,"sasphy,reset")) {
493 scsiopts
.sasphy
= scsiopts
.sasphy_reset
= true;
494 } else if (!strcmp(optarg
,"sataphy")) {
495 ataopts
.sataphy
= true;
496 } else if (!strcmp(optarg
,"sataphy,reset")) {
497 ataopts
.sataphy
= ataopts
.sataphy_reset
= true;
498 } else if (!strcmp(optarg
,"background")) {
499 scsiopts
.smart_background_log
= true;
500 } else if (!strcmp(optarg
,"ssd")) {
501 ataopts
.devstat_ssd_page
= true;
502 scsiopts
.smart_ss_media_log
= true;
503 } else if (!strcmp(optarg
,"scterc")) {
504 ataopts
.sct_erc_get
= true;
505 } else if (!strcmp(optarg
,"scttemp")) {
506 ataopts
.sct_temp_sts
= ataopts
.sct_temp_hist
= true;
507 } else if (!strcmp(optarg
,"scttempsts")) {
508 ataopts
.sct_temp_sts
= true;
509 } else if (!strcmp(optarg
,"scttemphist")) {
510 ataopts
.sct_temp_hist
= true;
512 } else if (!strncmp(optarg
, "scttempint,", sizeof("scstempint,")-1)) {
513 unsigned interval
= 0; int n1
= -1, n2
= -1, len
= strlen(optarg
);
514 if (!( sscanf(optarg
,"scttempint,%u%n,p%n", &interval
, &n1
, &n2
) == 1
515 && 0 < interval
&& interval
<= 0xffff && (n1
== len
|| n2
== len
))) {
516 snprintf(extraerror
, sizeof(extraerror
), "Option -l scttempint,N[,p] must have positive integer N\n");
519 ataopts
.sct_temp_int
= interval
;
520 ataopts
.sct_temp_int_pers
= (n2
== len
);
522 } else if (!strncmp(optarg
, "devstat", sizeof("devstat")-1)) {
523 int n1
= -1, n2
= -1, len
= strlen(optarg
);
525 sscanf(optarg
, "devstat%n,%u%n", &n1
, &val
, &n2
);
527 ataopts
.devstat_all_pages
= true;
529 if (n2
!= len
) // retry with hex
530 sscanf(optarg
, "devstat,0x%x%n", &val
, &n2
);
531 if (n2
== len
&& val
<= 0xff)
532 ataopts
.devstat_pages
.push_back(val
);
537 } else if (!strncmp(optarg
, "xerror", sizeof("xerror")-1)) {
538 int n1
= -1, n2
= -1, len
= strlen(optarg
);
540 sscanf(optarg
, "xerror%n,error%n", &n1
, &n2
);
541 if (!(n1
== len
|| n2
== len
)) {
543 sscanf(optarg
, "xerror,%u%n,error%n", &val
, &n1
, &n2
);
545 if ((n1
== len
|| n2
== len
) && val
> 0) {
546 ataopts
.smart_ext_error_log
= val
;
547 ataopts
.retry_error_log
= (n2
== len
);
552 } else if (!strncmp(optarg
, "xselftest", sizeof("xselftest")-1)) {
553 int n1
= -1, n2
= -1, len
= strlen(optarg
);
555 sscanf(optarg
, "xselftest%n,selftest%n", &n1
, &n2
);
556 if (!(n1
== len
|| n2
== len
)) {
558 sscanf(optarg
, "xselftest,%u%n,selftest%n", &val
, &n1
, &n2
);
560 if ((n1
== len
|| n2
== len
) && val
> 0) {
561 ataopts
.smart_ext_selftest_log
= val
;
562 ataopts
.retry_selftest_log
= (n2
== len
);
567 } else if (!strncmp(optarg
, "scterc,", sizeof("scterc,")-1)) {
568 unsigned rt
= ~0, wt
= ~0; int n
= -1;
569 sscanf(optarg
,"scterc,%u,%u%n", &rt
, &wt
, &n
);
570 if (n
== (int)strlen(optarg
) && rt
<= 999 && wt
<= 999) {
571 ataopts
.sct_erc_set
= true;
572 ataopts
.sct_erc_readtime
= rt
;
573 ataopts
.sct_erc_writetime
= wt
;
576 snprintf(extraerror
, sizeof(extraerror
), "Option -l scterc,[READTIME,WRITETIME] syntax error\n");
579 } else if ( !strncmp(optarg
, "gplog," , sizeof("gplog," )-1)
580 || !strncmp(optarg
, "smartlog,", sizeof("smartlog,")-1)) {
581 unsigned logaddr
= ~0U; unsigned page
= 0, nsectors
= 1; char sign
= 0;
582 int n1
= -1, n2
= -1, n3
= -1, len
= strlen(optarg
);
583 sscanf(optarg
, "%*[a-z],0x%x%n,%u%n%c%u%n",
584 &logaddr
, &n1
, &page
, &n2
, &sign
, &nsectors
, &n3
);
585 if (len
> n2
&& n3
== -1 && !strcmp(optarg
+n2
, "-max")) {
586 nsectors
= ~0U; sign
= '+'; n3
= len
;
588 bool gpl
= (optarg
[0] == 'g');
589 const char * erropt
= (gpl
? "gplog" : "smartlog");
590 if (!( n1
== len
|| n2
== len
591 || (n3
== len
&& (sign
== '+' || sign
== '-')))) {
592 snprintf(extraerror
, sizeof(extraerror
), "Option -l %s,ADDR[,FIRST[-LAST|+SIZE]] syntax error\n", erropt
);
595 else if (!( logaddr
<= 0xff && page
<= (gpl
? 0xffffU
: 0x00ffU
)
597 && (nsectors
<= (gpl
? 0xffffU
: 0xffU
) || nsectors
== ~0U)
598 && (sign
!= '-' || page
<= nsectors
) )) {
599 snprintf(extraerror
, sizeof(extraerror
), "Option -l %s,ADDR[,FIRST[-LAST|+SIZE]] parameter out of range\n", erropt
);
604 req
.gpl
= gpl
; req
.logaddr
= logaddr
; req
.page
= page
;
605 req
.nsectors
= (sign
== '-' ? nsectors
-page
+1 : nsectors
);
606 ataopts
.log_requests
.push_back(req
);
610 else if (str_starts_with(optarg
, "nvmelog,")) {
611 int n
= -1, len
= strlen(optarg
);
612 unsigned page
= 0, size
= 0;
613 sscanf(optarg
, "nvmelog,0x%x,0x%x%n", &page
, &size
, &n
);
614 if (n
== len
&& page
<= 0xff && 0 < size
&& size
<= 0x4000) {
615 nvmeopts
.log_page
= page
; nvmeopts
.log_page_size
= size
;
626 ataopts
.drive_info
= scsiopts
.drive_info
= nvmeopts
.drive_info
= true;
630 ataopts
.identify_word_level
= ataopts
.identify_bit_level
= 0;
632 for (int i
= 0; optarg
[i
]; i
++) {
634 case 'w': ataopts
.identify_word_level
= 1; break;
635 case 'n': ataopts
.identify_bit_level
= -1; break;
636 case 'v': ataopts
.identify_bit_level
= 1; break;
637 case 'b': ataopts
.identify_bit_level
= 2; break;
638 default: badarg
= true;
645 ataopts
.drive_info
= scsiopts
.drive_info
= nvmeopts
.drive_info
= true;
646 ataopts
.smart_check_status
= scsiopts
.smart_check_status
= nvmeopts
.smart_check_status
= true;
647 ataopts
.smart_general_values
= nvmeopts
.drive_capabilities
= true;
648 ataopts
.smart_vendor_attrib
= scsiopts
.smart_vendor_attrib
= nvmeopts
.smart_vendor_attrib
= true;
649 ataopts
.smart_error_log
= scsiopts
.smart_error_log
= true;
650 nvmeopts
.error_log_entries
= 16;
651 ataopts
.smart_selftest_log
= scsiopts
.smart_selftest_log
= true;
652 ataopts
.smart_selective_selftest_log
= true;
653 /* scsiopts.smart_background_log = true; */
654 scsiopts
.smart_ss_media_log
= true;
657 ataopts
.drive_info
= scsiopts
.drive_info
= nvmeopts
.drive_info
= true;
658 ataopts
.smart_check_status
= scsiopts
.smart_check_status
= nvmeopts
.smart_check_status
= true;
659 ataopts
.smart_general_values
= nvmeopts
.drive_capabilities
= true;
660 ataopts
.smart_vendor_attrib
= scsiopts
.smart_vendor_attrib
= nvmeopts
.smart_vendor_attrib
= true;
661 ataopts
.smart_ext_error_log
= 8;
662 ataopts
.retry_error_log
= true;
663 nvmeopts
.error_log_entries
= 16;
664 ataopts
.smart_ext_selftest_log
= 25;
665 ataopts
.retry_selftest_log
= true;
666 scsiopts
.smart_error_log
= scsiopts
.smart_selftest_log
= true;
667 ataopts
.smart_selective_selftest_log
= true;
668 ataopts
.smart_logdir
= ataopts
.gp_logdir
= true;
669 ataopts
.sct_temp_sts
= ataopts
.sct_temp_hist
= true;
670 ataopts
.sct_erc_get
= true;
671 ataopts
.sct_wcache_reorder_get
= true;
672 ataopts
.devstat_all_pages
= true;
673 ataopts
.sataphy
= true;
674 ataopts
.get_set_used
= true;
675 ataopts
.get_aam
= ataopts
.get_apm
= true;
676 ataopts
.get_security
= true;
677 ataopts
.get_lookahead
= ataopts
.get_wcache
= true;
678 scsiopts
.get_rcd
= scsiopts
.get_wce
= true;
679 scsiopts
.smart_background_log
= true;
680 scsiopts
.smart_ss_media_log
= true;
681 scsiopts
.sasphy
= true;
682 if (!output_format_set
)
683 ataopts
.output_format
|= ata_print_options::FMT_BRIEF
;
686 // parse vendor-specific definitions of attributes
687 if (!strcmp(optarg
,"help")) {
688 printing_is_off
= false;
690 pout("The valid arguments to -v are:\n\thelp\n%s\n",
691 create_vendor_attribute_arg_list().c_str());
694 if (!parse_attribute_def(optarg
, ataopts
.attribute_defs
, PRIOR_USER
))
698 if (!strcmp(optarg
, "use")) {
699 ataopts
.ignore_presets
= false;
700 } else if (!strcmp(optarg
, "ignore")) {
701 ataopts
.ignore_presets
= true;
702 } else if (!strcmp(optarg
, "show")) {
703 ataopts
.show_presets
= true;
704 } else if (!strcmp(optarg
, "showall")) {
705 if (!init_drive_database(use_default_db
))
707 if (optind
< argc
) { // -P showall MODEL [FIRMWARE]
708 int cnt
= showmatchingpresets(argv
[optind
], (optind
+1<argc
? argv
[optind
+1] : NULL
));
709 EXIT(cnt
); // report #matches
711 if (showallpresets())
712 EXIT(FAILCMD
); // report regexp syntax error
719 if (!strcmp(optarg
,"offline")) {
721 ataopts
.smart_selftest_type
= OFFLINE_FULL_SCAN
;
722 scsiopts
.smart_default_selftest
= true;
723 } else if (!strcmp(optarg
,"short")) {
725 ataopts
.smart_selftest_type
= SHORT_SELF_TEST
;
726 scsiopts
.smart_short_selftest
= true;
727 } else if (!strcmp(optarg
,"long")) {
729 ataopts
.smart_selftest_type
= EXTEND_SELF_TEST
;
730 scsiopts
.smart_extend_selftest
= true;
731 } else if (!strcmp(optarg
,"conveyance")) {
733 ataopts
.smart_selftest_type
= CONVEYANCE_SELF_TEST
;
734 } else if (!strcmp(optarg
,"force")) {
735 ataopts
.smart_selftest_force
= true;
736 scsiopts
.smart_selftest_force
= true;
737 } else if (!strcmp(optarg
,"afterselect,on")) {
738 // scan remainder of disk after doing selected segment
739 ataopts
.smart_selective_args
.scan_after_select
= 2;
740 } else if (!strcmp(optarg
,"afterselect,off")) {
741 // don't scan remainder of disk after doing selected segments
742 ataopts
.smart_selective_args
.scan_after_select
= 1;
743 } else if (!strncmp(optarg
,"pending,",strlen("pending,"))) {
744 // parse number of minutes that test should be pending
748 i
=(int)strtol(optarg
+strlen("pending,"), &tailptr
, 10);
749 if (errno
|| *tailptr
!= '\0') {
750 snprintf(extraerror
, sizeof(extraerror
), "Option -t pending,N requires N to be a non-negative integer\n");
752 } else if (i
<0 || i
>65535) {
753 snprintf(extraerror
, sizeof(extraerror
), "Option -t pending,N (N=%d) must have 0 <= N <= 65535\n", i
);
756 ataopts
.smart_selective_args
.pending_time
= i
+1;
758 } else if (!strncmp(optarg
,"select",strlen("select"))) {
759 if (ataopts
.smart_selective_args
.num_spans
== 0)
761 // parse range of LBAs to test
762 uint64_t start
, stop
; int mode
;
763 if (split_selective_arg(optarg
, &start
, &stop
, &mode
)) {
764 snprintf(extraerror
, sizeof(extraerror
), "Option -t select,M-N must have non-negative integer M and N\n");
767 if (ataopts
.smart_selective_args
.num_spans
>= 5 || start
> stop
) {
769 snprintf(extraerror
, sizeof(extraerror
), "ERROR: Start LBA (%" PRIu64
") > ending LBA (%" PRId64
") in argument \"%s\"\n",
770 start
, stop
, optarg
);
772 snprintf(extraerror
, sizeof(extraerror
),"ERROR: No more than five selective self-test spans may be"
777 ataopts
.smart_selective_args
.span
[ataopts
.smart_selective_args
.num_spans
].start
= start
;
778 ataopts
.smart_selective_args
.span
[ataopts
.smart_selective_args
.num_spans
].end
= stop
;
779 ataopts
.smart_selective_args
.span
[ataopts
.smart_selective_args
.num_spans
].mode
= mode
;
780 ataopts
.smart_selective_args
.num_spans
++;
781 ataopts
.smart_selftest_type
= SELECTIVE_SELF_TEST
;
783 } else if (!strncmp(optarg
, "scttempint", sizeof("scstempint")-1)) {
784 snprintf(extraerror
, sizeof(extraerror
), "-t scttempint is no longer supported, use -l scttempint instead\n");
786 } else if (!strncmp(optarg
, "vendor,", sizeof("vendor,")-1)) {
787 unsigned subcmd
= ~0U; int n
= -1;
788 if (!( sscanf(optarg
, "%*[a-z],0x%x%n", &subcmd
, &n
) == 1
789 && subcmd
<= 0xff && n
== (int)strlen(optarg
))) {
790 snprintf(extraerror
, sizeof(extraerror
), "Option -t vendor,0xNN syntax error\n");
794 ataopts
.smart_selftest_type
= subcmd
;
804 scsiopts
.smart_selftest_abort
= true;
805 ataopts
.smart_selftest_type
= ABORT_SELF_TEST
;
808 // skip disk check if in low-power mode
809 if (!strcmp(optarg
, "never"))
810 ataopts
.powermode
= 1; // do not skip, but print mode
811 else if (!strcmp(optarg
, "sleep"))
812 ataopts
.powermode
= 2;
813 else if (!strcmp(optarg
, "standby"))
814 ataopts
.powermode
= 3;
815 else if (!strcmp(optarg
, "idle"))
816 ataopts
.powermode
= 4;
821 if (!strcmp(optarg
, "old")) {
822 ataopts
.output_format
&= ~ata_print_options::FMT_BRIEF
;
823 output_format_set
= true;
825 else if (!strcmp(optarg
, "brief")) {
826 ataopts
.output_format
|= ata_print_options::FMT_BRIEF
;
827 output_format_set
= true;
829 else if (!strcmp(optarg
, "hex"))
830 ataopts
.output_format
|= ata_print_options::FMT_HEX_ID
831 | ata_print_options::FMT_HEX_VAL
;
832 else if (!strcmp(optarg
, "hex,id"))
833 ataopts
.output_format
|= ata_print_options::FMT_HEX_ID
;
834 else if (!strcmp(optarg
, "hex,val"))
835 ataopts
.output_format
|= ata_print_options::FMT_HEX_VAL
;
841 const char * path
= optarg
;
842 if (*path
== '+' && path
[1])
845 use_default_db
= false;
846 if (!read_drive_database(path
))
851 printing_is_off
= false;
858 case_s_continued
: // -s, see above
859 case opt_set
: // --set
861 ataopts
.get_set_used
= true;
862 bool get
= (optchar
== 'g');
863 char name
[16+1]; unsigned val
;
864 int n1
= -1, n2
= -1, n3
= -1, len
= strlen(optarg
);
865 if (sscanf(optarg
, "%16[^,=]%n%*[,=]%n%u%n", name
, &n1
, &n2
, &val
, &n3
) >= 1
866 && (n1
== len
|| (!get
&& n2
> 0))) {
867 bool on
= (n2
> 0 && !strcmp(optarg
+n2
, "on"));
868 bool off
= (n2
> 0 && !strcmp(optarg
+n2
, "off"));
872 if (get
&& !strcmp(name
, "all")) {
873 ataopts
.get_aam
= ataopts
.get_apm
= true;
874 ataopts
.get_security
= true;
875 ataopts
.get_lookahead
= ataopts
.get_wcache
= true;
876 scsiopts
.get_rcd
= scsiopts
.get_wce
= true;
878 else if (!strcmp(name
, "aam")) {
880 ataopts
.get_aam
= true;
882 ataopts
.set_aam
= -1;
884 ataopts
.set_aam
= val
+ 1;
886 snprintf(extraerror
, sizeof(extraerror
), "Option -s aam,N must have 0 <= N <= 254\n");
890 else if (!strcmp(name
, "apm")) {
892 ataopts
.get_apm
= true;
894 ataopts
.set_apm
= -1;
895 else if (1 <= val
&& val
<= 254)
896 ataopts
.set_apm
= val
+ 1;
898 snprintf(extraerror
, sizeof(extraerror
), "Option -s apm,N must have 1 <= N <= 254\n");
902 else if (!strcmp(name
, "lookahead")) {
904 ataopts
.get_lookahead
= true;
907 ataopts
.set_lookahead
= -1;
909 ataopts
.set_lookahead
= 1;
913 else if (!strcmp(name
, "wcreorder")) {
915 ataopts
.sct_wcache_reorder_get
= true;
918 ataopts
.sct_wcache_reorder_set
= -1;
920 ataopts
.sct_wcache_reorder_set
= 1;
924 else if (!strcmp(name
, "rcache")) {
926 scsiopts
.get_rcd
= true;
928 scsiopts
.set_rcd
= -1;
930 scsiopts
.set_rcd
= 1;
934 else if (get
&& !strcmp(name
, "security")) {
935 ataopts
.get_security
= true;
937 else if (!get
&& !strcmp(optarg
, "security-freeze")) {
938 ataopts
.set_security_freeze
= true;
940 else if (!get
&& !strcmp(optarg
, "standby,now")) {
941 ataopts
.set_standby_now
= true;
943 else if (!get
&& !strcmp(name
, "standby")) {
945 ataopts
.set_standby
= 0 + 1;
947 ataopts
.set_standby
= val
+ 1;
949 snprintf(extraerror
, sizeof(extraerror
), "Option -s standby,N must have 0 <= N <= 255\n");
953 else if (!strcmp(name
, "wcache")) {
955 ataopts
.get_wcache
= true;
956 scsiopts
.get_wce
= true;
959 ataopts
.set_wcache
= -1;
960 scsiopts
.set_wce
= -1;
963 ataopts
.set_wcache
= 1;
964 scsiopts
.set_wce
= 1;
984 printing_is_off
= false;
986 // Point arg to the argument in which this option was found.
987 arg
= argv
[optind
-1];
988 // Check whether the option is a long option that doesn't map to -h.
989 if (arg
[1] == '-' && optchar
!= 'h') {
990 // Iff optopt holds a valid option then argument must be missing.
991 if (optopt
&& (optopt
>= opt_scan
|| strchr(shortopts
, optopt
))) {
992 pout("=======> ARGUMENT REQUIRED FOR OPTION: %s\n", arg
+2);
993 printvalidarglistmessage(optopt
);
995 pout("=======> UNRECOGNIZED OPTION: %s\n",arg
+2);
997 pout("=======> %s", extraerror
);
1001 if (0 < optopt
&& optopt
< '~') {
1002 // Iff optopt holds a valid option then argument must be
1003 // missing. Note (BA) this logic seems to fail using Solaris
1005 if (strchr(shortopts
, optopt
) != NULL
) {
1006 pout("=======> ARGUMENT REQUIRED FOR OPTION: %c\n", optopt
);
1007 printvalidarglistmessage(optopt
);
1009 pout("=======> UNRECOGNIZED OPTION: %c\n",optopt
);
1011 pout("=======> %s", extraerror
);
1017 } // closes switch statement to process command-line options
1019 // Check to see if option had an unrecognized or incorrect argument.
1022 // It would be nice to print the actual option name given by the user
1023 // here, but we just print the short form. Please fix this if you know
1024 // a clean way to do it.
1025 char optstr
[] = { (char)optchar
, 0 };
1026 pout("=======> INVALID ARGUMENT TO -%s: %s\n",
1027 (optchar
== opt_identify
? "-identify" :
1028 optchar
== opt_set
? "-set" :
1029 optchar
== opt_smart
? "-smart" : optstr
), optarg
);
1030 printvalidarglistmessage(optchar
);
1032 pout("=======> %s", extraerror
);
1038 // Special handling of --scan, --scanopen
1040 // Read or init drive database to allow USB ID check.
1041 if (!init_drive_database(use_default_db
))
1043 scan_devices(scan_types
, (scan
== opt_scan_open
), argv
+ optind
);
1047 // At this point we have processed all command-line options. If the
1048 // print output is switchable, then start with the print output
1050 if (printing_is_switchable
)
1051 printing_is_off
= true;
1053 // Check for multiple -d TYPE options
1054 if (scan_types
.size() > 1) {
1055 printing_is_off
= false;
1057 pout("ERROR: multiple -d TYPE options are only allowed with --scan\n");
1062 // error message if user has asked for more than one test
1064 printing_is_off
= false;
1066 pout("\nERROR: smartctl can only run a single test type (or abort) at a time.\n");
1071 // error message if user has set selective self-test options without
1072 // asking for a selective self-test
1073 if ( (ataopts
.smart_selective_args
.pending_time
|| ataopts
.smart_selective_args
.scan_after_select
)
1074 && !ataopts
.smart_selective_args
.num_spans
) {
1075 printing_is_off
= false;
1077 if (ataopts
.smart_selective_args
.pending_time
)
1078 pout("\nERROR: smartctl -t pending,N must be used with -t select,N-M.\n");
1080 pout("\nERROR: smartctl -t afterselect,(on|off) must be used with -t select,N-M.\n");
1085 // If captive option was used, change test type if appropriate.
1087 switch (ataopts
.smart_selftest_type
) {
1088 case SHORT_SELF_TEST
:
1089 ataopts
.smart_selftest_type
= SHORT_CAPTIVE_SELF_TEST
;
1090 scsiopts
.smart_short_selftest
= false;
1091 scsiopts
.smart_short_cap_selftest
= true;
1093 case EXTEND_SELF_TEST
:
1094 ataopts
.smart_selftest_type
= EXTEND_CAPTIVE_SELF_TEST
;
1095 scsiopts
.smart_extend_selftest
= false;
1096 scsiopts
.smart_extend_cap_selftest
= true;
1098 case CONVEYANCE_SELF_TEST
:
1099 ataopts
.smart_selftest_type
= CONVEYANCE_CAPTIVE_SELF_TEST
;
1101 case SELECTIVE_SELF_TEST
:
1102 ataopts
.smart_selftest_type
= SELECTIVE_CAPTIVE_SELF_TEST
;
1106 // From here on, normal operations...
1109 // Warn if the user has provided no device name
1111 pout("ERROR: smartctl requires a device name as the final command-line argument.\n\n");
1116 // Warn if the user has provided more than one device name
1119 pout("ERROR: smartctl takes ONE device name as the final command-line argument.\n");
1120 pout("You have provided %d device names:\n",argc
-optind
);
1121 for (i
=0; i
<argc
-optind
; i
++)
1122 pout("%s\n",argv
[optind
+i
]);
1127 // Read or init drive database
1128 if (!init_drive_database(use_default_db
))
1134 // Printing function (controlled by global printing_is_off)
1135 // [From GLIBC Manual: Since the prototype doesn't specify types for
1136 // optional arguments, in a call to a variadic function the default
1137 // argument promotions are performed on the optional argument
1138 // values. This means the objects of type char or short int (whether
1139 // signed or not) are promoted to either int or unsigned int, as
1141 void pout(const char *fmt
, ...){
1144 // initialize variable argument list
1146 if (printing_is_off
) {
1158 // Globals to set failuretest() policy
1159 bool failuretest_conservative
= false;
1160 unsigned char failuretest_permissive
= 0;
1162 // Compares failure type to policy in effect, and either exits or
1163 // simply returns to the calling routine.
1164 // Used in ataprint.cpp and scsiprint.cpp.
1165 void failuretest(failure_type type
, int returnvalue
)
1167 // If this is an error in an "optional" SMART command
1168 if (type
== OPTIONAL_CMD
) {
1169 if (!failuretest_conservative
)
1171 pout("An optional SMART command failed: exiting. Remove '-T conservative' option to continue.\n");
1175 // If this is an error in a "mandatory" SMART command
1176 if (type
== MANDATORY_CMD
) {
1177 if (failuretest_permissive
--)
1179 pout("A mandatory SMART command failed: exiting. To continue, add one or more '-T permissive' options.\n");
1183 throw std::logic_error("failuretest: Unknown type");
1186 // Used to warn users about invalid checksums. Called from atacmds.cpp.
1187 // Action to be taken may be altered by the user.
1188 void checksumwarning(const char * string
)
1190 // user has asked us to ignore checksum errors
1191 if (checksum_err_mode
== CHECKSUM_ERR_IGNORE
)
1194 pout("Warning! %s error: invalid SMART checksum.\n", string
);
1196 // user has asked us to fail on checksum errors
1197 if (checksum_err_mode
== CHECKSUM_ERR_EXIT
)
1201 // Return info string about device protocol
1202 static const char * get_protocol_info(const smart_device
* dev
)
1204 switch ( (int)dev
->is_ata()
1205 | ((int)dev
->is_scsi() << 1)
1206 | ((int)dev
->is_nvme() << 2)) {
1207 case 0x1: return "ATA";
1208 case 0x2: return "SCSI";
1209 case 0x3: return "ATA+SCSI";
1210 case 0x4: return "NVMe";
1211 default: return "Unknown";
1216 // smartctl [-d type] --scan[-open] -- [PATTERN] [smartd directive ...]
1217 void scan_devices(const smart_devtype_list
& types
, bool with_open
, char ** argv
)
1219 bool dont_print
= !(ata_debugmode
|| scsi_debugmode
|| nvme_debugmode
);
1221 const char * pattern
= 0;
1223 if (argv
[ai
] && argv
[ai
][0] != '-')
1224 pattern
= argv
[ai
++];
1226 smart_device_list devlist
;
1227 printing_is_off
= dont_print
;
1228 bool ok
= smi()->scan_smart_devices(devlist
, types
, pattern
);
1229 printing_is_off
= false;
1232 pout("# scan_smart_devices: %s\n", smi()->get_errmsg());
1236 for (unsigned i
= 0; i
< devlist
.size(); i
++) {
1237 smart_device_auto_ptr
dev( devlist
.release(i
) );
1240 printing_is_off
= dont_print
;
1241 dev
.replace ( dev
->autodetect_open() );
1242 printing_is_off
= false;
1244 if (!dev
->is_open()) {
1245 pout("# %s -d %s # %s, %s device open failed: %s\n", dev
->get_dev_name(),
1246 dev
->get_dev_type(), dev
->get_info_name(),
1247 get_protocol_info(dev
.get()), dev
->get_errmsg());
1252 pout("%s -d %s", dev
->get_dev_name(), dev
->get_dev_type());
1254 pout(" # %s, %s device\n", dev
->get_info_name(), get_protocol_info(dev
.get()));
1256 for (int j
= ai
; argv
[j
]; j
++)
1257 pout(" %s", argv
[j
]);
1266 // Main program without exception handling
1267 static int main_worker(int argc
, char **argv
)
1269 // Throw if runtime environment does not match compile time test.
1272 // Initialize interface
1273 smart_interface::init();
1277 // Parse input arguments
1278 ata_print_options ataopts
;
1279 scsi_print_options scsiopts
;
1280 nvme_print_options nvmeopts
;
1281 bool print_type_only
= false;
1282 const char * type
= parse_options(argc
, argv
, ataopts
, scsiopts
, nvmeopts
, print_type_only
);
1284 const char * name
= argv
[argc
-1];
1286 smart_device_auto_ptr dev
;
1287 if (!strcmp(name
,"-")) {
1288 // Parse "smartctl -r ataioctl,2 ..." output from stdin
1289 if (type
|| print_type_only
) {
1290 pout("-d option is not allowed in conjunction with device name \"-\".\n");
1294 dev
= get_parsed_ata_device(smi(), name
);
1297 // get device of appropriate type
1298 dev
= smi()->get_smart_device(name
, type
);
1301 pout("%s: %s\n", name
, smi()->get_errmsg());
1303 printvalidarglistmessage('d');
1305 pout("Please specify device type with the -d option.\n");
1310 if (print_type_only
)
1311 // Report result of first autodetection
1312 pout("%s: Device of type '%s' [%s] detected\n",
1313 dev
->get_info_name(), dev
->get_dev_type(), get_protocol_info(dev
.get()));
1315 if (dev
->is_ata() && ataopts
.powermode
>=2 && dev
->is_powered_down()) {
1316 pout( "%s: Device is in %s mode, exit(%d)\n", dev
->get_info_name(), "STANDBY (OS)", FAILPOWER
);
1323 smart_device::device_info oldinfo
= dev
->get_info();
1325 // Open with autodetect support, may return 'better' device
1326 dev
.replace( dev
->autodetect_open() );
1328 // Report if type has changed
1329 if ( (ata_debugmode
|| scsi_debugmode
|| nvme_debugmode
|| print_type_only
)
1330 && oldinfo
.dev_type
!= dev
->get_dev_type() )
1331 pout("%s: Device open changed type from '%s' to '%s'\n",
1332 dev
->get_info_name(), oldinfo
.dev_type
.c_str(), dev
->get_dev_type());
1334 if (!dev
->is_open()) {
1335 pout("Smartctl open device: %s failed: %s\n", dev
->get_info_name(), dev
->get_errmsg());
1339 // now call appropriate ATA or SCSI routine
1341 if (print_type_only
)
1342 pout("%s: Device of type '%s' [%s] opened\n",
1343 dev
->get_info_name(), dev
->get_dev_type(), get_protocol_info(dev
.get()));
1344 else if (dev
->is_ata())
1345 retval
= ataPrintMain(dev
->to_ata(), ataopts
);
1346 else if (dev
->is_scsi())
1347 retval
= scsiPrintMain(dev
->to_scsi(), scsiopts
);
1348 else if (dev
->is_nvme())
1349 retval
= nvmePrintMain(dev
->to_nvme(), nvmeopts
);
1351 // we should never fall into this branch!
1352 pout("%s: Neither ATA, SCSI nor NVMe device\n", dev
->get_info_name());
1360 int main(int argc
, char **argv
)
1363 bool badcode
= false;
1366 // Do the real work ...
1367 status
= main_worker(argc
, argv
);
1370 // EXIT(status) arrives here
1373 catch (const std::bad_alloc
& /*ex*/) {
1374 // Memory allocation failed (also thrown by std::operator new)
1375 printf("Smartctl: Out of memory\n");
1378 catch (const std::exception
& ex
) {
1379 // Other fatal errors
1380 printf("Smartctl: Exception: %s\n", ex
.what());
1385 // Check for remaining device objects
1386 if (smart_device::get_num_objects() != 0) {
1387 printf("Smartctl: Internal Error: %d device object(s) left at exit.\n",
1388 smart_device::get_num_objects());
1394 printf("Please inform " PACKAGE_BUGREPORT
", including output of smartctl -V.\n");