On Wed, Feb 18, 2009 at 02:53:14PM +0100, Jan Safranek wrote:
> 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...
>

This is not querying the file system. Just the data structure.

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

I did not get the question. I would expect this to be handled by
cgconfigparser.

>>         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.
>

Yeah, but that right now seems to be the sanest way forward, esp since I
went crazy trying to figure out how to handle the triple pointer :).

>>         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?

This is just a test case (and a really bad one at that) to demonstrate
the API works as expected.


thanks,
-- 
regards,
Dhaval

------------------------------------------------------------------------------
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