4 * Home page of code is: http://www.smartmontools.org
6 * Copyright (C) 2002-11 Bruce Allen
7 * Copyright (C) 2008-16 Christian Franke
8 * Copyright (C) 2000 Michael Cornwell <cornwell@acm.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option)
15 * You should have received a copy of the GNU General Public License
16 * (for example COPYING); If not, see <http://www.gnu.org/licenses/>.
18 * This code was originally developed as a Senior Thesis by Michael Cornwell
19 * at the Concurrent Systems Laboratory (now part of the Storage Systems
20 * Research Center), Jack Baskin School of Engineering, University of
21 * California, Santa Cruz. http://ssrc.soe.ucsc.edu/
27 #include <sys/types.h>
40 #if defined(__FreeBSD__)
41 #include <sys/param.h>
46 #include "dev_interface.h"
48 #include "knowndrives.h"
50 #include "scsiprint.h"
51 #include "nvmeprint.h"
55 const char * smartctl_cpp_cvsid
= "$Id: smartctl.cpp 4311 2016-04-27 21:03:01Z chrfranke $"
56 CONFIG_H_CVSID SMARTCTL_H_CVSID
;
58 // Globals to control printing
59 bool printing_is_switchable
= false;
60 bool printing_is_off
= false;
62 static void printslogan()
64 pout("%s\n", format_version_info("smartctl").c_str());
67 static void UsageSummary()
69 pout("\nUse smartctl -h to get a usage summary\n\n");
73 static std::string
getvalidarglist(int opt
);
75 /* void prints help information for command syntax */
78 printf("Usage: smartctl [options] device\n\n");
80 "============================================ SHOW INFORMATION OPTIONS =====\n\n"
81 " -h, --help, --usage\n"
82 " Display this help and exit\n\n"
83 " -V, --version, --copyright, --license\n"
84 " Print license, copyright, and version information and exit\n\n"
86 " Show identity information for device\n\n"
87 " --identify[=[w][nvb]]\n"
88 " Show words and bits from IDENTIFY DEVICE data (ATA)\n\n"
89 " -g NAME, --get=NAME\n"
90 " Get device setting: all, aam, apm, lookahead, security, wcache, rcache, wcreorder\n\n"
92 " Show all SMART information for device\n\n"
94 " Show all information for device\n\n"
96 " Scan for devices\n\n"
98 " Scan for devices and try to open each device\n\n"
101 "================================== SMARTCTL RUN-TIME BEHAVIOR OPTIONS =====\n\n"
102 " -q TYPE, --quietmode=TYPE (ATA)\n"
103 " Set smartctl quiet mode to one of: errorsonly, silent, noserial\n\n"
104 " -d TYPE, --device=TYPE\n"
105 " Specify device type to one of: %s\n\n"
106 " -T TYPE, --tolerance=TYPE (ATA)\n"
107 " Tolerance: normal, conservative, permissive, verypermissive\n\n"
108 " -b TYPE, --badsum=TYPE (ATA)\n"
109 " Set action on bad checksum to one of: warn, exit, ignore\n\n"
110 " -r TYPE, --report=TYPE\n"
111 " Report transactions (see man page)\n\n"
112 " -n MODE, --nocheck=MODE (ATA)\n"
113 " No check if: never, sleep, standby, idle (see man page)\n\n",
114 getvalidarglist('d').c_str()); // TODO: Use this function also for other options ?
116 "============================== DEVICE FEATURE ENABLE/DISABLE COMMANDS =====\n\n"
117 " -s VALUE, --smart=VALUE\n"
118 " Enable/disable SMART on device (on/off)\n\n"
119 " -o VALUE, --offlineauto=VALUE (ATA)\n"
120 " Enable/disable automatic offline testing on device (on/off)\n\n"
121 " -S VALUE, --saveauto=VALUE (ATA)\n"
122 " Enable/disable Attribute autosave on device (on/off)\n\n"
123 " -s NAME[,VALUE], --set=NAME[,VALUE]\n"
124 " Enable/disable/change device setting: aam,[N|off], apm,[N|off],\n"
125 " lookahead,[on|off], security-freeze, standby,[N|off|now],\n"
126 " wcache,[on|off], rcache,[on|off], wcreorder,[on|off]\n\n"
129 "======================================= READ AND DISPLAY DATA OPTIONS =====\n\n"
131 " Show device SMART health status\n\n"
132 " -c, --capabilities (ATA, NVMe)\n"
133 " Show device SMART capabilities\n\n"
134 " -A, --attributes\n"
135 " Show device SMART vendor-specific Attributes and values\n\n"
136 " -f FORMAT, --format=FORMAT (ATA)\n"
137 " Set output format for attributes: old, brief, hex[,id|val]\n\n"
138 " -l TYPE, --log=TYPE\n"
139 " Show device log. TYPE: error, selftest, selective, directory[,g|s],\n"
140 " xerror[,N][,error], xselftest[,N][,selftest],\n"
141 " background, sasphy[,reset], sataphy[,reset],\n"
142 " scttemp[sts,hist], scttempint,N[,p],\n"
143 " scterc[,N,M], devstat[,N], ssd,\n"
144 " gplog,N[,RANGE], smartlog,N[,RANGE],\n"
145 " nvmelog,N,SIZE\n\n"
146 " -v N,OPTION , --vendorattribute=N,OPTION (ATA)\n"
147 " Set display OPTION for vendor Attribute N (see man page)\n\n"
148 " -F TYPE, --firmwarebug=TYPE (ATA)\n"
149 " Use firmware bug workaround:\n"
151 " -P TYPE, --presets=TYPE (ATA)\n"
152 " Drive-specific presets: use, ignore, show, showall\n\n"
153 " -B [+]FILE, --drivedb=[+]FILE (ATA)\n"
154 " Read and replace [add] drive database from FILE\n"
156 get_valid_firmwarebug_args(),
157 get_drivedb_path_add()
159 #ifdef SMARTMONTOOLS_DRIVEDBDIR
163 get_drivedb_path_default()
168 "============================================ DEVICE SELF-TEST OPTIONS =====\n\n"
169 " -t TEST, --test=TEST\n"
170 " Run test. TEST: offline, short, long, conveyance, force, vendor,N,\n"
171 " select,M-N, pending,N, afterselect,[on|off]\n\n"
173 " Do test in captive mode (along with -t)\n\n"
175 " Abort any non-captive test on device\n\n"
177 std::string examples
= smi()->get_app_examples("smartctl");
178 if (!examples
.empty())
179 printf("%s\n", examples
.c_str());
182 // Values for --long only options, see parse_options()
183 enum { opt_identify
= 1000, opt_scan
, opt_scan_open
, opt_set
, opt_smart
};
185 /* Returns a string containing a formatted list of the valid arguments
186 to the option opt or empty on failure. Note 'v' case different */
187 static std::string
getvalidarglist(int opt
)
191 return "errorsonly, silent, noserial";
193 return smi()->get_valid_dev_types_str() + ", auto, test";
195 return "normal, conservative, permissive, verypermissive";
197 return "warn, exit, ignore";
199 return "ioctl[,N], ataioctl[,N], scsiioctl[,N], nvmeioctl[,N]";
205 return "error, selftest, selective, directory[,g|s], "
206 "xerror[,N][,error], xselftest[,N][,selftest], "
207 "background, sasphy[,reset], sataphy[,reset], "
208 "scttemp[sts,hist], scttempint,N[,p], "
209 "scterc[,N,M], devstat[,N], ssd, "
210 "gplog,N[,RANGE], smartlog,N[,RANGE], "
213 return "use, ignore, show, showall";
215 return "offline, short, long, conveyance, force, vendor,N, select,M-N, "
216 "pending,N, afterselect,[on|off]";
218 return std::string(get_valid_firmwarebug_args()) + ", swapid";
220 return "never, sleep, standby, idle";
222 return "old, brief, hex[,id|val]";
224 return "aam, apm, lookahead, security, wcache, rcache, wcreorder";
226 return "aam,[N|off], apm,[N|off], lookahead,[on|off], security-freeze, "
227 "standby,[N|off|now], wcache,[on|off], rcache,[on|off], wcreorder,[on|off]";
229 return getvalidarglist(opt_smart
)+", "+getvalidarglist(opt_set
);
231 return "n, wn, w, v, wv, wb";
238 /* Prints the message "=======> VALID ARGUMENTS ARE: <LIST> \n", where
239 <LIST> is the list of valid arguments for option opt. */
240 static void printvalidarglistmessage(int opt
)
243 pout("=======> VALID ARGUMENTS ARE:\n\thelp\n%s\n<=======\n",
244 create_vendor_attribute_arg_list().c_str());
247 // getvalidarglist() might produce a multiline or single line string. We
248 // need to figure out which to get the formatting right.
249 std::string s
= getvalidarglist(opt
);
250 char separator
= strchr(s
.c_str(), '\n') ? '\n' : ' ';
251 pout("=======> VALID ARGUMENTS ARE:%c%s%c<=======\n", separator
, s
.c_str(), separator
);
257 // Checksum error mode
258 enum checksum_err_mode_t
{
259 CHECKSUM_ERR_WARN
, CHECKSUM_ERR_EXIT
, CHECKSUM_ERR_IGNORE
262 static checksum_err_mode_t checksum_err_mode
= CHECKSUM_ERR_WARN
;
264 static void scan_devices(const smart_devtype_list
& types
, bool with_open
, char ** argv
);
267 /* Takes command options and sets features to be run */
268 static const char * parse_options(int argc
, char** argv
,
269 ata_print_options
& ataopts
, scsi_print_options
& scsiopts
,
270 nvme_print_options
& nvmeopts
, bool & print_type_only
)
272 // Please update getvalidarglist() if you edit shortopts
273 const char *shortopts
= "h?Vq:d:T:b:r:s:o:S:HcAl:iaxv:P:t:CXF:n:B:f:g:";
274 // Please update getvalidarglist() if you edit longopts
275 struct option longopts
[] = {
276 { "help", no_argument
, 0, 'h' },
277 { "usage", no_argument
, 0, 'h' },
278 { "version", no_argument
, 0, 'V' },
279 { "copyright", no_argument
, 0, 'V' },
280 { "license", no_argument
, 0, 'V' },
281 { "quietmode", required_argument
, 0, 'q' },
282 { "device", required_argument
, 0, 'd' },
283 { "tolerance", required_argument
, 0, 'T' },
284 { "badsum", required_argument
, 0, 'b' },
285 { "report", required_argument
, 0, 'r' },
286 { "smart", required_argument
, 0, opt_smart
},
287 { "offlineauto", required_argument
, 0, 'o' },
288 { "saveauto", required_argument
, 0, 'S' },
289 { "health", no_argument
, 0, 'H' },
290 { "capabilities", no_argument
, 0, 'c' },
291 { "attributes", no_argument
, 0, 'A' },
292 { "log", required_argument
, 0, 'l' },
293 { "info", no_argument
, 0, 'i' },
294 { "all", no_argument
, 0, 'a' },
295 { "xall", no_argument
, 0, 'x' },
296 { "vendorattribute", required_argument
, 0, 'v' },
297 { "presets", required_argument
, 0, 'P' },
298 { "test", required_argument
, 0, 't' },
299 { "captive", no_argument
, 0, 'C' },
300 { "abort", no_argument
, 0, 'X' },
301 { "firmwarebug", required_argument
, 0, 'F' },
302 { "nocheck", required_argument
, 0, 'n' },
303 { "drivedb", required_argument
, 0, 'B' },
304 { "format", required_argument
, 0, 'f' },
305 { "get", required_argument
, 0, 'g' },
306 { "identify", optional_argument
, 0, opt_identify
},
307 { "set", required_argument
, 0, opt_set
},
308 { "scan", no_argument
, 0, opt_scan
},
309 { "scan-open", no_argument
, 0, opt_scan_open
},
313 char extraerror
[256];
314 memset(extraerror
, 0, sizeof(extraerror
));
317 const char * type
= 0; // set to -d optarg
318 smart_devtype_list scan_types
; // multiple -d TYPE options for --scan
319 bool use_default_db
= true; // set false on '-B FILE'
320 bool output_format_set
= false; // set true on '-f FORMAT'
321 int scan
= 0; // set by --scan, --scan-open
322 bool badarg
= false, captive
= false;
323 int testcnt
= 0; // number of self-tests requested
328 while ((optchar
= getopt_long(argc
, argv
, shortopts
, longopts
, 0)) != -1) {
331 printing_is_off
= false;
332 pout("%s", format_version_info("smartctl", true /*full*/).c_str());
336 if (!strcmp(optarg
,"errorsonly")) {
337 printing_is_switchable
= true;
338 printing_is_off
= false;
339 } else if (!strcmp(optarg
,"silent")) {
340 printing_is_switchable
= false;
341 printing_is_off
= true;
342 } else if (!strcmp(optarg
,"noserial")) {
343 dont_print_serial_number
= true;
349 if (!strcmp(optarg
, "test"))
350 print_type_only
= true;
351 else if (!strcmp(optarg
, "auto")) {
357 scan_types
.push_back(optarg
);
361 if (!strcmp(optarg
,"normal")) {
362 failuretest_conservative
= false;
363 failuretest_permissive
= 0;
364 } else if (!strcmp(optarg
,"conservative")) {
365 failuretest_conservative
= true;
366 } else if (!strcmp(optarg
,"permissive")) {
367 if (failuretest_permissive
< 0xff)
368 failuretest_permissive
++;
369 } else if (!strcmp(optarg
,"verypermissive")) {
370 failuretest_permissive
= 0xff;
376 if (!strcmp(optarg
,"warn")) {
377 checksum_err_mode
= CHECKSUM_ERR_WARN
;
378 } else if (!strcmp(optarg
,"exit")) {
379 checksum_err_mode
= CHECKSUM_ERR_EXIT
;
380 } else if (!strcmp(optarg
,"ignore")) {
381 checksum_err_mode
= CHECKSUM_ERR_IGNORE
;
388 int n1
= -1, n2
= -1, len
= strlen(optarg
);
389 char s
[9+1]; unsigned i
= 1;
390 sscanf(optarg
, "%9[a-z]%n,%u%n", s
, &n1
, &i
, &n2
);
391 if (!((n1
== len
|| n2
== len
) && 1 <= i
&& i
<= 4)) {
393 } else if (!strcmp(s
,"ioctl")) {
394 ata_debugmode
= scsi_debugmode
= nvme_debugmode
= i
;
395 } else if (!strcmp(s
,"ataioctl")) {
397 } else if (!strcmp(s
,"scsiioctl")) {
399 } else if (!strcmp(s
,"nvmeioctl")) {
408 case opt_smart
: // --smart
409 if (!strcmp(optarg
,"on")) {
410 ataopts
.smart_enable
= scsiopts
.smart_enable
= true;
411 ataopts
.smart_disable
= scsiopts
.smart_disable
= false;
412 } else if (!strcmp(optarg
,"off")) {
413 ataopts
.smart_disable
= scsiopts
.smart_disable
= true;
414 ataopts
.smart_enable
= scsiopts
.smart_enable
= false;
415 } else if (optchar
== 's') {
416 goto case_s_continued
; // --set, see below
423 if (!strcmp(optarg
,"on")) {
424 ataopts
.smart_auto_offl_enable
= true;
425 ataopts
.smart_auto_offl_disable
= false;
426 } else if (!strcmp(optarg
,"off")) {
427 ataopts
.smart_auto_offl_disable
= true;
428 ataopts
.smart_auto_offl_enable
= false;
434 if (!strcmp(optarg
,"on")) {
435 ataopts
.smart_auto_save_enable
= scsiopts
.smart_auto_save_enable
= true;
436 ataopts
.smart_auto_save_disable
= scsiopts
.smart_auto_save_disable
= false;
437 } else if (!strcmp(optarg
,"off")) {
438 ataopts
.smart_auto_save_disable
= scsiopts
.smart_auto_save_disable
= true;
439 ataopts
.smart_auto_save_enable
= scsiopts
.smart_auto_save_enable
= false;
445 ataopts
.smart_check_status
= scsiopts
.smart_check_status
= nvmeopts
.smart_check_status
= true;
446 scsiopts
.smart_ss_media_log
= true;
449 if (!strcmp(optarg
, "swapid"))
450 ataopts
.fix_swapped_id
= true;
451 else if (!parse_firmwarebug_def(optarg
, ataopts
.firmwarebugs
))
455 ataopts
.smart_general_values
= nvmeopts
.drive_capabilities
= true;
458 ataopts
.smart_vendor_attrib
= scsiopts
.smart_vendor_attrib
= nvmeopts
.smart_vendor_attrib
= true;
461 if (str_starts_with(optarg
, "error")) {
462 int n1
= -1, n2
= -1, len
= strlen(optarg
);
464 sscanf(optarg
, "error%n,%u%n", &n1
, &val
, &n2
);
465 ataopts
.smart_error_log
= scsiopts
.smart_error_log
= true;
467 nvmeopts
.error_log_entries
= 16;
468 else if (n2
== len
&& val
> 0)
469 nvmeopts
.error_log_entries
= val
;
472 } else if (!strcmp(optarg
,"selftest")) {
473 ataopts
.smart_selftest_log
= scsiopts
.smart_selftest_log
= true;
474 } else if (!strcmp(optarg
, "selective")) {
475 ataopts
.smart_selective_selftest_log
= true;
476 } else if (!strcmp(optarg
,"directory")) {
477 ataopts
.smart_logdir
= ataopts
.gp_logdir
= true; // SMART+GPL
478 } else if (!strcmp(optarg
,"directory,s")) {
479 ataopts
.smart_logdir
= true; // SMART
480 } else if (!strcmp(optarg
,"directory,g")) {
481 ataopts
.gp_logdir
= true; // GPL
482 } else if (!strcmp(optarg
,"sasphy")) {
483 scsiopts
.sasphy
= true;
484 } else if (!strcmp(optarg
,"sasphy,reset")) {
485 scsiopts
.sasphy
= scsiopts
.sasphy_reset
= true;
486 } else if (!strcmp(optarg
,"sataphy")) {
487 ataopts
.sataphy
= true;
488 } else if (!strcmp(optarg
,"sataphy,reset")) {
489 ataopts
.sataphy
= ataopts
.sataphy_reset
= true;
490 } else if (!strcmp(optarg
,"background")) {
491 scsiopts
.smart_background_log
= true;
492 } else if (!strcmp(optarg
,"ssd")) {
493 ataopts
.devstat_ssd_page
= true;
494 scsiopts
.smart_ss_media_log
= true;
495 } else if (!strcmp(optarg
,"scterc")) {
496 ataopts
.sct_erc_get
= true;
497 } else if (!strcmp(optarg
,"scttemp")) {
498 ataopts
.sct_temp_sts
= ataopts
.sct_temp_hist
= true;
499 } else if (!strcmp(optarg
,"scttempsts")) {
500 ataopts
.sct_temp_sts
= true;
501 } else if (!strcmp(optarg
,"scttemphist")) {
502 ataopts
.sct_temp_hist
= true;
504 } else if (!strncmp(optarg
, "scttempint,", sizeof("scstempint,")-1)) {
505 unsigned interval
= 0; int n1
= -1, n2
= -1, len
= strlen(optarg
);
506 if (!( sscanf(optarg
,"scttempint,%u%n,p%n", &interval
, &n1
, &n2
) == 1
507 && 0 < interval
&& interval
<= 0xffff && (n1
== len
|| n2
== len
))) {
508 snprintf(extraerror
, sizeof(extraerror
), "Option -l scttempint,N[,p] must have positive integer N\n");
511 ataopts
.sct_temp_int
= interval
;
512 ataopts
.sct_temp_int_pers
= (n2
== len
);
514 } else if (!strncmp(optarg
, "devstat", sizeof("devstat")-1)) {
515 int n1
= -1, n2
= -1, len
= strlen(optarg
);
517 sscanf(optarg
, "devstat%n,%u%n", &n1
, &val
, &n2
);
519 ataopts
.devstat_all_pages
= true;
521 if (n2
!= len
) // retry with hex
522 sscanf(optarg
, "devstat,0x%x%n", &val
, &n2
);
523 if (n2
== len
&& val
<= 0xff)
524 ataopts
.devstat_pages
.push_back(val
);
529 } else if (!strncmp(optarg
, "xerror", sizeof("xerror")-1)) {
530 int n1
= -1, n2
= -1, len
= strlen(optarg
);
532 sscanf(optarg
, "xerror%n,error%n", &n1
, &n2
);
533 if (!(n1
== len
|| n2
== len
)) {
535 sscanf(optarg
, "xerror,%u%n,error%n", &val
, &n1
, &n2
);
537 if ((n1
== len
|| n2
== len
) && val
> 0) {
538 ataopts
.smart_ext_error_log
= val
;
539 ataopts
.retry_error_log
= (n2
== len
);
544 } else if (!strncmp(optarg
, "xselftest", sizeof("xselftest")-1)) {
545 int n1
= -1, n2
= -1, len
= strlen(optarg
);
547 sscanf(optarg
, "xselftest%n,selftest%n", &n1
, &n2
);
548 if (!(n1
== len
|| n2
== len
)) {
550 sscanf(optarg
, "xselftest,%u%n,selftest%n", &val
, &n1
, &n2
);
552 if ((n1
== len
|| n2
== len
) && val
> 0) {
553 ataopts
.smart_ext_selftest_log
= val
;
554 ataopts
.retry_selftest_log
= (n2
== len
);
559 } else if (!strncmp(optarg
, "scterc,", sizeof("scterc,")-1)) {
560 unsigned rt
= ~0, wt
= ~0; int n
= -1;
561 sscanf(optarg
,"scterc,%u,%u%n", &rt
, &wt
, &n
);
562 if (n
== (int)strlen(optarg
) && rt
<= 999 && wt
<= 999) {
563 ataopts
.sct_erc_set
= true;
564 ataopts
.sct_erc_readtime
= rt
;
565 ataopts
.sct_erc_writetime
= wt
;
568 snprintf(extraerror
, sizeof(extraerror
), "Option -l scterc,[READTIME,WRITETIME] syntax error\n");
571 } else if ( !strncmp(optarg
, "gplog," , sizeof("gplog," )-1)
572 || !strncmp(optarg
, "smartlog,", sizeof("smartlog,")-1)) {
573 unsigned logaddr
= ~0U; unsigned page
= 0, nsectors
= 1; char sign
= 0;
574 int n1
= -1, n2
= -1, n3
= -1, len
= strlen(optarg
);
575 sscanf(optarg
, "%*[a-z],0x%x%n,%u%n%c%u%n",
576 &logaddr
, &n1
, &page
, &n2
, &sign
, &nsectors
, &n3
);
577 if (len
> n2
&& n3
== -1 && !strcmp(optarg
+n2
, "-max")) {
578 nsectors
= ~0U; sign
= '+'; n3
= len
;
580 bool gpl
= (optarg
[0] == 'g');
581 const char * erropt
= (gpl
? "gplog" : "smartlog");
582 if (!( n1
== len
|| n2
== len
583 || (n3
== len
&& (sign
== '+' || sign
== '-')))) {
584 snprintf(extraerror
, sizeof(extraerror
), "Option -l %s,ADDR[,FIRST[-LAST|+SIZE]] syntax error\n", erropt
);
587 else if (!( logaddr
<= 0xff && page
<= (gpl
? 0xffffU
: 0x00ffU
)
589 && (nsectors
<= (gpl
? 0xffffU
: 0xffU
) || nsectors
== ~0U)
590 && (sign
!= '-' || page
<= nsectors
) )) {
591 snprintf(extraerror
, sizeof(extraerror
), "Option -l %s,ADDR[,FIRST[-LAST|+SIZE]] parameter out of range\n", erropt
);
596 req
.gpl
= gpl
; req
.logaddr
= logaddr
; req
.page
= page
;
597 req
.nsectors
= (sign
== '-' ? nsectors
-page
+1 : nsectors
);
598 ataopts
.log_requests
.push_back(req
);
602 else if (str_starts_with(optarg
, "nvmelog,")) {
603 int n
= -1, len
= strlen(optarg
);
604 unsigned page
= 0, size
= 0;
605 sscanf(optarg
, "nvmelog,0x%x,0x%x%n", &page
, &size
, &n
);
606 if (n
== len
&& page
<= 0xff && 0 < size
&& size
<= 0x4000) {
607 nvmeopts
.log_page
= page
; nvmeopts
.log_page_size
= size
;
618 ataopts
.drive_info
= scsiopts
.drive_info
= nvmeopts
.drive_info
= true;
622 ataopts
.identify_word_level
= ataopts
.identify_bit_level
= 0;
624 for (int i
= 0; optarg
[i
]; i
++) {
626 case 'w': ataopts
.identify_word_level
= 1; break;
627 case 'n': ataopts
.identify_bit_level
= -1; break;
628 case 'v': ataopts
.identify_bit_level
= 1; break;
629 case 'b': ataopts
.identify_bit_level
= 2; break;
630 default: badarg
= true;
637 ataopts
.drive_info
= scsiopts
.drive_info
= nvmeopts
.drive_info
= true;
638 ataopts
.smart_check_status
= scsiopts
.smart_check_status
= nvmeopts
.smart_check_status
= true;
639 ataopts
.smart_general_values
= nvmeopts
.drive_capabilities
= true;
640 ataopts
.smart_vendor_attrib
= scsiopts
.smart_vendor_attrib
= nvmeopts
.smart_vendor_attrib
= true;
641 ataopts
.smart_error_log
= scsiopts
.smart_error_log
= true;
642 nvmeopts
.error_log_entries
= 16;
643 ataopts
.smart_selftest_log
= scsiopts
.smart_selftest_log
= true;
644 ataopts
.smart_selective_selftest_log
= true;
645 /* scsiopts.smart_background_log = true; */
646 scsiopts
.smart_ss_media_log
= true;
649 ataopts
.drive_info
= scsiopts
.drive_info
= nvmeopts
.drive_info
= true;
650 ataopts
.smart_check_status
= scsiopts
.smart_check_status
= nvmeopts
.smart_check_status
= true;
651 ataopts
.smart_general_values
= nvmeopts
.drive_capabilities
= true;
652 ataopts
.smart_vendor_attrib
= scsiopts
.smart_vendor_attrib
= nvmeopts
.smart_vendor_attrib
= true;
653 ataopts
.smart_ext_error_log
= 8;
654 ataopts
.retry_error_log
= true;
655 nvmeopts
.error_log_entries
= 16;
656 ataopts
.smart_ext_selftest_log
= 25;
657 ataopts
.retry_selftest_log
= true;
658 scsiopts
.smart_error_log
= scsiopts
.smart_selftest_log
= true;
659 ataopts
.smart_selective_selftest_log
= true;
660 ataopts
.smart_logdir
= ataopts
.gp_logdir
= true;
661 ataopts
.sct_temp_sts
= ataopts
.sct_temp_hist
= true;
662 ataopts
.sct_erc_get
= true;
663 ataopts
.sct_wcache_reorder_get
= true;
664 ataopts
.devstat_all_pages
= true;
665 ataopts
.sataphy
= true;
666 ataopts
.get_set_used
= true;
667 ataopts
.get_aam
= ataopts
.get_apm
= true;
668 ataopts
.get_security
= true;
669 ataopts
.get_lookahead
= ataopts
.get_wcache
= true;
670 scsiopts
.get_rcd
= scsiopts
.get_wce
= true;
671 scsiopts
.smart_background_log
= true;
672 scsiopts
.smart_ss_media_log
= true;
673 scsiopts
.sasphy
= true;
674 if (!output_format_set
)
675 ataopts
.output_format
|= ata_print_options::FMT_BRIEF
;
678 // parse vendor-specific definitions of attributes
679 if (!strcmp(optarg
,"help")) {
680 printing_is_off
= false;
682 pout("The valid arguments to -v are:\n\thelp\n%s\n",
683 create_vendor_attribute_arg_list().c_str());
686 if (!parse_attribute_def(optarg
, ataopts
.attribute_defs
, PRIOR_USER
))
690 if (!strcmp(optarg
, "use")) {
691 ataopts
.ignore_presets
= false;
692 } else if (!strcmp(optarg
, "ignore")) {
693 ataopts
.ignore_presets
= true;
694 } else if (!strcmp(optarg
, "show")) {
695 ataopts
.show_presets
= true;
696 } else if (!strcmp(optarg
, "showall")) {
697 if (!init_drive_database(use_default_db
))
699 if (optind
< argc
) { // -P showall MODEL [FIRMWARE]
700 int cnt
= showmatchingpresets(argv
[optind
], (optind
+1<argc
? argv
[optind
+1] : NULL
));
701 EXIT(cnt
); // report #matches
703 if (showallpresets())
704 EXIT(FAILCMD
); // report regexp syntax error
711 if (!strcmp(optarg
,"offline")) {
713 ataopts
.smart_selftest_type
= OFFLINE_FULL_SCAN
;
714 scsiopts
.smart_default_selftest
= true;
715 } else if (!strcmp(optarg
,"short")) {
717 ataopts
.smart_selftest_type
= SHORT_SELF_TEST
;
718 scsiopts
.smart_short_selftest
= true;
719 } else if (!strcmp(optarg
,"long")) {
721 ataopts
.smart_selftest_type
= EXTEND_SELF_TEST
;
722 scsiopts
.smart_extend_selftest
= true;
723 } else if (!strcmp(optarg
,"conveyance")) {
725 ataopts
.smart_selftest_type
= CONVEYANCE_SELF_TEST
;
726 } else if (!strcmp(optarg
,"force")) {
727 ataopts
.smart_selftest_force
= true;
728 scsiopts
.smart_selftest_force
= true;
729 } else if (!strcmp(optarg
,"afterselect,on")) {
730 // scan remainder of disk after doing selected segment
731 ataopts
.smart_selective_args
.scan_after_select
= 2;
732 } else if (!strcmp(optarg
,"afterselect,off")) {
733 // don't scan remainder of disk after doing selected segments
734 ataopts
.smart_selective_args
.scan_after_select
= 1;
735 } else if (!strncmp(optarg
,"pending,",strlen("pending,"))) {
736 // parse number of minutes that test should be pending
740 i
=(int)strtol(optarg
+strlen("pending,"), &tailptr
, 10);
741 if (errno
|| *tailptr
!= '\0') {
742 snprintf(extraerror
, sizeof(extraerror
), "Option -t pending,N requires N to be a non-negative integer\n");
744 } else if (i
<0 || i
>65535) {
745 snprintf(extraerror
, sizeof(extraerror
), "Option -t pending,N (N=%d) must have 0 <= N <= 65535\n", i
);
748 ataopts
.smart_selective_args
.pending_time
= i
+1;
750 } else if (!strncmp(optarg
,"select",strlen("select"))) {
751 if (ataopts
.smart_selective_args
.num_spans
== 0)
753 // parse range of LBAs to test
754 uint64_t start
, stop
; int mode
;
755 if (split_selective_arg(optarg
, &start
, &stop
, &mode
)) {
756 snprintf(extraerror
, sizeof(extraerror
), "Option -t select,M-N must have non-negative integer M and N\n");
759 if (ataopts
.smart_selective_args
.num_spans
>= 5 || start
> stop
) {
761 snprintf(extraerror
, sizeof(extraerror
), "ERROR: Start LBA (%" PRIu64
") > ending LBA (%" PRId64
") in argument \"%s\"\n",
762 start
, stop
, optarg
);
764 snprintf(extraerror
, sizeof(extraerror
),"ERROR: No more than five selective self-test spans may be"
769 ataopts
.smart_selective_args
.span
[ataopts
.smart_selective_args
.num_spans
].start
= start
;
770 ataopts
.smart_selective_args
.span
[ataopts
.smart_selective_args
.num_spans
].end
= stop
;
771 ataopts
.smart_selective_args
.span
[ataopts
.smart_selective_args
.num_spans
].mode
= mode
;
772 ataopts
.smart_selective_args
.num_spans
++;
773 ataopts
.smart_selftest_type
= SELECTIVE_SELF_TEST
;
775 } else if (!strncmp(optarg
, "scttempint", sizeof("scstempint")-1)) {
776 snprintf(extraerror
, sizeof(extraerror
), "-t scttempint is no longer supported, use -l scttempint instead\n");
778 } else if (!strncmp(optarg
, "vendor,", sizeof("vendor,")-1)) {
779 unsigned subcmd
= ~0U; int n
= -1;
780 if (!( sscanf(optarg
, "%*[a-z],0x%x%n", &subcmd
, &n
) == 1
781 && subcmd
<= 0xff && n
== (int)strlen(optarg
))) {
782 snprintf(extraerror
, sizeof(extraerror
), "Option -t vendor,0xNN syntax error\n");
786 ataopts
.smart_selftest_type
= subcmd
;
796 scsiopts
.smart_selftest_abort
= true;
797 ataopts
.smart_selftest_type
= ABORT_SELF_TEST
;
800 // skip disk check if in low-power mode
801 if (!strcmp(optarg
, "never"))
802 ataopts
.powermode
= 1; // do not skip, but print mode
803 else if (!strcmp(optarg
, "sleep"))
804 ataopts
.powermode
= 2;
805 else if (!strcmp(optarg
, "standby"))
806 ataopts
.powermode
= 3;
807 else if (!strcmp(optarg
, "idle"))
808 ataopts
.powermode
= 4;
813 if (!strcmp(optarg
, "old")) {
814 ataopts
.output_format
&= ~ata_print_options::FMT_BRIEF
;
815 output_format_set
= true;
817 else if (!strcmp(optarg
, "brief")) {
818 ataopts
.output_format
|= ata_print_options::FMT_BRIEF
;
819 output_format_set
= true;
821 else if (!strcmp(optarg
, "hex"))
822 ataopts
.output_format
|= ata_print_options::FMT_HEX_ID
823 | ata_print_options::FMT_HEX_VAL
;
824 else if (!strcmp(optarg
, "hex,id"))
825 ataopts
.output_format
|= ata_print_options::FMT_HEX_ID
;
826 else if (!strcmp(optarg
, "hex,val"))
827 ataopts
.output_format
|= ata_print_options::FMT_HEX_VAL
;
833 const char * path
= optarg
;
834 if (*path
== '+' && path
[1])
837 use_default_db
= false;
838 if (!read_drive_database(path
))
843 printing_is_off
= false;
850 case_s_continued
: // -s, see above
851 case opt_set
: // --set
853 ataopts
.get_set_used
= true;
854 bool get
= (optchar
== 'g');
855 char name
[16+1]; unsigned val
;
856 int n1
= -1, n2
= -1, n3
= -1, len
= strlen(optarg
);
857 if (sscanf(optarg
, "%16[^,=]%n%*[,=]%n%u%n", name
, &n1
, &n2
, &val
, &n3
) >= 1
858 && (n1
== len
|| (!get
&& n2
> 0))) {
859 bool on
= (n2
> 0 && !strcmp(optarg
+n2
, "on"));
860 bool off
= (n2
> 0 && !strcmp(optarg
+n2
, "off"));
864 if (get
&& !strcmp(name
, "all")) {
865 ataopts
.get_aam
= ataopts
.get_apm
= true;
866 ataopts
.get_security
= true;
867 ataopts
.get_lookahead
= ataopts
.get_wcache
= true;
868 scsiopts
.get_rcd
= scsiopts
.get_wce
= true;
870 else if (!strcmp(name
, "aam")) {
872 ataopts
.get_aam
= true;
874 ataopts
.set_aam
= -1;
876 ataopts
.set_aam
= val
+ 1;
878 snprintf(extraerror
, sizeof(extraerror
), "Option -s aam,N must have 0 <= N <= 254\n");
882 else if (!strcmp(name
, "apm")) {
884 ataopts
.get_apm
= true;
886 ataopts
.set_apm
= -1;
887 else if (1 <= val
&& val
<= 254)
888 ataopts
.set_apm
= val
+ 1;
890 snprintf(extraerror
, sizeof(extraerror
), "Option -s apm,N must have 1 <= N <= 254\n");
894 else if (!strcmp(name
, "lookahead")) {
896 ataopts
.get_lookahead
= true;
899 ataopts
.set_lookahead
= -1;
901 ataopts
.set_lookahead
= 1;
905 else if (!strcmp(name
, "wcreorder")) {
907 ataopts
.sct_wcache_reorder_get
= true;
910 ataopts
.sct_wcache_reorder_set
= -1;
912 ataopts
.sct_wcache_reorder_set
= 1;
916 else if (!strcmp(name
, "rcache")) {
918 scsiopts
.get_rcd
= true;
920 scsiopts
.set_rcd
= -1;
922 scsiopts
.set_rcd
= 1;
926 else if (get
&& !strcmp(name
, "security")) {
927 ataopts
.get_security
= true;
929 else if (!get
&& !strcmp(optarg
, "security-freeze")) {
930 ataopts
.set_security_freeze
= true;
932 else if (!get
&& !strcmp(optarg
, "standby,now")) {
933 ataopts
.set_standby_now
= true;
935 else if (!get
&& !strcmp(name
, "standby")) {
937 ataopts
.set_standby
= 0 + 1;
939 ataopts
.set_standby
= val
+ 1;
941 snprintf(extraerror
, sizeof(extraerror
), "Option -s standby,N must have 0 <= N <= 255\n");
945 else if (!strcmp(name
, "wcache")) {
947 ataopts
.get_wcache
= true;
948 scsiopts
.get_wce
= true;
951 ataopts
.set_wcache
= -1;
952 scsiopts
.set_wce
= -1;
955 ataopts
.set_wcache
= 1;
956 scsiopts
.set_wce
= 1;
976 printing_is_off
= false;
978 // Point arg to the argument in which this option was found.
979 arg
= argv
[optind
-1];
980 // Check whether the option is a long option that doesn't map to -h.
981 if (arg
[1] == '-' && optchar
!= 'h') {
982 // Iff optopt holds a valid option then argument must be missing.
983 if (optopt
&& (optopt
>= opt_scan
|| strchr(shortopts
, optopt
))) {
984 pout("=======> ARGUMENT REQUIRED FOR OPTION: %s\n", arg
+2);
985 printvalidarglistmessage(optopt
);
987 pout("=======> UNRECOGNIZED OPTION: %s\n",arg
+2);
989 pout("=======> %s", extraerror
);
993 if (0 < optopt
&& optopt
< '~') {
994 // Iff optopt holds a valid option then argument must be
995 // missing. Note (BA) this logic seems to fail using Solaris
997 if (strchr(shortopts
, optopt
) != NULL
) {
998 pout("=======> ARGUMENT REQUIRED FOR OPTION: %c\n", optopt
);
999 printvalidarglistmessage(optopt
);
1001 pout("=======> UNRECOGNIZED OPTION: %c\n",optopt
);
1003 pout("=======> %s", extraerror
);
1009 } // closes switch statement to process command-line options
1011 // Check to see if option had an unrecognized or incorrect argument.
1014 // It would be nice to print the actual option name given by the user
1015 // here, but we just print the short form. Please fix this if you know
1016 // a clean way to do it.
1017 char optstr
[] = { (char)optchar
, 0 };
1018 pout("=======> INVALID ARGUMENT TO -%s: %s\n",
1019 (optchar
== opt_identify
? "-identify" :
1020 optchar
== opt_set
? "-set" :
1021 optchar
== opt_smart
? "-smart" : optstr
), optarg
);
1022 printvalidarglistmessage(optchar
);
1024 pout("=======> %s", extraerror
);
1030 // Special handling of --scan, --scanopen
1032 // Read or init drive database to allow USB ID check.
1033 if (!init_drive_database(use_default_db
))
1035 scan_devices(scan_types
, (scan
== opt_scan_open
), argv
+ optind
);
1039 // At this point we have processed all command-line options. If the
1040 // print output is switchable, then start with the print output
1042 if (printing_is_switchable
)
1043 printing_is_off
= true;
1045 // Check for multiple -d TYPE options
1046 if (scan_types
.size() > 1) {
1047 printing_is_off
= false;
1049 pout("ERROR: multiple -d TYPE options are only allowed with --scan\n");
1054 // error message if user has asked for more than one test
1056 printing_is_off
= false;
1058 pout("\nERROR: smartctl can only run a single test type (or abort) at a time.\n");
1063 // error message if user has set selective self-test options without
1064 // asking for a selective self-test
1065 if ( (ataopts
.smart_selective_args
.pending_time
|| ataopts
.smart_selective_args
.scan_after_select
)
1066 && !ataopts
.smart_selective_args
.num_spans
) {
1067 printing_is_off
= false;
1069 if (ataopts
.smart_selective_args
.pending_time
)
1070 pout("\nERROR: smartctl -t pending,N must be used with -t select,N-M.\n");
1072 pout("\nERROR: smartctl -t afterselect,(on|off) must be used with -t select,N-M.\n");
1077 // If captive option was used, change test type if appropriate.
1079 switch (ataopts
.smart_selftest_type
) {
1080 case SHORT_SELF_TEST
:
1081 ataopts
.smart_selftest_type
= SHORT_CAPTIVE_SELF_TEST
;
1082 scsiopts
.smart_short_selftest
= false;
1083 scsiopts
.smart_short_cap_selftest
= true;
1085 case EXTEND_SELF_TEST
:
1086 ataopts
.smart_selftest_type
= EXTEND_CAPTIVE_SELF_TEST
;
1087 scsiopts
.smart_extend_selftest
= false;
1088 scsiopts
.smart_extend_cap_selftest
= true;
1090 case CONVEYANCE_SELF_TEST
:
1091 ataopts
.smart_selftest_type
= CONVEYANCE_CAPTIVE_SELF_TEST
;
1093 case SELECTIVE_SELF_TEST
:
1094 ataopts
.smart_selftest_type
= SELECTIVE_CAPTIVE_SELF_TEST
;
1098 // From here on, normal operations...
1101 // Warn if the user has provided no device name
1103 pout("ERROR: smartctl requires a device name as the final command-line argument.\n\n");
1108 // Warn if the user has provided more than one device name
1111 pout("ERROR: smartctl takes ONE device name as the final command-line argument.\n");
1112 pout("You have provided %d device names:\n",argc
-optind
);
1113 for (i
=0; i
<argc
-optind
; i
++)
1114 pout("%s\n",argv
[optind
+i
]);
1119 // Read or init drive database
1120 if (!init_drive_database(use_default_db
))
1126 // Printing function (controlled by global printing_is_off)
1127 // [From GLIBC Manual: Since the prototype doesn't specify types for
1128 // optional arguments, in a call to a variadic function the default
1129 // argument promotions are performed on the optional argument
1130 // values. This means the objects of type char or short int (whether
1131 // signed or not) are promoted to either int or unsigned int, as
1133 void pout(const char *fmt
, ...){
1136 // initialize variable argument list
1138 if (printing_is_off
) {
1150 // Globals to set failuretest() policy
1151 bool failuretest_conservative
= false;
1152 unsigned char failuretest_permissive
= 0;
1154 // Compares failure type to policy in effect, and either exits or
1155 // simply returns to the calling routine.
1156 // Used in ataprint.cpp and scsiprint.cpp.
1157 void failuretest(failure_type type
, int returnvalue
)
1159 // If this is an error in an "optional" SMART command
1160 if (type
== OPTIONAL_CMD
) {
1161 if (!failuretest_conservative
)
1163 pout("An optional SMART command failed: exiting. Remove '-T conservative' option to continue.\n");
1167 // If this is an error in a "mandatory" SMART command
1168 if (type
== MANDATORY_CMD
) {
1169 if (failuretest_permissive
--)
1171 pout("A mandatory SMART command failed: exiting. To continue, add one or more '-T permissive' options.\n");
1175 throw std::logic_error("failuretest: Unknown type");
1178 // Used to warn users about invalid checksums. Called from atacmds.cpp.
1179 // Action to be taken may be altered by the user.
1180 void checksumwarning(const char * string
)
1182 // user has asked us to ignore checksum errors
1183 if (checksum_err_mode
== CHECKSUM_ERR_IGNORE
)
1186 pout("Warning! %s error: invalid SMART checksum.\n", string
);
1188 // user has asked us to fail on checksum errors
1189 if (checksum_err_mode
== CHECKSUM_ERR_EXIT
)
1193 // Return info string about device protocol
1194 static const char * get_protocol_info(const smart_device
* dev
)
1196 switch ( (int)dev
->is_ata()
1197 | ((int)dev
->is_scsi() << 1)
1198 | ((int)dev
->is_nvme() << 2)) {
1199 case 0x1: return "ATA";
1200 case 0x2: return "SCSI";
1201 case 0x3: return "ATA+SCSI";
1202 case 0x4: return "NVMe";
1203 default: return "Unknown";
1208 // smartctl [-d type] --scan[-open] -- [PATTERN] [smartd directive ...]
1209 void scan_devices(const smart_devtype_list
& types
, bool with_open
, char ** argv
)
1211 bool dont_print
= !(ata_debugmode
|| scsi_debugmode
|| nvme_debugmode
);
1213 const char * pattern
= 0;
1215 if (argv
[ai
] && argv
[ai
][0] != '-')
1216 pattern
= argv
[ai
++];
1218 smart_device_list devlist
;
1219 printing_is_off
= dont_print
;
1220 bool ok
= smi()->scan_smart_devices(devlist
, types
, pattern
);
1221 printing_is_off
= false;
1224 pout("# scan_smart_devices: %s\n", smi()->get_errmsg());
1228 for (unsigned i
= 0; i
< devlist
.size(); i
++) {
1229 smart_device_auto_ptr
dev( devlist
.release(i
) );
1232 printing_is_off
= dont_print
;
1233 dev
.replace ( dev
->autodetect_open() );
1234 printing_is_off
= false;
1236 if (!dev
->is_open()) {
1237 pout("# %s -d %s # %s, %s device open failed: %s\n", dev
->get_dev_name(),
1238 dev
->get_dev_type(), dev
->get_info_name(),
1239 get_protocol_info(dev
.get()), dev
->get_errmsg());
1244 pout("%s -d %s", dev
->get_dev_name(), dev
->get_dev_type());
1246 pout(" # %s, %s device\n", dev
->get_info_name(), get_protocol_info(dev
.get()));
1248 for (int j
= ai
; argv
[j
]; j
++)
1249 pout(" %s", argv
[j
]);
1258 // Main program without exception handling
1259 static int main_worker(int argc
, char **argv
)
1261 // Throw if runtime environment does not match compile time test.
1264 // Initialize interface
1265 smart_interface::init();
1269 // Parse input arguments
1270 ata_print_options ataopts
;
1271 scsi_print_options scsiopts
;
1272 nvme_print_options nvmeopts
;
1273 bool print_type_only
= false;
1274 const char * type
= parse_options(argc
, argv
, ataopts
, scsiopts
, nvmeopts
, print_type_only
);
1276 const char * name
= argv
[argc
-1];
1278 smart_device_auto_ptr dev
;
1279 if (!strcmp(name
,"-")) {
1280 // Parse "smartctl -r ataioctl,2 ..." output from stdin
1281 if (type
|| print_type_only
) {
1282 pout("-d option is not allowed in conjunction with device name \"-\".\n");
1286 dev
= get_parsed_ata_device(smi(), name
);
1289 // get device of appropriate type
1290 dev
= smi()->get_smart_device(name
, type
);
1293 pout("%s: %s\n", name
, smi()->get_errmsg());
1295 printvalidarglistmessage('d');
1297 pout("Please specify device type with the -d option.\n");
1302 if (print_type_only
)
1303 // Report result of first autodetection
1304 pout("%s: Device of type '%s' [%s] detected\n",
1305 dev
->get_info_name(), dev
->get_dev_type(), get_protocol_info(dev
.get()));
1307 if (dev
->is_ata() && ataopts
.powermode
>=2 && dev
->is_powered_down()) {
1308 pout( "%s: Device is in %s mode, exit(%d)\n", dev
->get_info_name(), "STANDBY (OS)", FAILPOWER
);
1315 smart_device::device_info oldinfo
= dev
->get_info();
1317 // Open with autodetect support, may return 'better' device
1318 dev
.replace( dev
->autodetect_open() );
1320 // Report if type has changed
1321 if ( (ata_debugmode
|| scsi_debugmode
|| nvme_debugmode
|| print_type_only
)
1322 && oldinfo
.dev_type
!= dev
->get_dev_type() )
1323 pout("%s: Device open changed type from '%s' to '%s'\n",
1324 dev
->get_info_name(), oldinfo
.dev_type
.c_str(), dev
->get_dev_type());
1326 if (!dev
->is_open()) {
1327 pout("Smartctl open device: %s failed: %s\n", dev
->get_info_name(), dev
->get_errmsg());
1331 // now call appropriate ATA or SCSI routine
1333 if (print_type_only
)
1334 pout("%s: Device of type '%s' [%s] opened\n",
1335 dev
->get_info_name(), dev
->get_dev_type(), get_protocol_info(dev
.get()));
1336 else if (dev
->is_ata())
1337 retval
= ataPrintMain(dev
->to_ata(), ataopts
);
1338 else if (dev
->is_scsi())
1339 retval
= scsiPrintMain(dev
->to_scsi(), scsiopts
);
1340 else if (dev
->is_nvme())
1341 retval
= nvmePrintMain(dev
->to_nvme(), nvmeopts
);
1343 // we should never fall into this branch!
1344 pout("%s: Neither ATA, SCSI nor NVMe device\n", dev
->get_info_name());
1352 int main(int argc
, char **argv
)
1355 bool badcode
= false;
1358 // Do the real work ...
1359 status
= main_worker(argc
, argv
);
1362 // EXIT(status) arrives here
1365 catch (const std::bad_alloc
& /*ex*/) {
1366 // Memory allocation failed (also thrown by std::operator new)
1367 printf("Smartctl: Out of memory\n");
1370 catch (const std::exception
& ex
) {
1371 // Other fatal errors
1372 printf("Smartctl: Exception: %s\n", ex
.what());
1377 // Check for remaining device objects
1378 if (smart_device::get_num_objects() != 0) {
1379 printf("Smartctl: Internal Error: %d device object(s) left at exit.\n",
1380 smart_device::get_num_objects());
1386 printf("Please inform " PACKAGE_BUGREPORT
", including output of smartctl -V.\n");