On Sun, Dec 28, 2008 at 07:51:29PM +0530, Dhaval Giani wrote:
> cgroup_get_cgroup was failing with the memory controller enabled. It was
> failing on memory.force_empty. The file has read permissions, but there
> is no read routine associated with it inside the kernel. fscanf failed
> and so cgroup_get_cgroup also failed. This was unexpected,
> cgroup_get_cgroup should have just skipped the file. In order to fix
> this, change cg_rd_ctrl_file to return more descriptive errors.
> 
> Sigend-off-by: Dhaval Giani <[email protected]>

Tested using,


#include <libcgroup.h>
#include <stdio.h>
#include <libcgroup-internal.h>

void print_cgroup(struct cgroup *cgroup)
{
        int i, j;

        printf("cgroup name is %s\n", cgroup->name);
        for (i = 0; i < cgroup->index; i++) {
                printf("\tcontroller is %s\n", cgroup->controller[i]->name);
                for (j = 0; j < cgroup->controller[i]->index; j++) {
                        printf("\t\tcontrol value name is %s and value is %s\n",
                                        cgroup->controller[i]->values[j]->name,
                                        
cgroup->controller[i]->values[j]->value);
                }
        }
}

int main()
{
        struct cgroup *create, *get;
        struct cgroup_controller *cpu, *memory;
        int ret;

        create = cgroup_new_cgroup("test");
        cpu = cgroup_add_controller(create, "cpu");
        ret = cgroup_add_value_string(cpu, "cpu.shares", "2048");
        memory = cgroup_add_controller(create, "memory");
        ret = cgroup_add_value_string(memory, "memory.limit_in_bytes",
                                                                "1024000");
        ret = cgroup_set_uid_gid(create, 0, 0, 500, 500);

        ret = cgroup_init();
        ret = cgroup_create_cgroup(create, 0);

        get = cgroup_new_cgroup("test");
        ret = cgroup_get_cgroup(get);
        if (ret) {
                printf("cgroup_get_cgroup failed with %d\n", ret);
        }
        print_cgroup(get);
        return 0;
}
-- 
regards,
Dhaval

------------------------------------------------------------------------------
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to