dm vdo errors: remove unused error codes
[linux-block.git] / drivers / md / dm-vdo / errors.h
CommitLineData
03d1089e
MS
1/* SPDX-License-Identifier: GPL-2.0-only */
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
ee8f6ec1
MS
12/* Custom error codes and error-related utilities */
13#define VDO_SUCCESS 0
03d1089e
MS
14
15/* Valid status codes for internal UDS functions. */
16enum uds_status_codes {
17 /* Successful return */
ee8f6ec1 18 UDS_SUCCESS = VDO_SUCCESS,
03d1089e
MS
19 /* Used as a base value for reporting internal errors */
20 UDS_ERROR_CODE_BASE = 1024,
21 /* Index overflow */
86492a3f 22 UDS_OVERFLOW = UDS_ERROR_CODE_BASE,
03d1089e 23 /* Invalid argument passed to internal routine */
86492a3f 24 UDS_INVALID_ARGUMENT,
03d1089e 25 /* UDS data structures are in an invalid state */
86492a3f 26 UDS_BAD_STATE,
03d1089e 27 /* Attempt to enter the same name into an internal structure twice */
86492a3f 28 UDS_DUPLICATE_NAME,
03d1089e 29 /* An assertion failed */
86492a3f 30 UDS_ASSERTION_FAILED,
03d1089e 31 /* A request has been queued for later processing (not an error) */
86492a3f 32 UDS_QUEUED,
03d1089e 33 /* This error range has already been registered */
86492a3f 34 UDS_ALREADY_REGISTERED,
03d1089e 35 /* Attempt to read or write data outside the valid range */
86492a3f 36 UDS_OUT_OF_RANGE,
03d1089e 37 /* The index session is disabled */
86492a3f 38 UDS_DISABLED,
03d1089e 39 /* The index configuration or volume format is no longer supported */
86492a3f 40 UDS_UNSUPPORTED_VERSION,
03d1089e 41 /* Some index structure is corrupt */
86492a3f 42 UDS_CORRUPT_DATA,
03d1089e 43 /* No index state found */
86492a3f 44 UDS_NO_INDEX,
03d1089e 45 /* Attempt to access incomplete index save data */
86492a3f 46 UDS_INDEX_NOT_SAVED_CLEANLY,
03d1089e
MS
47 /* One more than the last UDS_INTERNAL error code */
48 UDS_ERROR_CODE_LAST,
49 /* One more than the last error this block will ever use */
50 UDS_ERROR_CODE_BLOCK_END = UDS_ERROR_CODE_BASE + 440,
51};
52
53enum {
54 UDS_MAX_ERROR_NAME_SIZE = 80,
55 UDS_MAX_ERROR_MESSAGE_SIZE = 128,
56};
57
58struct error_info {
59 const char *name;
60 const char *message;
61};
62
63const char * __must_check uds_string_error(int errnum, char *buf, size_t buflen);
64
65const char *uds_string_error_name(int errnum, char *buf, size_t buflen);
66
c10497b3 67int uds_status_to_errno(int error);
03d1089e
MS
68
69int 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 /* UDS_ERRORS_H */