This patch standardize error messages form of the second part of cgclassify.
Signed-off-by: Ivana Varekova <[email protected]> Ivana Varekova -------------------------------------------------------- diff -up ./api.c.p1 ./api.c --- ./api.c.p1 2009-01-29 14:50:28.000000000 +0100 +++ ./api.c 2009-01-30 14:30:57.000000000 +0100 @@ -96,6 +96,8 @@ char *cgroup_strerror_codes[] = { "Cgroup mounting failed", "Process with given pid does not exist", "euid or egid of the given proces can not be found", + "The config file can not be open", + "Out of memory", }; static int cg_chown_file(FTS *fts, FTSENT *ent, uid_t owner, gid_t group) @@ -296,14 +298,14 @@ static int cgroup_parse_rules(bool cache dbg("Failed to open configuration file %s with" " error: %s\n", CGRULES_CONF_FILE, strerror(errno)); - ret = errno; + ret = ECGCANTOPENCF; goto finish; } buff = calloc(CGROUP_RULE_MAXLINE, sizeof(char)); if (!buff) { dbg("Out of memory? Error: %s\n", strerror(errno)); - ret = errno; + ret = ECGOUTOFEMEM; goto close_unlock; } @@ -444,7 +446,7 @@ static int cgroup_parse_rules(bool cache newrule = calloc(1, sizeof(struct cgroup_rule)); if (!newrule) { dbg("Out of memory? Error: %s\n", strerror(errno)); - ret = errno; + ret = ECGOUTOFEMEM; goto cleanup; } @@ -2046,8 +2048,8 @@ int cgroup_reload_cached_rules() dbg("Reloading cached rules from %s.\n", CGRULES_CONF_FILE); if ((ret = cgroup_parse_rules(true, CGRULE_INVALID, CGRULE_INVALID))) { - dbg("Error parsing configuration file \"%s\": %d.\n", - CGRULES_CONF_FILE, ret); + dbg("Error parsing configuration file \"%s\": %s.\n", + CGRULES_CONF_FILE, cgroup_strerror(ret)); ret = ECGROUPPARSEFAIL; goto finished; } @@ -2072,7 +2074,7 @@ int cgroup_init_rules_cache() /* Attempt to read the configuration file and cache the rules. */ ret = cgroup_parse_rules(true, CGRULE_INVALID, CGRULE_INVALID); if (ret) { - dbg("Could not initialize rule cache, error was: %d\n", ret); + dbg("Could not initialize rule cache, error was: %s\n", cgroup_strerror(ret)); cgroup_rules_loaded = false; } else { cgroup_rules_loaded = true; diff -up ./cgclassify.c.p1 ./cgclassify.c --- ./cgclassify.c.p1 2009-01-29 14:50:28.000000000 +0100 +++ ./cgclassify.c 2009-01-29 15:10:17.000000000 +0100 @@ -141,7 +141,7 @@ int main(int argc, char *argv[]) ret = cgroup_change_cgroup_uid_gid(euid, egid, pid); if (ret) { fprintf(stderr, "Error: change of cgroup failed for" - " pid %d\n", pid); + " pid %d: %s\n", pid, cgroup_strerror(ret)); return ret; } } diff -up ./cgrulesengd.c.p1 ./cgrulesengd.c --- ./cgrulesengd.c.p1 2009-01-29 14:47:19.000000000 +0100 +++ ./cgrulesengd.c 2009-01-30 14:14:24.000000000 +0100 @@ -572,7 +572,7 @@ int main(int argc, char *argv[]) /* Ask libcgroup to load the configuration rules. */ if ((ret = cgroup_init_rules_cache()) != 0) { fprintf(stderr, "Error: libcgroup failed to initialize rules" - "cache, %d\n", ret); + "cache: %s\n", cgroup_strerror(ret)); goto finished; } diff -up ./libcgroup.h.p1 ./libcgroup.h --- ./libcgroup.h.p1 2009-01-29 14:50:28.000000000 +0100 +++ ./libcgroup.h 2009-01-30 13:56:21.000000000 +0100 @@ -96,6 +96,8 @@ enum cgroup_errors { ECGMOUNTFAIL, ECGPROCNEXISTS, /* Proces with given pid does not exist*/ ECGEUIDGIDFAIL, /* euid of the given proces can't be found */ + ECGCANTOPENCF, /* The config file can not be open */ + ECGOUTOFEMEM, /* Out of memory */ ECGSENTINEL, /* Please insert further error codes above this */ }; ------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ Libcg-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libcg-devel
