4 * Home page of code is: http://www.smartmontools.org
6 * Copyright (C) 2002-10 Bruce Allen
7 * Copyright (C) 2008-17 Christian Franke
8 * Copyright (C) 2000 Michael Cornwell <cornwell@acm.org>
10 * SPDX-License-Identifier: GPL-2.0-or-later
16 #define SMARTCTL_H_CVSID "$Id: smartctl.h 4842 2018-12-02 16:07:26Z chrfranke $\n"
18 // Return codes (bitmask)
20 // command line did not parse, or internal error occurred in smartctl
21 #define FAILCMD (0x01<<0)
24 #define FAILDEV (0x01<<1)
26 // device is in low power mode and -n option requests to exit
27 #define FAILPOWER (0x01<<1)
29 // read device identity (ATA only) failed
30 #define FAILID (0x01<<1)
32 // smart command failed, or ATA identify device structure missing information
33 #define FAILSMART (0x01<<2)
35 // SMART STATUS returned FAILURE
36 #define FAILSTATUS (0x01<<3)
38 // Attributes found <= threshold with prefail=1
39 #define FAILATTR (0x01<<4)
41 // SMART STATUS returned GOOD but age attributes failed or prefail
42 // attributes have failed in the past
43 #define FAILAGE (0x01<<5)
45 // Device had Errors in the error log
46 #define FAILERR (0x01<<6)
48 // Device had Errors in the self-test log
49 #define FAILLOG (0x01<<7)
51 // Classes of SMART commands. Here 'mandatory' means "Required by the
52 // ATA/ATAPI-5 Specification if the device implements the S.M.A.R.T.
53 // command set." The 'mandatory' S.M.A.R.T. commands are: (1)
54 // Enable/Disable Attribute Autosave, (2) Enable/Disable S.M.A.R.T.,
55 // and (3) S.M.A.R.T. Return Status. All others are optional.
61 // Globals to set failuretest() policy
62 extern bool failuretest_conservative
;
63 extern unsigned char failuretest_permissive
;
65 // Compares failure type to policy in effect, and either exits or
66 // simply returns to the calling routine.
67 void failuretest(failure_type type
, int returnvalue
);
69 // Globals to control printing
70 extern bool printing_is_switchable
;
71 extern bool printing_is_off
;
73 // Printing control functions
74 inline void print_on()
76 if (printing_is_switchable
)
77 printing_is_off
= false;
79 inline void print_off()
81 if (printing_is_switchable
)
82 printing_is_off
= true;
85 // The singleton global JSON object
89 #include "utility.h" // __attribute_format_printf()
90 // TODO: move this to a new include file?
92 // Version of pout() for items already included in JSON output
93 void jout(const char *fmt
, ...)
94 __attribute_format_printf(1, 2);
95 // Version of pout() for info/warning/error messages
96 void jinf(const char *fmt
, ...)
97 __attribute_format_printf(1, 2);
98 void jwrn(const char *fmt
, ...)
99 __attribute_format_printf(1, 2);
100 void jerr(const char *fmt
, ...)
101 __attribute_format_printf(1, 2);