Bring task_cgroup_path_from_hierarchy() back for pre-3.11 compatiblity
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Mon, 28 Oct 2013 15:09:04 +0000 (16:09 +0100)
committerŁukasz Stelmach <l.stelmach@samsung.com>
Wed, 19 Nov 2014 12:46:10 +0000 (13:46 +0100)
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 <k.lewandowsk@samsung.com>
message.c

index 9022efe2a9dcadf53eb65bff574639078f9adc2b..c983bcb7b6e40d118812e89cc780243b24946279 100644 (file)
--- a/message.c
+++ b/message.c
@@ -23,6 +23,8 @@
 #include <linux/slab.h>
 #include <linux/uaccess.h>
 
+#include <linux/version.h>
+
 #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, &current->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