pacemaker  2.0.3-4b1f869f0f
Scalable High-Availability cluster resource manager
results.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012-2019 the Pacemaker project contributors
3  *
4  * The version control history for this file may have further details.
5  *
6  * This source code is licensed under the GNU Lesser General Public License
7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
8  */
9 #ifndef CRM_RESULTS__H
10 # define CRM_RESULTS__H
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
22 // Lifted from config.h
23 /* The _Noreturn keyword of C11. */
24 #ifndef _Noreturn
25 # if (defined __cplusplus \
26  && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
27  || (defined _MSC_VER && 1900 <= _MSC_VER)))
28 # define _Noreturn [[noreturn]]
29 # elif ((!defined __cplusplus || defined __clang__) \
30  && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
31  || 4 < __GNUC__ + (7 <= __GNUC_MINOR__)))
32  /* _Noreturn works as-is. */
33 # elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C
34 # define _Noreturn __attribute__ ((__noreturn__))
35 # elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
36 # define _Noreturn __declspec (noreturn)
37 # else
38 # define _Noreturn
39 # endif
40 #endif
41 
42 # define CRM_ASSERT(expr) do { \
43  if(__unlikely((expr) == FALSE)) { \
44  crm_abort(__FILE__, __FUNCTION__, __LINE__, #expr, TRUE, FALSE); \
45  abort(); /* Redundant but it makes static analyzers happy */ \
46  } \
47  } while(0)
48 
49 /*
50  * Function return codes
51  *
52  * For system error codes, see:
53  * - /usr/include/asm-generic/errno.h
54  * - /usr/include/asm-generic/errno-base.h
55  */
56 
57 # define pcmk_ok 0
58 # define PCMK_ERROR_OFFSET 190 /* Replacements on non-linux systems, see include/portability.h */
59 # define PCMK_CUSTOM_OFFSET 200 /* Purely custom codes */
60 # define pcmk_err_generic 201
61 # define pcmk_err_no_quorum 202
62 # define pcmk_err_schema_validation 203
63 # define pcmk_err_transform_failed 204
64 # define pcmk_err_old_data 205
65 # define pcmk_err_diff_failed 206
66 # define pcmk_err_diff_resync 207
67 # define pcmk_err_cib_modified 208
68 # define pcmk_err_cib_backup 209
69 # define pcmk_err_cib_save 210
70 # define pcmk_err_schema_unchanged 211
71 # define pcmk_err_cib_corrupt 212
72 # define pcmk_err_multiple 213
73 # define pcmk_err_node_unknown 214
74 # define pcmk_err_already 215
75 /* On HPPA 215 is ENOSYM (Unknown error 215), which hopefully never happens. */
76 #ifdef __hppa__
77 # define pcmk_err_bad_nvpair 250 /* 216 is ENOTSOCK */
78 # define pcmk_err_unknown_format 252 /* 217 is EDESTADDRREQ */
79 #else
80 # define pcmk_err_bad_nvpair 216
81 # define pcmk_err_unknown_format 217
82 #endif
83 
84 /*
85  * Exit status codes
86  *
87  * We want well-specified (i.e. OS-invariant) exit status codes for our daemons
88  * and applications so they can be relied on by callers. (Function return codes
89  * and errno's do not make good exit statuses.)
90  *
91  * The only hard rule is that exit statuses must be between 0 and 255; all else
92  * is convention. Universally, 0 is success, and 1 is generic error (excluding
93  * OSes we don't support -- for example, OpenVMS considers 1 success!).
94  *
95  * For init scripts, the LSB gives meaning to 0-7, and sets aside 150-199 for
96  * application use. OCF adds 8-9 and 189-199.
97  *
98  * sysexits.h was an attempt to give additional meanings, but never really
99  * caught on. It uses 0 and 64-78.
100  *
101  * Bash reserves 2 ("incorrect builtin usage") and 126-255 (126 is "command
102  * found but not executable", 127 is "command not found", 128 + n is
103  * "interrupted by signal n").
104  *
105  * tldp.org recommends 64-113 for application use.
106  *
107  * We try to overlap with the above conventions when practical.
108  */
109 typedef enum crm_exit_e {
110  // Common convention
113 
114  // LSB + OCF
121 
122  // sysexits.h
123  CRM_EX_USAGE = 64, // command line usage error
124  CRM_EX_DATAERR = 65, // user-supplied data incorrect
125  CRM_EX_NOINPUT = 66, // input file not available
126  CRM_EX_NOUSER = 67, // user does not exist
127  CRM_EX_NOHOST = 68, // host unknown
128  CRM_EX_UNAVAILABLE = 69, // needed service unavailable
129  CRM_EX_SOFTWARE = 70, // internal software bug
130  CRM_EX_OSERR = 71, // external (OS/environmental) problem
131  CRM_EX_OSFILE = 72, // system file not usable
132  CRM_EX_CANTCREAT = 73, // file couldn't be created
133  CRM_EX_IOERR = 74, // file I/O error
134  CRM_EX_TEMPFAIL = 75, // try again
135  CRM_EX_PROTOCOL = 76, // protocol violated
136  CRM_EX_NOPERM = 77, // non-file permission issue
137  CRM_EX_CONFIG = 78, // misconfiguration
138 
139  // Custom
140  CRM_EX_FATAL = 100, // do not respawn
141  CRM_EX_PANIC = 101, // panic the local host
142  CRM_EX_DISCONNECT = 102, // lost connection to something
143  CRM_EX_OLD = 103, // update older than existing config
144  CRM_EX_DIGEST = 104, // digest comparison failed
145  CRM_EX_NOSUCH = 105, // requested item does not exist
146  CRM_EX_QUORUM = 106, // local partition does not have quorum
147  CRM_EX_UNSAFE = 107, // requires --force or new conditions
148  CRM_EX_EXISTS = 108, // requested item already exists
149  CRM_EX_MULTIPLE = 109, // requested item has multiple matches
150  CRM_EX_EXPIRED = 110, // requested item has expired
151  CRM_EX_NOT_YET_IN_EFFECT = 111, // requested item is not in effect
152  CRM_EX_INDETERMINATE = 112, // could not determine status
153 
154  // Other
155  CRM_EX_TIMEOUT = 124, // convention from timeout(1)
156  CRM_EX_MAX = 255, // ensure crm_exit_t can hold this
157 } crm_exit_t;
158 
159 const char *pcmk_strerror(int rc);
160 const char *pcmk_errorname(int rc);
161 const char *bz2_strerror(int rc);
162 crm_exit_t crm_errno2exit(int rc);
163 const char *crm_exit_name(crm_exit_t exit_code);
164 const char *crm_exit_str(crm_exit_t exit_code);
166 
167 #ifdef __cplusplus
168 }
169 #endif
170 
171 #endif
CRM_EX_TEMPFAIL
Definition: results.h:134
CRM_EX_OK
Definition: results.h:111
CRM_EX_CONFIG
Definition: results.h:137
CRM_EX_INSUFFICIENT_PRIV
Definition: results.h:117
CRM_EX_ERROR
Definition: results.h:112
CRM_EX_UNIMPLEMENT_FEATURE
Definition: results.h:116
crm_exit_name
const char * crm_exit_name(crm_exit_t exit_code)
Definition: results.c:262
CRM_EX_UNAVAILABLE
Definition: results.h:128
pcmk_strerror
const char * pcmk_strerror(int rc)
Definition: results.c:188
CRM_EX_EXPIRED
Definition: results.h:150
crm_exit_t
enum crm_exit_e crm_exit_t
CRM_EX_EXISTS
Definition: results.h:148
CRM_EX_OSERR
Definition: results.h:130
CRM_EX_NOINPUT
Definition: results.h:125
CRM_EX_UNSAFE
Definition: results.h:147
CRM_EX_NOHOST
Definition: results.h:127
CRM_EX_INDETERMINATE
Definition: results.h:152
CRM_EX_PANIC
Definition: results.h:141
crm_exit_str
const char * crm_exit_str(crm_exit_t exit_code)
Definition: results.c:308
CRM_EX_NOT_YET_IN_EFFECT
Definition: results.h:151
CRM_EX_NOPERM
Definition: results.h:136
CRM_EX_DIGEST
Definition: results.h:144
CRM_EX_SOFTWARE
Definition: results.h:129
CRM_EX_PROTOCOL
Definition: results.h:135
CRM_EX_IOERR
Definition: results.h:133
CRM_EX_NOT_INSTALLED
Definition: results.h:118
CRM_EX_TIMEOUT
Definition: results.h:155
CRM_EX_MAX
Definition: results.h:156
_Noreturn
#define _Noreturn
Definition: results.h:38
CRM_EX_NOUSER
Definition: results.h:126
CRM_EX_MULTIPLE
Definition: results.h:149
CRM_EX_INVALID_PARAM
Definition: results.h:115
CRM_EX_CANTCREAT
Definition: results.h:132
CRM_EX_NOT_CONFIGURED
Definition: results.h:119
CRM_EX_OSFILE
Definition: results.h:131
CRM_EX_NOT_RUNNING
Definition: results.h:120
CRM_EX_DATAERR
Definition: results.h:124
CRM_EX_OLD
Definition: results.h:143
pcmk_errorname
const char * pcmk_errorname(int rc)
Definition: results.c:26
crm_exit_e
crm_exit_e
Definition: results.h:109
crm_errno2exit
crm_exit_t crm_errno2exit(int rc)
Map an errno to a similar exit status.
Definition: results.c:364
CRM_EX_QUORUM
Definition: results.h:146
crm_exit
_Noreturn crm_exit_t crm_exit(crm_exit_t rc)
Definition: results.c:478
CRM_EX_NOSUCH
Definition: results.h:145
CRM_EX_USAGE
Definition: results.h:123
bz2_strerror
const char * bz2_strerror(int rc)
Definition: results.c:445
CRM_EX_DISCONNECT
Definition: results.h:142
CRM_EX_FATAL
Definition: results.h:140