error.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #ifndef _LIBCGROUP_ERROR_H
  2. #define _LIBCGROUP_ERROR_H
  3. #ifndef _LIBCGROUP_H_INSIDE
  4. #error "Only <libcgroup.h> should be included directly."
  5. #endif
  6. #ifndef SWIG
  7. #include <features.h>
  8. #endif
  9. __BEGIN_DECLS
  10. /**
  11. * @defgroup group_errors 6. Error handling
  12. * @{
  13. *
  14. * @name Error handling
  15. * @{
  16. * Unless states otherwise in documentation of a function, all functions
  17. * return @c int, which is zero (0) when the function succeeds, and positive
  18. * number if the function fails.
  19. *
  20. * The returned integer is one of the ECG* values described below. Value
  21. * #ECGOTHER means that the error was caused by underlying OS and the real
  22. * cause can be found by calling cgroup_get_last_errno().
  23. */
  24. enum {
  25. ECGROUPNOTCOMPILED = 50000,
  26. ECGROUPNOTMOUNTED,
  27. ECGROUPNOTEXIST,
  28. ECGROUPNOTCREATED,
  29. ECGROUPSUBSYSNOTMOUNTED,
  30. ECGROUPNOTOWNER,
  31. /** Controllers bound to different mount points */
  32. ECGROUPMULTIMOUNTED,
  33. /* This is the stock error. Default error. @todo really? */
  34. ECGROUPNOTALLOWED,
  35. ECGMAXVALUESEXCEEDED,
  36. ECGCONTROLLEREXISTS,
  37. ECGVALUEEXISTS,
  38. ECGINVAL,
  39. ECGCONTROLLERCREATEFAILED,
  40. ECGFAIL,
  41. ECGROUPNOTINITIALIZED,
  42. ECGROUPVALUENOTEXIST,
  43. /**
  44. * Represents error coming from other libraries like glibc. @c libcgroup
  45. * users need to check cgroup_get_last_errno() upon encountering this
  46. * error.
  47. */
  48. ECGOTHER,
  49. ECGROUPNOTEQUAL,
  50. ECGCONTROLLERNOTEQUAL,
  51. /** Failed to parse rules configuration file. */
  52. ECGROUPPARSEFAIL,
  53. /** Rules list does not exist. */
  54. ECGROUPNORULES,
  55. ECGMOUNTFAIL,
  56. /**
  57. * Not an real error, it just indicates that iterator has come to end
  58. * of sequence and no more items are left.
  59. */
  60. ECGEOF = 50023,
  61. /** Failed to parse config file (cgconfig.conf). */
  62. ECGCONFIGPARSEFAIL,
  63. ECGNAMESPACEPATHS,
  64. ECGNAMESPACECONTROLLER,
  65. ECGMOUNTNAMESPACE,
  66. ECGROUPUNSUPP,
  67. ECGCANTSETVALUE,
  68. /** Removing of a group failed because it was not empty. */
  69. ECGNONEMPTY,
  70. };
  71. /**
  72. * Legacy definition of ECGRULESPARSEFAIL error code.
  73. */
  74. #define ECGRULESPARSEFAIL ECGROUPPARSEFAIL
  75. /**
  76. * Format error code to a human-readable English string. No internationalization
  77. * is currently done. Returned pointer leads to @c libcgroup memory and
  78. * must not be freed nor modified. The memory is rewritten by subsequent
  79. * call to this function.
  80. * @param code Error code for which the corresponding error string is
  81. * returned. When #ECGOTHER is used, text with glibc's description of
  82. * cgroup_get_last_errno() value is returned.
  83. */
  84. const char *cgroup_strerror(int code);
  85. /**
  86. * Return last errno, which caused ECGOTHER error.
  87. */
  88. int cgroup_get_last_errno(void);
  89. /**
  90. * @}
  91. * @}
  92. */
  93. __END_DECLS
  94. #endif /* _LIBCGROUP_INIT_H */