From 9fc7175a3ed6ea0afeeedaabc01e2ef4cb51e0a4 Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Mon, 28 Oct 2013 16:09:04 +0100 Subject: [PATCH] Bring task_cgroup_path_from_hierarchy() back for pre-3.11 compatiblity This commit partially reverts ea2b8c798cd34149fa13010d24 ("message.c: task_cgroup_path_from_hierarchy is now in 3.11-rc1, so remove it from here"). We still require it for pre-3.11 kernels that Tizen is shipping. Change-Id: I05568c5d8d473bb5257d3aa64f8a84b03e6da117 Signed-off-by: Karol Lewandowski --- message.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/message.c b/message.c index 9022efe..c983bcb 100644 --- a/message.c +++ b/message.c @@ -23,6 +23,8 @@ #include #include +#include + #include "bus.h" #include "connection.h" #include "endpoint.h" @@ -326,3 +328,45 @@ exit_free: kdbus_kmsg_free(m); return ret; } + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0) +/* + * FIXME: dirty and unsafe version of: + * http://git.kernel.org/cgit/linux/kernel/git/tj/cgroup.git/commit/?h=review-task_cgroup_path_from_hierarchy + * remove it when the above is upstream. + */ +int task_cgroup_path_from_hierarchy(struct task_struct *task, int hierarchy_id, + char *buf, size_t buflen) +{ + struct cg_cgroup_link { + struct list_head cgrp_link_list; + struct cgroup *cgrp; + struct list_head cg_link_list; + struct css_set *cg; + }; + + struct cgroupfs_root { + struct super_block *sb; + unsigned long subsys_mask; + int hierarchy_id; + }; + + struct cg_cgroup_link *link; + int ret = -ENOENT; + +// cgroup_lock(); + list_for_each_entry(link, ¤t->cgroups->cg_links, cg_link_list) { + struct cgroup *cg = link->cgrp; + struct cgroupfs_root *root = (struct cgroupfs_root *)cg->root; + + if (root->hierarchy_id != hierarchy_id) + continue; + + ret = cgroup_path(cg, buf, buflen); + break; + } +// cgroup_unlock(); + + return ret; +} +#endif -- 2.34.1