6. Error handling

Error handling

Unless states otherwise in documentation of a function, all functions return int, which is zero (0) when the function succeeds, and positive number if the function fails.

The returned integer is one of the ECG* values described below. Value ECGOTHER means that the error was caused by underlying OS and the real cause can be found by calling cgroup_get_last_errno().



enum  {
  ECGROUPNOTCOMPILED = 50000, ECGROUPNOTMOUNTED, ECGROUPNOTEXIST, ECGROUPNOTCREATED,
  ECGROUPSUBSYSNOTMOUNTED, ECGROUPNOTOWNER, ECGROUPMULTIMOUNTED, ECGROUPNOTALLOWED,
  ECGMAXVALUESEXCEEDED, ECGCONTROLLEREXISTS, ECGVALUEEXISTS, ECGINVAL,
  ECGCONTROLLERCREATEFAILED, ECGFAIL, ECGROUPNOTINITIALIZED, ECGROUPVALUENOTEXIST,
  ECGOTHER, ECGROUPNOTEQUAL, ECGCONTROLLERNOTEQUAL, ECGROUPPARSEFAIL,
  ECGROUPNORULES, ECGMOUNTFAIL, ECGSENTINEL, ECGEOF,
  ECGCONFIGPARSEFAIL, ECGNAMESPACEPATHS, ECGNAMESPACECONTROLLER, ECGMOUNTNAMESPACE
}
const char * cgroup_strerror (int code)
 Format error code to a human-readable English string.
int cgroup_get_last_errno (void)
 Return last errno, which caused ECGOTHER error.
#define ECGRULESPARSEFAIL   ECGROUPPARSEFAIL
 Legacy definition of ECGRULESPARSEFAIL error code.

Define Documentation

#define ECGRULESPARSEFAIL   ECGROUPPARSEFAIL

Legacy definition of ECGRULESPARSEFAIL error code.


Enumeration Type Documentation

anonymous enum
Enumerator:
ECGROUPNOTCOMPILED 
ECGROUPNOTMOUNTED 
ECGROUPNOTEXIST 
ECGROUPNOTCREATED 
ECGROUPSUBSYSNOTMOUNTED 
ECGROUPNOTOWNER 
ECGROUPMULTIMOUNTED 

Controllers bound to different mount points.

ECGROUPNOTALLOWED 
ECGMAXVALUESEXCEEDED 
ECGCONTROLLEREXISTS 
ECGVALUEEXISTS 
ECGINVAL 
ECGCONTROLLERCREATEFAILED 
ECGFAIL 
ECGROUPNOTINITIALIZED 
ECGROUPVALUENOTEXIST 
ECGOTHER 

Represents error coming from other libraries like glibc.

libcgroup users need to check cgroup_get_last_errno() upon encountering this error.

ECGROUPNOTEQUAL 
ECGCONTROLLERNOTEQUAL 
ECGROUPPARSEFAIL 

Failed to parse rules configuration file.

ECGROUPNORULES 

Rules list does not exist.

ECGMOUNTFAIL 
ECGSENTINEL 

Not an real error, just a auxiliary mark in the enum.

Please insert further error codes above this.

ECGEOF 

Not an real error, it just indicates that iterator has come to end of sequence and no more items are left.

ECGCONFIGPARSEFAIL 

Failed to parse config file (cgconfig.conf).

ECGNAMESPACEPATHS 
ECGNAMESPACECONTROLLER 
ECGMOUNTNAMESPACE 

Function Documentation

int cgroup_get_last_errno ( void   ) 

Return last errno, which caused ECGOTHER error.

const char* cgroup_strerror ( int  code  ) 

Format error code to a human-readable English string.

No internationalization is currently done. Returned pointer leads to libcgroup memory and must not be freed nor modified. The memory is rewritten by subsequent call to this function.

Parameters:
code Error code for which the corresponding error string is returned. When ECGOTHER is used, text with glibc's description of cgroup_get_last_errno() value is returned.

Generated on 31 Mar 2010 for libcgroup by  doxygen 1.6.1