]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
There is a bogus test in cgroup_get_parent_name
authorJan Safranek <jsafrane@redhat.com>
Thu, 2 Dec 2010 14:00:40 +0000 (15:00 +0100)
committerJan Safranek <jsafrane@redhat.com>
Thu, 2 Dec 2010 14:00:40 +0000 (15:00 +0100)
which returns error in situation when 0 should be return.
This causes problem e.g. when a hierarchy is mounted to two
mount points.

CHANGELOG:
- the test is not removed but moved to the else part

EXAMPLE:

$ cat aux.conf
mount {
cpu = /cgroup/cpu;
cpuacct = /cgroup/cpu;
memory = /cgroup/memory;
}
group hXAjiy/wWRq {
cpu {}
memory {}
}
$ mkdir /mnt/cgroups/cpu 2>/dev/null
$ mount -t cgroup -o cpu,cpuacct cpu /mnt/cgroups/cpu
$ time cgconfigparser -l aux.conf
$ cgclear
$ cat /proc/cgroups

OLD output
#subsys_name hierarchy num_cgroups enabled
cpuset 0 1 1
ns 0 1 1
cpu 301 1 1
cpuacct 301 1 1
memory 303 3 1
devices 0 1 1
freezer 0 1 1
net_cls 0 1 1
blkio 0 1 1

New output
#subsys_name    hierarchy   num_cgroups enabled
cpuset  0   1   1
ns  0   1   1
cpu 0   1   1
cpuacct 0   1   1
memory  0   1   1
devices 0   1   1
freezer 0   1   1
net_cls 0   1   1
blkio   0   1   1

Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
src/api.c

index a51230bd4f1b59162a0fc0f63ef03f1f981037e0..7e2903dc4b45899eafae971c15351845677c241a 100644 (file)
--- a/src/api.c
+++ b/src/api.c
@@ -1512,12 +1512,11 @@ static int cgroup_get_parent_name(struct cgroup *cgroup, char **parent)
        }
        else {
                *parent = strdup(pdir);
+               if (*parent == NULL)
+                       ret = ECGFAIL;
        }
        free(dir);
 
-       if (*parent == NULL)
-               ret = ECGFAIL;
-
        return ret;
 }