]> git.proxmox.com Git - mirror_smartmontools-debian.git/blob - smartctl.h
import smartmontools 7.0
[mirror_smartmontools-debian.git] / smartctl.h
1 /*
2 * smartctl.h
3 *
4 * Home page of code is: http://www.smartmontools.org
5 *
6 * Copyright (C) 2002-10 Bruce Allen
7 * Copyright (C) 2008-17 Christian Franke
8 * Copyright (C) 2000 Michael Cornwell <cornwell@acm.org>
9 *
10 * SPDX-License-Identifier: GPL-2.0-or-later
11 */
12
13 #ifndef SMARTCTL_H_
14 #define SMARTCTL_H_
15
16 #define SMARTCTL_H_CVSID "$Id: smartctl.h 4842 2018-12-02 16:07:26Z chrfranke $\n"
17
18 // Return codes (bitmask)
19
20 // command line did not parse, or internal error occurred in smartctl
21 #define FAILCMD (0x01<<0)
22
23 // device open failed
24 #define FAILDEV (0x01<<1)
25
26 // device is in low power mode and -n option requests to exit
27 #define FAILPOWER (0x01<<1)
28
29 // read device identity (ATA only) failed
30 #define FAILID (0x01<<1)
31
32 // smart command failed, or ATA identify device structure missing information
33 #define FAILSMART (0x01<<2)
34
35 // SMART STATUS returned FAILURE
36 #define FAILSTATUS (0x01<<3)
37
38 // Attributes found <= threshold with prefail=1
39 #define FAILATTR (0x01<<4)
40
41 // SMART STATUS returned GOOD but age attributes failed or prefail
42 // attributes have failed in the past
43 #define FAILAGE (0x01<<5)
44
45 // Device had Errors in the error log
46 #define FAILERR (0x01<<6)
47
48 // Device had Errors in the self-test log
49 #define FAILLOG (0x01<<7)
50
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.
56 enum failure_type {
57 OPTIONAL_CMD,
58 MANDATORY_CMD,
59 };
60
61 // Globals to set failuretest() policy
62 extern bool failuretest_conservative;
63 extern unsigned char failuretest_permissive;
64
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);
68
69 // Globals to control printing
70 extern bool printing_is_switchable;
71 extern bool printing_is_off;
72
73 // Printing control functions
74 inline void print_on()
75 {
76 if (printing_is_switchable)
77 printing_is_off = false;
78 }
79 inline void print_off()
80 {
81 if (printing_is_switchable)
82 printing_is_off = true;
83 }
84
85 // The singleton global JSON object
86 #include "json.h"
87 extern json jglb;
88
89 #include "utility.h" // __attribute_format_printf()
90 // TODO: move this to a new include file?
91
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);
102
103 #endif