]> git.proxmox.com Git - mirror_smartmontools-debian.git/blame - smartctl.h
import smartmontools 7.0
[mirror_smartmontools-debian.git] / smartctl.h
CommitLineData
832b75ed
GG
1/*
2 * smartctl.h
3 *
a86ec89e 4 * Home page of code is: http://www.smartmontools.org
832b75ed 5 *
f9e10201 6 * Copyright (C) 2002-10 Bruce Allen
ff28b140 7 * Copyright (C) 2008-17 Christian Franke
832b75ed
GG
8 * Copyright (C) 2000 Michael Cornwell <cornwell@acm.org>
9 *
ff28b140 10 * SPDX-License-Identifier: GPL-2.0-or-later
832b75ed
GG
11 */
12
13#ifndef SMARTCTL_H_
14#define SMARTCTL_H_
15
ff28b140 16#define SMARTCTL_H_CVSID "$Id: smartctl.h 4842 2018-12-02 16:07:26Z chrfranke $\n"
832b75ed
GG
17
18// Return codes (bitmask)
19
ff28b140 20// command line did not parse, or internal error occurred in smartctl
832b75ed
GG
21#define FAILCMD (0x01<<0)
22
23// device open failed
24#define FAILDEV (0x01<<1)
25
4d59bff9
GG
26// device is in low power mode and -n option requests to exit
27#define FAILPOWER (0x01<<1)
28
832b75ed
GG
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.
cfbba5b9
GI
56enum failure_type {
57 OPTIONAL_CMD,
58 MANDATORY_CMD,
59};
60
61// Globals to set failuretest() policy
62extern bool failuretest_conservative;
63extern unsigned char failuretest_permissive;
64
65// Compares failure type to policy in effect, and either exits or
66// simply returns to the calling routine.
67void failuretest(failure_type type, int returnvalue);
68
69// Globals to control printing
70extern bool printing_is_switchable;
71extern bool printing_is_off;
72
73// Printing control functions
74inline void print_on()
75{
76 if (printing_is_switchable)
77 printing_is_off = false;
78}
79inline void print_off()
80{
81 if (printing_is_switchable)
82 printing_is_off = true;
83}
832b75ed 84
ff28b140
TL
85// The singleton global JSON object
86#include "json.h"
87extern 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
93void jout(const char *fmt, ...)
94 __attribute_format_printf(1, 2);
95// Version of pout() for info/warning/error messages
96void jinf(const char *fmt, ...)
97 __attribute_format_printf(1, 2);
98void jwrn(const char *fmt, ...)
99__attribute_format_printf(1, 2);
100void jerr(const char *fmt, ...)
101__attribute_format_printf(1, 2);
102
832b75ed 103#endif