diff options
author | Dhaval Giani <dhaval@linux.vnet.ibm.com> | 2009-03-03 20:21:03 +0530 |
---|---|---|
committer | Dhaval Giani <dhaval@linux.vnet.ibm.com> | 2009-03-04 15:22:49 +0530 |
commit | 8594444bf340b98a8d0eb22a4af9c3ce7157d1ba (patch) | |
tree | afd2175b7734ccbfeaf633d3a3b4fb73677b11bc | |
parent | 19da8166649f449e2762aacdeedcbfefe4ef5c5c (diff) | |
download | libcg-8594444bf340b98a8d0eb22a4af9c3ce7157d1ba.tar.gz libcg-8594444bf340b98a8d0eb22a4af9c3ce7157d1ba.tar.xz libcg-8594444bf340b98a8d0eb22a4af9c3ce7157d1ba.zip |
libcgroup: Check if the data structures have been initialized for walk_tree
The test for cgroup_init() was not being done by the walk tree APIs.
With this it is possible for it to run without cgroup_init() being
called and having mysterious failures.
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
-rw-r--r-- | api.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -2251,6 +2251,9 @@ static int cg_walk_node(FTS *fts, FTSENT *ent, const int depth, int ret = 0; int base_level; + if (!cgroup_initialized) + return ECGROUPNOTINITIALIZED; + cgroup_dbg("seeing file %s\n", ent->fts_path); info->path = ent->fts_name; @@ -2291,6 +2294,9 @@ int cgroup_walk_tree_next(const int depth, void **handle, FTS *fts = *(FTS **)handle; FTSENT *ent; + if (!cgroup_initialized) + return ECGROUPNOTINITIALIZED; + if (!handle) return ECGINVAL; ent = fts_read(fts); @@ -2308,6 +2314,9 @@ int cgroup_walk_tree_end(void **handle) int ret = 0; FTS *fts = *(FTS **)handle; + if (!cgroup_initialized) + return ECGROUPNOTINITIALIZED; + if (!handle) return ECGINVAL; fts_close(fts); @@ -2328,6 +2337,9 @@ int cgroup_walk_tree_begin(char *controller, char *base_path, const int depth, FTSENT *ent; FTS *fts; + if (!cgroup_initialized) + return ECGROUPNOTINITIALIZED; + if (!cg_build_path(base_path, full_path, controller)) return ECGOTHER; |