summaryrefslogtreecommitdiffstats
path: root/api.c
diff options
context:
space:
mode:
authorDhaval Giani <dhaval@linux.vnet.ibm.com>2008-12-09 11:18:39 +0000
committerDhaval Giani <dhaval@linux.vnet.ibm.com>2008-12-09 11:18:39 +0000
commit96ee38b048031ceefcd8eb169fc1c4bd2bee2eb7 (patch)
tree578d985f59883daac59438952e572519e1db56df /api.c
parent50dce522e4a5a09d43012b1d3d18ac80a5c16863 (diff)
downloadlibcg-96ee38b048031ceefcd8eb169fc1c4bd2bee2eb7.tar.gz
libcg-96ee38b048031ceefcd8eb169fc1c4bd2bee2eb7.tar.xz
libcg-96ee38b048031ceefcd8eb169fc1c4bd2bee2eb7.zip
libcgroup: Better error reporting for libcgroup
From: Ankita Garg <ankita@in.ibm.com> This patch adds human readable error messages to the configuration parser. The error lookup is implemented as a simple table, indexed by the error. TODO: Save errno at ECGOTHER and pass it down as cgroup_lasterror. Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> Signed-off-by: Ankita Garg <ankita@in.ibm.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@228 4f4bb910-9a46-0410-90c8-c897d4f1cd53
Diffstat (limited to 'api.c')
-rw-r--r--api.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/api.c b/api.c
index 4efb390..b5bb8ee 100644
--- a/api.c
+++ b/api.c
@@ -40,6 +40,7 @@
#include <ctype.h>
#include <pwd.h>
#include <libgen.h>
+#include <assert.h>
#ifndef PACKAGE_VERSION
#define PACKAGE_VERSION 0.01
@@ -70,6 +71,31 @@ static struct cgroup_rule_list trl;
/* Lock for the list of rules (rl) */
static pthread_rwlock_t rl_lock = PTHREAD_RWLOCK_INITIALIZER;
+char *cgroup_strerror_codes[] = {
+ "Cgroup is not compiled in",
+ "Cgroup is not mounted",
+ "Cgroup does not exist",
+ "Cgroup has not been created",
+ "Cgroup one of the needed subsystems is not mounted",
+ "Cgroup, request came in from non owner",
+ "Cgroup controllers controllers are bound to different mount points",
+ "Cgroup, operation not allowed",
+ "Cgroup value set exceeds maximum",
+ "Cgroup controller already exists",
+ "Cgroup value already exists",
+ "Cgroup invalid operation",
+ "Cgroup, creation of controller failed",
+ "Cgroup operation failed",
+ "Cgroup not initialized",
+ "Cgroup trying to set value for control that does not exist",
+ "Cgroup generic error, see errno",
+ "Cgroup values are not equal",
+ "Cgroup controllers are different",
+ "Cgroup parsing failed",
+ "Cgroup, rules file does not exist",
+ "Cgroup mounting failed",
+};
+
static int cg_chown_file(FTS *fts, FTSENT *ent, uid_t owner, gid_t group)
{
int ret = 0;
@@ -2077,3 +2103,9 @@ cleanup_path:
free(path);
return ret;
}
+
+char *cgroup_strerror(int code)
+{
+ assert((code >= ECGROUPNOTCOMPILED) && (code < ECGSENTINEL));
+ return cgroup_strerror_codes[code % ECGROUPNOTCOMPILED];
+}