include/libcgroup/iterators.h File Reference

#include <sys/types.h>
#include <stdio.h>
#include <features.h>

Data Structures

struct  cgroup_file_info
 Information about found directory (= a control group). More...
struct  cgroup_stat
 One item in stats file. More...
struct  cgroup_mount_point
 Information about mounted controller. More...
struct  controller_data
 Detailed information about available controller. More...

Read group stats

libcgroup's cgroup_get_value_string() reads only relatively short parametrs of a group.

Use following functions to read stats parameter, which can be quite long.



#define CG_VALUE_MAX   100
 Maximum length of a value in stats file.
int cgroup_read_stats_begin (const char *controller, const char *path, void **handle, struct cgroup_stat *stat)
 Read the statistics values (= stats parameter) for the specified controller and control group.
int cgroup_read_stats_next (void **handle, struct cgroup_stat *stat)
 Read the next stat value.
int cgroup_read_stats_end (void **handle)
 Release the iterator.

Walk through control group filesystem

This iterator returns all subgroups of given control group.

It can be used to return all groups in given hierarchy, when root control group is provided.



enum  cgroup_walk_type { CGROUP_WALK_TYPE_PRE_DIR = 0x1, CGROUP_WALK_TYPE_POST_DIR = 0x2 }
 

Type of the walk.

More...
enum  cgroup_file_type { CGROUP_FILE_TYPE_FILE, CGROUP_FILE_TYPE_DIR, CGROUP_FILE_TYPE_OTHER }
 

Type of returned entity.

More...
int cgroup_walk_tree_begin (const char *controller, const char *base_path, int depth, void **handle, struct cgroup_file_info *info, int *base_level)
 Walk through the directory tree for the specified controller.
int cgroup_walk_tree_next (int depth, void **handle, struct cgroup_file_info *info, int base_level)
 Get the next directory in the walk.
int cgroup_walk_tree_end (void **handle)
 Release the iterator.
int cgroup_walk_tree_set_flags (void **handle, int flags)
 Set the flags for walk_tree.

List all tasks in a group

Use following functions to read tasks file of a group.



int cgroup_get_task_begin (const char *cgroup, const char *controller, void **handle, pid_t *pid)
 Read the tasks file to get the list of tasks in a cgroup.
int cgroup_get_task_next (void **handle, pid_t *pid)
 Read the next task value.
int cgroup_get_task_end (void **handle)
 Release the iterator.

List mounted controllers

Use following function to list mounted controllers and to see, how they are mounted together in hierarchies.

Use cgroup_get_all_controller_begin() (see later) to list all controllers, including those which are not mounted.



int cgroup_get_controller_begin (void **handle, struct cgroup_mount_point *info)
 Read the mount table to give a list where each controller is mounted.
int cgroup_get_controller_next (void **handle, struct cgroup_mount_point *info)
 Read the next mounted controller.
int cgroup_get_controller_end (void **handle)
 Release the iterator.

List all controllers

Use following functions to list all controllers, including those which are not mounted.

The controllers are returned in the same order as in /proc/cgroups file, i.e. mostly random.



int cgroup_get_all_controller_begin (void **handle, struct controller_data *info)
 Read the first of controllers from /proc/cgroups.
int cgroup_get_all_controller_next (void **handle, struct controller_data *info)
 Read next controllers from /proc/cgroups.
int cgroup_get_all_controller_end (void **handle)
 Release the iterator.

Generated on 31 Mar 2010 for libcgroup by  doxygen 1.6.1