summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/api.c74
-rw-r--r--src/libcgroup.map3
2 files changed, 77 insertions, 0 deletions
diff --git a/src/api.c b/src/api.c
index ab35ed7..63813a3 100644
--- a/src/api.c
+++ b/src/api.c
@@ -2541,6 +2541,80 @@ int cgroup_get_task_begin(char *cgroup, char *controller, void **handle,
return ret;
}
+
+int cgroup_get_controller_end(void **handle)
+{
+ int *pos = (int *) *handle;
+
+ if (!cgroup_initialized)
+ return ECGROUPNOTINITIALIZED;
+
+ if (!pos)
+ return ECGINVAL;
+
+ free(pos);
+ *handle = NULL;
+
+ return 0;
+}
+
+int cgroup_get_controller_next(void **handle, struct cgroup_mount_point *info)
+{
+ int *pos = (int *) *handle;
+ int ret = 0;
+
+ if (!cgroup_initialized)
+ return ECGROUPNOTINITIALIZED;
+
+ if (!pos)
+ return ECGINVAL;
+
+ if (!info)
+ return ECGINVAL;
+
+ pthread_rwlock_rdlock(&cg_mount_table_lock);
+
+ if (cg_mount_table[*pos].name[0] == '\0') {
+ ret = ECGEOF;
+ goto out_unlock;
+ }
+
+ strncpy(info->name, cg_mount_table[*pos].name, FILENAME_MAX);
+
+ strncpy(info->path, cg_mount_table[*pos].path, FILENAME_MAX);
+
+ (*pos)++;
+ *handle = pos;
+
+out_unlock:
+ pthread_rwlock_unlock(&cg_mount_table_lock);
+ return ret;
+}
+
+int cgroup_get_controller_begin(void **handle, struct cgroup_mount_point *info)
+{
+ int *pos;
+
+ if (!cgroup_initialized)
+ return ECGROUPNOTINITIALIZED;
+
+ if (!info)
+ return ECGINVAL;
+
+ pos = malloc(sizeof(int));
+
+ if (!pos) {
+ last_errno = errno;
+ return ECGOTHER;
+ }
+
+ *pos = 0;
+
+ *handle = pos;
+
+ return cgroup_get_controller_next(handle, info);
+}
+
/**
* Get process data (euid and egid) from /proc/<pid>/status file.
* @param pid: The process id
diff --git a/src/libcgroup.map b/src/libcgroup.map
index 0748bb3..adcf905 100644
--- a/src/libcgroup.map
+++ b/src/libcgroup.map
@@ -63,6 +63,9 @@ global:
cgroup_read_stats_next;
cgroup_read_stats_end;
cgroup_walk_tree_set_flags;
+ cgroup_get_controller_end;
+ cgroup_get_controller_next;
+ cgroup_get_controller_begin;
cgroup_get_controller;
cgroup_get_uid_gid_from_procfs;
} CGROUP_0.33;