| 1 |
|
| 2 | |
| 3 | * Copyright 2023 Red Hat
|
| 4 |
|
| 5 |
|
| 6 | #ifndef UDS_ERRORS_H
|
| 7 | #define UDS_ERRORS_H
|
| 8 |
|
| 9 | #include <linux/compiler.h>
|
| 10 | #include <linux/types.h>
|
| 11 |
|
| 12 |
|
| 13 | #define VDO_SUCCESS 0
|
| 14 |
|
| 15 |
|
| 16 | enum uds_status_codes {
|
| 17 |
|
| 18 | UDS_SUCCESS = VDO_SUCCESS,
|
| 19 |
|
| 20 | UDS_ERROR_CODE_BASE = 1024,
|
| 21 |
|
| 22 | UDS_OVERFLOW = UDS_ERROR_CODE_BASE,
|
| 23 |
|
| 24 | UDS_INVALID_ARGUMENT,
|
| 25 |
|
| 26 | UDS_BAD_STATE,
|
| 27 |
|
| 28 | UDS_DUPLICATE_NAME,
|
| 29 |
|
| 30 | UDS_ASSERTION_FAILED,
|
| 31 |
|
| 32 | UDS_QUEUED,
|
| 33 |
|
| 34 | UDS_ALREADY_REGISTERED,
|
| 35 |
|
| 36 | UDS_OUT_OF_RANGE,
|
| 37 |
|
| 38 | UDS_DISABLED,
|
| 39 |
|
| 40 | UDS_UNSUPPORTED_VERSION,
|
| 41 |
|
| 42 | UDS_CORRUPT_DATA,
|
| 43 |
|
| 44 | UDS_NO_INDEX,
|
| 45 |
|
| 46 | UDS_INDEX_NOT_SAVED_CLEANLY,
|
| 47 |
|
| 48 | UDS_ERROR_CODE_LAST,
|
| 49 |
|
| 50 | UDS_ERROR_CODE_BLOCK_END = UDS_ERROR_CODE_BASE + 440,
|
| 51 | };
|
| 52 |
|
| 53 | enum {
|
| 54 | VDO_MAX_ERROR_NAME_SIZE = 80,
|
| 55 | VDO_MAX_ERROR_MESSAGE_SIZE = 128,
|
| 56 | };
|
| 57 |
|
| 58 | struct error_info {
|
| 59 | const char *name;
|
| 60 | const char *message;
|
| 61 | };
|
| 62 |
|
| 63 | const char * __must_check uds_string_error(int errnum, char *buf, size_t buflen);
|
| 64 |
|
| 65 | const char *uds_string_error_name(int errnum, char *buf, size_t buflen);
|
| 66 |
|
| 67 | int uds_status_to_errno(int error);
|
| 68 |
|
| 69 | int uds_register_error_block(const char *block_name, int first_error,
|
| 70 | int last_reserved_error, const struct error_info *infos,
|
| 71 | size_t info_size);
|
| 72 |
|
| 73 | #endif
|