Hello,

see my questions inline...

Dhaval Giani wrote:
>         cgroup = cgroup_new_cgroup("a");

Can I assume that cgroup_list_controllers() with group '/' (or '.') 
returns list of all controllers in the system? The code looks like it 
could work...

And is there a way, how to say that two controllers are mounted to the 
same mount point and therefore share groups?

>         ret = cgroup_get_cgroup(cgroup);
> 
>         if (ret) {
>                 printf("get cgroup failed with %s\n", cgroup_strerror(ret));
>                 return 0;
>         }
> 
>         ret = cgroup_list_controllers(cgroup, NULL);
>         size = ret;

Umm... returning both size and error code is *very* ugly, especially if 
both are positive integers.

>         list = calloc(ret, sizeof(char *));
> 
>         ret = cgroup_list_controllers(cgroup, list);
> 
>         printf("Listing all controllers\n");
> 
>         for (i = 0; i < size; i++)
>                 printf("%s\n", list[i]);
> 
>         for (i = 0; i < size; i++) {
>                 free(list[i]);
>                 list[i] = NULL;
>         }
> 
>         ret = cgroup_list_controller_files(cgroup, "cpu", NULL);

Again returning both size and error code.

>         if (ret == ECGCONTROLLERNOTFOUND) {
>                 printf("Controller not found\n");
>                 return 0;
>         }
> 
>         len = ret;
>         list = calloc(ret, sizeof(char *));
> 
>         ret = cgroup_list_controller_files(cgroup, "cpu", list);
> 
>         printf("Listing all the files for the CPU controller\n");
>         for (i = 0; i < len; i++)
>                 printf("%s\n", list[i]);

I think free(list); is missing here. The libcgroup won't free it for me, 
right?


Jan

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to