smartmontools SVN Rev 5611
Utility to control and monitor storage systems with "S.M.A.R.T."
smartctl.h
Go to the documentation of this file.
1/*
2 * smartctl.h
3 *
4 * Home page of code is: https://www.smartmontools.org
5 *
6 * Copyright (C) 2002-10 Bruce Allen
7 * Copyright (C) 2008-21 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 5200 2021-02-07 14:19:40Z 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.
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{
77 printing_is_off = false;
78}
79inline void print_off()
80{
82 printing_is_off = true;
83}
84
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, ...)
95// Version of pout() for info/warning/error messages
96void jinf(const char *fmt, ...)
98void jwrn(const char *fmt, ...)
100void jerr(const char *fmt, ...)
102
103// Print smartctl start-up date and time and timezone
104void jout_startup_datetime(const char *prefix);
105
106#endif
Create and print JSON output.
Definition: json.h:24
const char const char * fmt
Definition: smartctl.cpp:1324
bool failuretest_conservative
Definition: smartctl.cpp:1455
unsigned char failuretest_permissive
Definition: smartctl.cpp:1456
bool printing_is_off
Definition: smartctl.cpp:50
void void jinf(const char *fmt,...) __attribute_format_printf(1
json jglb
Definition: smartctl.cpp:53
void print_off()
Definition: smartctl.h:79
void failuretest(failure_type type, int returnvalue)
Definition: smartctl.cpp:1461
void void void jwrn(const char *fmt,...) __attribute_format_printf(1
void void void void jerr(const char *fmt,...) __attribute_format_printf(1
void jout(const char *fmt,...) __attribute_format_printf(1
void void void void void jout_startup_datetime(const char *prefix)
Definition: smartctl.cpp:1449
failure_type
Definition: smartctl.h:56
@ OPTIONAL_CMD
Definition: smartctl.h:57
@ MANDATORY_CMD
Definition: smartctl.h:58
bool printing_is_switchable
Definition: smartctl.cpp:49
void print_on()
Definition: smartctl.h:74
#define __attribute_format_printf(x, y)
Definition: utility.h:34