* Ankita Garg <[EMAIL PROTECTED]> [2008-12-01 15:06:14]:
> Hello,
>
> As part of the FOSS.in workout, I had worked on improving the error
> reporting of libcgroup. So, instead of displaying the error code of
> 50019, with the patch, the user would get a more meaningful error
> message.
>
> Testing done: Tried several incorrect scenarios, like, mount point not
> existing, executing parser without appropriate permissions, incorrect
> config file format, etc.
>
> Note: errno is still not thread specific. So, chances are that the
> global variable would be over-written and un-related error message might
> be printed. This is a to-do.
>
> Thoughts on the patch ?
>
> Signed-off-by: Ankita Garg <[EMAIL PROTECTED]>
>
> Index: trunk/cgconfig.c
> ===================================================================
> --- trunk.orig/cgconfig.c 2008-11-29 11:21:17.000000000 +0530
> +++ trunk/cgconfig.c 2008-12-01 15:01:38.000000000 +0530
> @@ -24,6 +24,78 @@
> #include <string.h>
> #include <errno.h>
>
> +void cgerror(int code)
> +{
> + switch(code) {
> + case ECGROUPNOTCOMPILED:
> + printf("Cgroup has not compiled\n");
> + break;
> + case ECGROUPNOTMOUNTED:
> + printf("Cgroup not mounted\n");
> + break;
> + case ECGROUPNOTEXIST:
> + printf("Cgroup does not exist. Check
> /proc/cgroups\n");
> + break;
> + case ECGROUPNOTCREATED:
> + printf("Cgroup not created\n");
> + break;
> + case ECGROUPSUBSYSNOTMOUNTED:
> + printf("Cgroup subsystem not mounted\n");
> + break;
> + case ECGROUPNOTOWNER:
> + printf("Caller does not have access to the
> cgroup\n");
> + break;
> + case ECGROUPMULTIMOUNTED:
> + printf("Controller bound to different mount
> points\n");
> + break;
> + case ECGROUPNOTALLOWED:
> + printf("Operation not allowed\n");
> + break;
> + case ECGCONTROLLEREXISTS:
> + printf("Controller already exists\n");
> + break;
> + case ECGMAXVALUESEXCEEDED:
> + printf("Exceeded maximum number of control
> group values in the config file\n");
> + break;
> + case ECGVALUEEXISTS:
> + printf("Control group value already exists.
> Check config file\n");
> + break;
> + case ECGINVAL:
> + printf("Invalid operation\n");
> + break;
> + case ECGCONTROLLERCREATEFAILED:
> + printf("Failed to create controller\n");
> + break;
> + case ECGFAIL:
> + printf("Operation failed\n");
> + break;
> + case ECGROUPNOTINITIALIZED:
> + printf("Cgroup not initialized\n");
> + break;
> + case ECGROUPVALUENOTEXIST:
> + printf("Cgroup value does not exist. Check the
> config file\n");
> + break;
> + case ECGOTHER:
> + printf("%s\n", strerror(errno));
> + break;
> + case ECGROUPNOTEQUAL:
> + printf("Cgroups not equal\n");
> + break;
> + case ECGCONTROLLERNOTEQUAL:
> + printf("Cgroup controller not equal\n");
> + break;
> + case ECGROUPPARSEFAIL:
> + printf("Error parsing configuration file\n");
> + break;
> + case ECGROUPNORULES:
> + printf("Rules list does not exist\n");
> + break;
> + case ECGMOUNTFAIL:
> + printf("Failed to mount cgroup\n");
> + break;
> + }
> +}
> +
1. It should belong to api.c, to make error parsing easy for everyone
2. It exceeds 80 columns on several occasions
3. switch and case should be at same indent level. I'll fix all of
those and merge into api.c and in the next release export it
4. I'll also changed change cgerror to cgroup_strerror()
5. printf's need to be removed and converted to an error value
I'll work on that, in case you are short on time.
--
Balbir
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel