pacemaker  2.0.4-2deceaa
Scalable High-Availability cluster resource manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
results.c
Go to the documentation of this file.
1 /*
2  * Copyright 2004-2020 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 
10 #include <crm_internal.h>
11 
12 #ifndef _GNU_SOURCE
13 # define _GNU_SOURCE
14 #endif
15 
16 #include <bzlib.h>
17 #include <errno.h>
18 #include <stdlib.h>
19 #include <string.h>
20 #include <qb/qbdefs.h>
21 
22 #include <crm/common/mainloop.h>
23 #include <crm/common/xml.h>
24 
25 // @COMPAT Legacy function return codes
26 
28 const char *
30 {
31  rc = abs(rc);
32  switch (rc) {
33  case pcmk_err_generic: return "pcmk_err_generic";
34  case pcmk_err_no_quorum: return "pcmk_err_no_quorum";
35  case pcmk_err_schema_validation: return "pcmk_err_schema_validation";
36  case pcmk_err_transform_failed: return "pcmk_err_transform_failed";
37  case pcmk_err_old_data: return "pcmk_err_old_data";
38  case pcmk_err_diff_failed: return "pcmk_err_diff_failed";
39  case pcmk_err_diff_resync: return "pcmk_err_diff_resync";
40  case pcmk_err_cib_modified: return "pcmk_err_cib_modified";
41  case pcmk_err_cib_backup: return "pcmk_err_cib_backup";
42  case pcmk_err_cib_save: return "pcmk_err_cib_save";
43  case pcmk_err_cib_corrupt: return "pcmk_err_cib_corrupt";
44  case pcmk_err_multiple: return "pcmk_err_multiple";
45  case pcmk_err_node_unknown: return "pcmk_err_node_unknown";
46  case pcmk_err_already: return "pcmk_err_already";
47  case pcmk_err_bad_nvpair: return "pcmk_err_bad_nvpair";
48  case pcmk_err_unknown_format: return "pcmk_err_unknown_format";
49  default: return pcmk_rc_name(rc); // system errno
50  }
51 }
52 
54 const char *
56 {
57  if (rc == 0) {
58  return "OK";
59  }
60 
61  rc = abs(rc);
62 
63  // Of course rc > 0 ... unless someone passed INT_MIN as rc
64  if ((rc > 0) && (rc < PCMK_ERROR_OFFSET)) {
65  return strerror(rc);
66  }
67 
68  switch (rc) {
69  case pcmk_err_generic:
70  return "Generic Pacemaker error";
71  case pcmk_err_no_quorum:
72  return "Operation requires quorum";
74  return "Update does not conform to the configured schema";
76  return "Schema transform failed";
77  case pcmk_err_old_data:
78  return "Update was older than existing configuration";
80  return "Application of an update diff failed";
82  return "Application of an update diff failed, requesting a full refresh";
84  return "The on-disk configuration was manually modified";
86  return "Could not archive the previous configuration";
87  case pcmk_err_cib_save:
88  return "Could not save the new configuration to disk";
90  return "Could not parse on-disk configuration";
91  case pcmk_err_multiple:
92  return "Resource active on multiple nodes";
94  return "Node not found";
95  case pcmk_err_already:
96  return "Situation already as requested";
98  return "Bad name/value pair given";
100  return "Schema is already the latest available";
102  return "Unknown output format";
103 
104  /* The following cases will only be hit on systems for which they are non-standard */
105  /* coverity[dead_error_condition] False positive on non-Linux */
106  case ENOTUNIQ:
107  return "Name not unique on network";
108  /* coverity[dead_error_condition] False positive on non-Linux */
109  case ECOMM:
110  return "Communication error on send";
111  /* coverity[dead_error_condition] False positive on non-Linux */
112  case ELIBACC:
113  return "Can not access a needed shared library";
114  /* coverity[dead_error_condition] False positive on non-Linux */
115  case EREMOTEIO:
116  return "Remote I/O error";
117  /* coverity[dead_error_condition] False positive on non-Linux */
118  case EUNATCH:
119  return "Protocol driver not attached";
120  /* coverity[dead_error_condition] False positive on non-Linux */
121  case ENOKEY:
122  return "Required key not available";
123  }
124  crm_err("Unknown error code: %d", rc);
125  return "Unknown error";
126 }
127 
128 // Standard Pacemaker API return codes
129 
130 /* This array is used only for nonzero values of pcmk_rc_e. Its values must be
131  * kept in the exact reverse order of the enum value numbering (i.e. add new
132  * values to the end of the array).
133  */
134 static struct pcmk__rc_info {
135  const char *name;
136  const char *desc;
137  int legacy_rc;
138 } pcmk__rcs[] = {
139  { "pcmk_rc_error",
140  "Error",
142  },
143  { "pcmk_rc_unknown_format",
144  "Unknown output format",
146  },
147  { "pcmk_rc_bad_nvpair",
148  "Bad name/value pair given",
150  },
151  { "pcmk_rc_already",
152  "Already in requested state",
154  },
155  { "pcmk_rc_node_unknown",
156  "Node not found",
158  },
159  { "pcmk_rc_multiple",
160  "Resource active on multiple nodes",
162  },
163  { "pcmk_rc_cib_corrupt",
164  "Could not parse on-disk configuration",
166  },
167  { "pcmk_rc_cib_save",
168  "Could not save new configuration to disk",
170  },
171  { "pcmk_rc_cib_backup",
172  "Could not archive previous configuration",
174  },
175  { "pcmk_rc_cib_modified",
176  "On-disk configuration was manually modified",
178  },
179  { "pcmk_rc_diff_resync",
180  "Application of update diff failed, requesting full refresh",
182  },
183  { "pcmk_rc_diff_failed",
184  "Application of update diff failed",
186  },
187  { "pcmk_rc_old_data",
188  "Update was older than existing configuration",
190  },
191  { "pcmk_rc_transform_failed",
192  "Schema transform failed",
194  },
195  { "pcmk_rc_schema_unchanged",
196  "Schema is already the latest available",
198  },
199  { "pcmk_rc_schema_validation",
200  "Update does not conform to the configured schema",
202  },
203  { "pcmk_rc_no_quorum",
204  "Operation requires quorum",
206  },
207  { "pcmk_rc_ipc_pid_only",
208  "IPC server process is active but not accepting connections",
210  },
211  { "pcmk_rc_ipc_unresponsive",
212  "IPC server is unresponsive",
214  },
215  { "pcmk_rc_ipc_unauthorized",
216  "IPC server is blocked by unauthorized process",
218  },
219  { "pcmk_rc_op_unsatisifed",
220  "Not applicable under current conditions",
222  },
223  { "pcmk_rc_undetermined",
224  "Result undetermined",
226  },
227  { "pcmk_rc_before_range",
228  "Result occurs before given range",
230  },
231  { "pcmk_rc_within_range",
232  "Result occurs within given range",
234  },
235  { "pcmk_rc_after_range",
236  "Result occurs after given range",
238  },
239  { "pcmk_rc_no_output",
240  "Output message produced no output",
242  },
243  { "pcmk_rc_no_input",
244  "Input file not available",
246  }
247 };
248 
249 #define PCMK__N_RC (sizeof(pcmk__rcs) / sizeof(struct pcmk__rc_info))
250 
258 const char *
260 {
261  if ((rc <= pcmk_rc_error) && ((pcmk_rc_error - rc) < PCMK__N_RC)) {
262  return pcmk__rcs[pcmk_rc_error - rc].name;
263  }
264  switch (rc) {
265  case pcmk_rc_ok: return "pcmk_rc_ok";
266  case E2BIG: return "E2BIG";
267  case EACCES: return "EACCES";
268  case EADDRINUSE: return "EADDRINUSE";
269  case EADDRNOTAVAIL: return "EADDRNOTAVAIL";
270  case EAFNOSUPPORT: return "EAFNOSUPPORT";
271  case EAGAIN: return "EAGAIN";
272  case EALREADY: return "EALREADY";
273  case EBADF: return "EBADF";
274  case EBADMSG: return "EBADMSG";
275  case EBUSY: return "EBUSY";
276  case ECANCELED: return "ECANCELED";
277  case ECHILD: return "ECHILD";
278  case ECOMM: return "ECOMM";
279  case ECONNABORTED: return "ECONNABORTED";
280  case ECONNREFUSED: return "ECONNREFUSED";
281  case ECONNRESET: return "ECONNRESET";
282  /* case EDEADLK: return "EDEADLK"; */
283  case EDESTADDRREQ: return "EDESTADDRREQ";
284  case EDOM: return "EDOM";
285  case EDQUOT: return "EDQUOT";
286  case EEXIST: return "EEXIST";
287  case EFAULT: return "EFAULT";
288  case EFBIG: return "EFBIG";
289  case EHOSTDOWN: return "EHOSTDOWN";
290  case EHOSTUNREACH: return "EHOSTUNREACH";
291  case EIDRM: return "EIDRM";
292  case EILSEQ: return "EILSEQ";
293  case EINPROGRESS: return "EINPROGRESS";
294  case EINTR: return "EINTR";
295  case EINVAL: return "EINVAL";
296  case EIO: return "EIO";
297  case EISCONN: return "EISCONN";
298  case EISDIR: return "EISDIR";
299  case ELIBACC: return "ELIBACC";
300  case ELOOP: return "ELOOP";
301  case EMFILE: return "EMFILE";
302  case EMLINK: return "EMLINK";
303  case EMSGSIZE: return "EMSGSIZE";
304 #ifdef EMULTIHOP // Not available on OpenBSD
305  case EMULTIHOP: return "EMULTIHOP";
306 #endif
307  case ENAMETOOLONG: return "ENAMETOOLONG";
308  case ENETDOWN: return "ENETDOWN";
309  case ENETRESET: return "ENETRESET";
310  case ENETUNREACH: return "ENETUNREACH";
311  case ENFILE: return "ENFILE";
312  case ENOBUFS: return "ENOBUFS";
313  case ENODATA: return "ENODATA";
314  case ENODEV: return "ENODEV";
315  case ENOENT: return "ENOENT";
316  case ENOEXEC: return "ENOEXEC";
317  case ENOKEY: return "ENOKEY";
318  case ENOLCK: return "ENOLCK";
319 #ifdef ENOLINK // Not available on OpenBSD
320  case ENOLINK: return "ENOLINK";
321 #endif
322  case ENOMEM: return "ENOMEM";
323  case ENOMSG: return "ENOMSG";
324  case ENOPROTOOPT: return "ENOPROTOOPT";
325  case ENOSPC: return "ENOSPC";
326  case ENOSR: return "ENOSR";
327  case ENOSTR: return "ENOSTR";
328  case ENOSYS: return "ENOSYS";
329  case ENOTBLK: return "ENOTBLK";
330  case ENOTCONN: return "ENOTCONN";
331  case ENOTDIR: return "ENOTDIR";
332  case ENOTEMPTY: return "ENOTEMPTY";
333  case ENOTSOCK: return "ENOTSOCK";
334 #if ENOTSUP != EOPNOTSUPP
335  case ENOTSUP: return "ENOTSUP";
336 #endif
337  case ENOTTY: return "ENOTTY";
338  case ENOTUNIQ: return "ENOTUNIQ";
339  case ENXIO: return "ENXIO";
340  case EOPNOTSUPP: return "EOPNOTSUPP";
341  case EOVERFLOW: return "EOVERFLOW";
342  case EPERM: return "EPERM";
343  case EPFNOSUPPORT: return "EPFNOSUPPORT";
344  case EPIPE: return "EPIPE";
345  case EPROTO: return "EPROTO";
346  case EPROTONOSUPPORT: return "EPROTONOSUPPORT";
347  case EPROTOTYPE: return "EPROTOTYPE";
348  case ERANGE: return "ERANGE";
349  case EREMOTE: return "EREMOTE";
350  case EREMOTEIO: return "EREMOTEIO";
351  case EROFS: return "EROFS";
352  case ESHUTDOWN: return "ESHUTDOWN";
353  case ESPIPE: return "ESPIPE";
354  case ESOCKTNOSUPPORT: return "ESOCKTNOSUPPORT";
355  case ESRCH: return "ESRCH";
356  case ESTALE: return "ESTALE";
357  case ETIME: return "ETIME";
358  case ETIMEDOUT: return "ETIMEDOUT";
359  case ETXTBSY: return "ETXTBSY";
360  case EUNATCH: return "EUNATCH";
361  case EUSERS: return "EUSERS";
362  /* case EWOULDBLOCK: return "EWOULDBLOCK"; */
363  case EXDEV: return "EXDEV";
364 
365 #ifdef EBADE // Not available on OS X
366  case EBADE: return "EBADE";
367  case EBADFD: return "EBADFD";
368  case EBADSLT: return "EBADSLT";
369  case EDEADLOCK: return "EDEADLOCK";
370  case EBADR: return "EBADR";
371  case EBADRQC: return "EBADRQC";
372  case ECHRNG: return "ECHRNG";
373 #ifdef EISNAM // Not available on OS X, Illumos, Solaris
374  case EISNAM: return "EISNAM";
375  case EKEYEXPIRED: return "EKEYEXPIRED";
376  case EKEYREJECTED: return "EKEYREJECTED";
377  case EKEYREVOKED: return "EKEYREVOKED";
378 #endif
379  case EL2HLT: return "EL2HLT";
380  case EL2NSYNC: return "EL2NSYNC";
381  case EL3HLT: return "EL3HLT";
382  case EL3RST: return "EL3RST";
383  case ELIBBAD: return "ELIBBAD";
384  case ELIBMAX: return "ELIBMAX";
385  case ELIBSCN: return "ELIBSCN";
386  case ELIBEXEC: return "ELIBEXEC";
387 #ifdef ENOMEDIUM // Not available on OS X, Illumos, Solaris
388  case ENOMEDIUM: return "ENOMEDIUM";
389  case EMEDIUMTYPE: return "EMEDIUMTYPE";
390 #endif
391  case ENONET: return "ENONET";
392  case ENOPKG: return "ENOPKG";
393  case EREMCHG: return "EREMCHG";
394  case ERESTART: return "ERESTART";
395  case ESTRPIPE: return "ESTRPIPE";
396 #ifdef EUCLEAN // Not available on OS X, Illumos, Solaris
397  case EUCLEAN: return "EUCLEAN";
398 #endif
399  case EXFULL: return "EXFULL";
400 #endif // EBADE
401  default: return "Unknown";
402  }
403 }
404 
412 const char *
414 {
415  if (rc == pcmk_rc_ok) {
416  return "OK";
417  }
418  if ((rc <= pcmk_rc_error) && ((pcmk_rc_error - rc) < PCMK__N_RC)) {
419  return pcmk__rcs[pcmk_rc_error - rc].desc;
420  }
421  if (rc < 0) {
422  return "Unknown error";
423  }
424  return strerror(rc);
425 }
426 
427 // This returns negative values for errors
429 int
431 {
432  if (rc >= 0) {
433  return -rc; // OK or system errno
434  }
435  if ((rc <= pcmk_rc_error) && ((pcmk_rc_error - rc) < PCMK__N_RC)) {
436  return pcmk__rcs[pcmk_rc_error - rc].legacy_rc;
437  }
438  return -pcmk_err_generic;
439 }
440 
442 int
443 pcmk_legacy2rc(int legacy_rc)
444 {
445  legacy_rc = abs(legacy_rc);
446  switch (legacy_rc) {
451  case pcmk_err_old_data: return pcmk_rc_old_data;
456  case pcmk_err_cib_save: return pcmk_rc_cib_save;
458  case pcmk_err_multiple: return pcmk_rc_multiple;
460  case pcmk_err_already: return pcmk_rc_already;
463  case pcmk_err_generic: return pcmk_rc_error;
464  case pcmk_ok: return pcmk_rc_ok;
465  default: return legacy_rc; // system errno
466  }
467 }
468 
469 // Exit status codes
470 
471 const char *
473 {
474  switch (exit_code) {
475  case CRM_EX_OK: return "CRM_EX_OK";
476  case CRM_EX_ERROR: return "CRM_EX_ERROR";
477  case CRM_EX_INVALID_PARAM: return "CRM_EX_INVALID_PARAM";
478  case CRM_EX_UNIMPLEMENT_FEATURE: return "CRM_EX_UNIMPLEMENT_FEATURE";
479  case CRM_EX_INSUFFICIENT_PRIV: return "CRM_EX_INSUFFICIENT_PRIV";
480  case CRM_EX_NOT_INSTALLED: return "CRM_EX_NOT_INSTALLED";
481  case CRM_EX_NOT_CONFIGURED: return "CRM_EX_NOT_CONFIGURED";
482  case CRM_EX_NOT_RUNNING: return "CRM_EX_NOT_RUNNING";
483  case CRM_EX_USAGE: return "CRM_EX_USAGE";
484  case CRM_EX_DATAERR: return "CRM_EX_DATAERR";
485  case CRM_EX_NOINPUT: return "CRM_EX_NOINPUT";
486  case CRM_EX_NOUSER: return "CRM_EX_NOUSER";
487  case CRM_EX_NOHOST: return "CRM_EX_NOHOST";
488  case CRM_EX_UNAVAILABLE: return "CRM_EX_UNAVAILABLE";
489  case CRM_EX_SOFTWARE: return "CRM_EX_SOFTWARE";
490  case CRM_EX_OSERR: return "CRM_EX_OSERR";
491  case CRM_EX_OSFILE: return "CRM_EX_OSFILE";
492  case CRM_EX_CANTCREAT: return "CRM_EX_CANTCREAT";
493  case CRM_EX_IOERR: return "CRM_EX_IOERR";
494  case CRM_EX_TEMPFAIL: return "CRM_EX_TEMPFAIL";
495  case CRM_EX_PROTOCOL: return "CRM_EX_PROTOCOL";
496  case CRM_EX_NOPERM: return "CRM_EX_NOPERM";
497  case CRM_EX_CONFIG: return "CRM_EX_CONFIG";
498  case CRM_EX_FATAL: return "CRM_EX_FATAL";
499  case CRM_EX_PANIC: return "CRM_EX_PANIC";
500  case CRM_EX_DISCONNECT: return "CRM_EX_DISCONNECT";
501  case CRM_EX_DIGEST: return "CRM_EX_DIGEST";
502  case CRM_EX_NOSUCH: return "CRM_EX_NOSUCH";
503  case CRM_EX_QUORUM: return "CRM_EX_QUORUM";
504  case CRM_EX_UNSAFE: return "CRM_EX_UNSAFE";
505  case CRM_EX_EXISTS: return "CRM_EX_EXISTS";
506  case CRM_EX_MULTIPLE: return "CRM_EX_MULTIPLE";
507  case CRM_EX_EXPIRED: return "CRM_EX_EXPIRED";
508  case CRM_EX_NOT_YET_IN_EFFECT: return "CRM_EX_NOT_YET_IN_EFFECT";
509  case CRM_EX_INDETERMINATE: return "CRM_EX_INDETERMINATE";
510  case CRM_EX_UNSATISFIED: return "CRM_EX_UNSATISFIED";
511  case CRM_EX_OLD: return "CRM_EX_OLD";
512  case CRM_EX_TIMEOUT: return "CRM_EX_TIMEOUT";
513  case CRM_EX_MAX: return "CRM_EX_UNKNOWN";
514  }
515  return "CRM_EX_UNKNOWN";
516 }
517 
518 const char *
520 {
521  switch (exit_code) {
522  case CRM_EX_OK: return "OK";
523  case CRM_EX_ERROR: return "Error occurred";
524  case CRM_EX_INVALID_PARAM: return "Invalid parameter";
525  case CRM_EX_UNIMPLEMENT_FEATURE: return "Unimplemented";
526  case CRM_EX_INSUFFICIENT_PRIV: return "Insufficient privileges";
527  case CRM_EX_NOT_INSTALLED: return "Not installed";
528  case CRM_EX_NOT_CONFIGURED: return "Not configured";
529  case CRM_EX_NOT_RUNNING: return "Not running";
530  case CRM_EX_USAGE: return "Incorrect usage";
531  case CRM_EX_DATAERR: return "Invalid data given";
532  case CRM_EX_NOINPUT: return "Input file not available";
533  case CRM_EX_NOUSER: return "User does not exist";
534  case CRM_EX_NOHOST: return "Host does not exist";
535  case CRM_EX_UNAVAILABLE: return "Necessary service unavailable";
536  case CRM_EX_SOFTWARE: return "Internal software bug";
537  case CRM_EX_OSERR: return "Operating system error occurred";
538  case CRM_EX_OSFILE: return "System file not available";
539  case CRM_EX_CANTCREAT: return "Cannot create output file";
540  case CRM_EX_IOERR: return "I/O error occurred";
541  case CRM_EX_TEMPFAIL: return "Temporary failure, try again";
542  case CRM_EX_PROTOCOL: return "Protocol violated";
543  case CRM_EX_NOPERM: return "Insufficient privileges";
544  case CRM_EX_CONFIG: return "Invalid configuration";
545  case CRM_EX_FATAL: return "Fatal error occurred, will not respawn";
546  case CRM_EX_PANIC: return "System panic required";
547  case CRM_EX_DISCONNECT: return "Not connected";
548  case CRM_EX_DIGEST: return "Digest mismatch";
549  case CRM_EX_NOSUCH: return "No such object";
550  case CRM_EX_QUORUM: return "Quorum required";
551  case CRM_EX_UNSAFE: return "Operation not safe";
552  case CRM_EX_EXISTS: return "Requested item already exists";
553  case CRM_EX_MULTIPLE: return "Multiple items match request";
554  case CRM_EX_EXPIRED: return "Requested item has expired";
555  case CRM_EX_NOT_YET_IN_EFFECT: return "Requested item is not yet in effect";
556  case CRM_EX_INDETERMINATE: return "Could not determine status";
557  case CRM_EX_UNSATISFIED: return "Not applicable under current conditions";
558  case CRM_EX_OLD: return "Update was older than existing configuration";
559  case CRM_EX_TIMEOUT: return "Timeout occurred";
560  case CRM_EX_MAX: return "Error occurred";
561  }
562  if ((exit_code > 128) && (exit_code < CRM_EX_MAX)) {
563  return "Interrupted by signal";
564  }
565  return "Unknown exit status";
566 }
567 
571 {
572  rc = abs(rc); // Convenience for functions that return -errno
573  switch (rc) {
574  case pcmk_ok:
575  return CRM_EX_OK;
576 
577  case pcmk_err_no_quorum:
578  return CRM_EX_QUORUM;
579 
580  case pcmk_err_old_data:
581  return CRM_EX_OLD;
582 
585  return CRM_EX_CONFIG;
586 
587  case pcmk_err_bad_nvpair:
588  return CRM_EX_INVALID_PARAM;
589 
590  case pcmk_err_already:
591  return CRM_EX_EXISTS;
592 
593  case pcmk_err_multiple:
594  return CRM_EX_MULTIPLE;
595 
598  return CRM_EX_NOSUCH;
599 
600  default:
601  return pcmk_rc2exitc(rc); // system errno
602  }
603 }
604 
614 {
615  switch (rc) {
616  case pcmk_rc_ok:
617  return CRM_EX_OK;
618 
619  case pcmk_rc_no_quorum:
620  return CRM_EX_QUORUM;
621 
622  case pcmk_rc_old_data:
623  return CRM_EX_OLD;
624 
627  return CRM_EX_CONFIG;
628 
629  case pcmk_rc_bad_nvpair:
630  return CRM_EX_INVALID_PARAM;
631 
632  case EACCES:
634 
635  case EBADF:
636  case EINVAL:
637  case EFAULT:
638  case ENOSYS:
639  case EOVERFLOW:
640  return CRM_EX_SOFTWARE;
641 
642  case EBADMSG:
643  case EMSGSIZE:
644  case ENOMSG:
645  case ENOPROTOOPT:
646  case EPROTO:
647  case EPROTONOSUPPORT:
648  case EPROTOTYPE:
649  return CRM_EX_PROTOCOL;
650 
651  case ECOMM:
652  case ENOMEM:
653  return CRM_EX_OSERR;
654 
655  case ECONNABORTED:
656  case ECONNREFUSED:
657  case ECONNRESET:
658  case ENOTCONN:
659  return CRM_EX_DISCONNECT;
660 
661  case EEXIST:
662  case pcmk_rc_already:
663  return CRM_EX_EXISTS;
664 
665  case EIO:
666  case pcmk_rc_no_output:
667  return CRM_EX_IOERR;
668 
669  case ENOTSUP:
670 #if EOPNOTSUPP != ENOTSUP
671  case EOPNOTSUPP:
672 #endif
674 
675  case ENOTUNIQ:
676  case pcmk_rc_multiple:
677  return CRM_EX_MULTIPLE;
678 
679  case ENXIO:
682  return CRM_EX_NOSUCH;
683 
684  case ETIME:
685  case ETIMEDOUT:
686  return CRM_EX_TIMEOUT;
687 
688  case EAGAIN:
689  case EBUSY:
690  return CRM_EX_UNSATISFIED;
691 
694 
695  case pcmk_rc_after_range:
696  return CRM_EX_EXPIRED;
697 
699  return CRM_EX_INDETERMINATE;
700 
702  return CRM_EX_UNSATISFIED;
703 
705  return CRM_EX_OK;
706 
707  case pcmk_rc_no_input:
708  return CRM_EX_NOINPUT;
709 
710  default:
711  return CRM_EX_ERROR;
712  }
713 }
714 
715 // Other functions
716 
717 const char *
719 {
720  // See ftp://sources.redhat.com/pub/bzip2/docs/manual_3.html#SEC17
721  switch (rc) {
722  case BZ_OK:
723  case BZ_RUN_OK:
724  case BZ_FLUSH_OK:
725  case BZ_FINISH_OK:
726  case BZ_STREAM_END:
727  return "Ok";
728  case BZ_CONFIG_ERROR:
729  return "libbz2 has been improperly compiled on your platform";
730  case BZ_SEQUENCE_ERROR:
731  return "library functions called in the wrong order";
732  case BZ_PARAM_ERROR:
733  return "parameter is out of range or otherwise incorrect";
734  case BZ_MEM_ERROR:
735  return "memory allocation failed";
736  case BZ_DATA_ERROR:
737  return "data integrity error is detected during decompression";
738  case BZ_DATA_ERROR_MAGIC:
739  return "the compressed stream does not start with the correct magic bytes";
740  case BZ_IO_ERROR:
741  return "error reading or writing in the compressed file";
742  case BZ_UNEXPECTED_EOF:
743  return "compressed file finishes before the logical end of stream is detected";
744  case BZ_OUTBUFF_FULL:
745  return "output data will not fit into the buffer provided";
746  }
747  return "Unknown error";
748 }
749 
752 {
753  /* A compiler could theoretically use any type for crm_exit_t, but an int
754  * should always hold it, so cast to int to keep static analysis happy.
755  */
756  if ((((int) rc) < 0) || (((int) rc) > CRM_EX_MAX)) {
757  rc = CRM_EX_ERROR;
758  }
759 
761  crm_xml_cleanup();
762 
764 
765  if (crm_system_name) {
766  crm_info("Exiting %s " CRM_XS " with status %d", crm_system_name, rc);
767  free(crm_system_name);
768  } else {
769  crm_trace("Exiting with status %d", rc);
770  }
771  qb_log_fini(); // Don't log anything after this point
772 
773  exit(rc);
774 }
#define pcmk_err_old_data
Definition: results.h:74
#define pcmk_err_schema_validation
Definition: results.h:72
const char * pcmk_errorname(int rc)
Definition: results.c:29
#define pcmk_err_already
Definition: results.h:84
crm_exit_t crm_errno2exit(int rc)
Definition: results.c:570
const char * pcmk_strerror(int rc)
Definition: results.c:55
#define ETIME
Definition: portability.h:162
const char * bz2_strerror(int rc)
Definition: results.c:718
#define pcmk_err_no_quorum
Definition: results.h:71
#define pcmk_err_schema_unchanged
Definition: results.h:80
int pcmk_rc2legacy(int rc)
Definition: results.c:430
_Noreturn crm_exit_t crm_exit(crm_exit_t rc)
Definition: results.c:751
#define ENOSTR
Definition: portability.h:170
void crm_xml_cleanup(void)
Definition: xml.c:4462
#define EKEYREJECTED
Definition: portability.h:174
#define pcmk_err_transform_failed
Definition: results.h:73
crm_exit_t pcmk_rc2exitc(int rc)
Map a function return code to the most similar exit code.
Definition: results.c:613
#define EREMOTEIO
Definition: portability.h:146
#define pcmk_err_node_unknown
Definition: results.h:83
#define pcmk_err_generic
Definition: results.h:70
void mainloop_cleanup(void)
Definition: mainloop.c:402
char * crm_system_name
Definition: utils.c:52
enum crm_exit_e crm_exit_t
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code.
Definition: results.c:413
char * strerror(int errnum)
#define pcmk_err_cib_backup
Definition: results.h:78
Wrappers for and extensions to glib mainloop.
#define pcmk_err_cib_save
Definition: results.h:79
#define pcmk_err_diff_failed
Definition: results.h:75
const char * crm_exit_str(crm_exit_t exit_code)
Definition: results.c:519
int rc
Definition: pcmk_fence.c:34
#define PCMK_ERROR_OFFSET
Definition: results.h:68
#define pcmk_err_multiple
Definition: results.h:82
#define crm_trace(fmt, args...)
Definition: logging.h:369
Wrappers for and extensions to libxml2.
#define ECOMM
Definition: portability.h:138
int pcmk_legacy2rc(int legacy_rc)
Definition: results.c:443
#define pcmk_err_cib_modified
Definition: results.h:77
#define ENOSR
Definition: portability.h:166
#define ENOKEY
Definition: portability.h:154
#define CRM_XS
Definition: logging.h:54
#define ELIBACC
Definition: portability.h:142
#define EUNATCH
Definition: portability.h:150
#define ENODATA
Definition: portability.h:158
#define pcmk_err_diff_resync
Definition: results.h:76
void pcmk__cli_option_cleanup(void)
Definition: options.c:39
const char * pcmk_rc_name(int rc)
Get a return code constant name as a string.
Definition: results.c:259
#define crm_err(fmt, args...)
Definition: logging.h:363
#define pcmk_err_unknown_format
Definition: results.h:91
#define ENOTUNIQ
Definition: portability.h:134
#define pcmk_ok
Definition: results.h:67
#define PCMK__N_RC
Definition: results.c:249
char * name
Definition: pcmk_fence.c:30
#define pcmk_err_bad_nvpair
Definition: results.h:90
#define pcmk_err_cib_corrupt
Definition: results.h:81
#define crm_info(fmt, args...)
Definition: logging.h:366
const char * crm_exit_name(crm_exit_t exit_code)
Definition: results.c:472