errors.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright 2023 Red Hat
  4. */
  5. #ifndef UDS_ERRORS_H
  6. #define UDS_ERRORS_H
  7. #include <linux/compiler.h>
  8. #include <linux/types.h>
  9. /* Custom error codes and error-related utilities */
  10. #define VDO_SUCCESS 0
  11. /* Valid status codes for internal UDS functions. */
  12. enum uds_status_codes {
  13. /* Successful return */
  14. UDS_SUCCESS = VDO_SUCCESS,
  15. /* Used as a base value for reporting internal errors */
  16. UDS_ERROR_CODE_BASE = 1024,
  17. /* Index overflow */
  18. UDS_OVERFLOW = UDS_ERROR_CODE_BASE,
  19. /* Invalid argument passed to internal routine */
  20. UDS_INVALID_ARGUMENT,
  21. /* UDS data structures are in an invalid state */
  22. UDS_BAD_STATE,
  23. /* Attempt to enter the same name into an internal structure twice */
  24. UDS_DUPLICATE_NAME,
  25. /* An assertion failed */
  26. UDS_ASSERTION_FAILED,
  27. /* A request has been queued for later processing (not an error) */
  28. UDS_QUEUED,
  29. /* This error range has already been registered */
  30. UDS_ALREADY_REGISTERED,
  31. /* Attempt to read or write data outside the valid range */
  32. UDS_OUT_OF_RANGE,
  33. /* The index session is disabled */
  34. UDS_DISABLED,
  35. /* The index configuration or volume format is no longer supported */
  36. UDS_UNSUPPORTED_VERSION,
  37. /* Some index structure is corrupt */
  38. UDS_CORRUPT_DATA,
  39. /* No index state found */
  40. UDS_NO_INDEX,
  41. /* Attempt to access incomplete index save data */
  42. UDS_INDEX_NOT_SAVED_CLEANLY,
  43. /* One more than the last UDS_INTERNAL error code */
  44. UDS_ERROR_CODE_LAST,
  45. /* One more than the last error this block will ever use */
  46. UDS_ERROR_CODE_BLOCK_END = UDS_ERROR_CODE_BASE + 440,
  47. };
  48. enum {
  49. VDO_MAX_ERROR_NAME_SIZE = 80,
  50. VDO_MAX_ERROR_MESSAGE_SIZE = 128,
  51. };
  52. struct error_info {
  53. const char *name;
  54. const char *message;
  55. };
  56. const char * __must_check uds_string_error(int errnum, char *buf, size_t buflen);
  57. const char *uds_string_error_name(int errnum, char *buf, size_t buflen);
  58. int uds_status_to_errno(int error);
  59. int uds_register_error_block(const char *block_name, int first_error,
  60. int last_reserved_error, const struct error_info *infos,
  61. size_t info_size);
  62. #endif /* UDS_ERRORS_H */