8
void visit_node(struct cgroup_file_info *info, char *root)
10
if (info->type == CGROUP_FILE_TYPE_DIR) {
11
printf("path %s, parent %s, relative %s, full %s\n",
12
info->path, info->parent, info->full_path +
18
int main(int argc, char *argv[])
23
struct cgroup_file_info info;
24
char root[FILENAME_MAX];
28
fprintf(stderr, "Usage %s: <controller name>\n",
37
ret = cgroup_walk_tree_begin(controller, "/", 0, &handle, &info, &lvl);
40
fprintf(stderr, "Walk failed\n");
43
strcpy(root, info.full_path);
44
printf("Begin pre-order walk\n");
45
printf("root is %s\n", root);
46
visit_node(&info, root);
47
while ((ret = cgroup_walk_tree_next(0, &handle, &info, lvl)) !=
49
visit_node(&info, root);
51
cgroup_walk_tree_end(&handle);
53
printf("pre-order walk finished\n");
54
ret = cgroup_walk_tree_begin(controller, "/", 0, &handle, &info, &lvl);
57
fprintf(stderr, "Walk failed\n");
61
ret = cgroup_walk_tree_set_flags(&handle, CGROUP_WALK_TYPE_POST_DIR);
64
fprintf(stderr, "Walk failed with %s\n", cgroup_strerror(ret));
68
strcpy(root, info.full_path);
69
printf("Begin post-order walk\n");
70
printf("root is %s\n", root);
71
visit_node(&info, root);
72
while ((ret = cgroup_walk_tree_next(0, &handle, &info, lvl)) !=
74
visit_node(&info, root);
76
cgroup_walk_tree_end(&handle);
77
printf("post order walk finished\n");
79
ret = cgroup_walk_tree_begin(controller, "/a", 2, &handle, &info, &lvl);
82
fprintf(stderr, "Walk failed\n");
85
strcpy(root, info.full_path);
86
printf("root is %s\n", root);
87
visit_node(&info, root);
88
while ((ret = cgroup_walk_tree_next(2, &handle, &info, lvl)) !=
90
visit_node(&info, root);
92
cgroup_walk_tree_end(&handle);
95
* Walk only the first five nodes
98
printf("Walking the first 5 nodes\n");
99
ret = cgroup_walk_tree_begin(controller, "/", 0, &handle, &info, &lvl);
102
fprintf(stderr, "Walk failed\n");
105
strcpy(root, info.full_path);
106
printf("root is %s\n", root);
107
visit_node(&info, root);
109
while ((ret = cgroup_walk_tree_next(0, &handle, &info, lvl)) !=
111
visit_node(&info, root);
115
cgroup_walk_tree_end(&handle);