From 305fdb705e4eca50f3dc18d7cc685b547ce0ee98 Mon Sep 17 00:00:00 2001 From: Dhaval Giani Date: Fri, 26 Jun 2009 23:06:18 +0530 Subject: libcgroup: Introduce an API to get the mount point of a specific subsystem Introduce an API which will query the mount table and return the mount point of a specific subsystem. This is needed in the case when the user knows which subsystem he wants the details of, which would make the use of the get_controller* APIs cumbersome. Signed-off-by: Dhaval Giani --- src/api.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/api.c') diff --git a/src/api.c b/src/api.c index 76ba833..03d7520 100644 --- a/src/api.c +++ b/src/api.c @@ -2668,3 +2668,31 @@ int cgroup_get_uid_gid_from_procfs(pid_t pid, uid_t *euid, gid_t *egid) return 0; } +int cgroup_get_subsys_mount_point(char *controller, char **mount_point) +{ + int i; + int ret = ECGROUPNOTEXIST; + + if (!cgroup_initialized) + return ECGROUPNOTINITIALIZED; + + pthread_rwlock_rdlock(&cg_mount_table_lock); + for (i = 0; cg_mount_table[i].name[0] != '\0'; i++) { + if (strncmp(cg_mount_table[i].name, controller, FILENAME_MAX)) + continue; + + *mount_point = strdup(cg_mount_table[i].path); + + if (!*mount_point) { + last_errno = errno; + ret = ECGOTHER; + goto out_exit; + } + + ret = 0; + break; + } +out_exit: + pthread_rwlock_unlock(&cg_mount_table_lock); + return ret; +} -- cgit