Hi,

This patchset implements two new APIs to access data inside the cgroup data
structure. It has been tested using,

#include <stdio.h>
#include <libcgroup.h>
#include <stdlib.h>

int main()
{
        char **list;
        int size;
        struct cgroup *cgroup;
        int ret;
        int len;
        int i;

        ret = cgroup_init();

        cgroup = cgroup_new_cgroup("a");

        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;

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

        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]);

        return 0;
}

which on running returns,
Listing all controllers
cpu
cpuacct
memory
Listing all the files for the CPU controller
cpu.rt_period_us
cpu.rt_runtime_us
cpu.shares

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