[Devel] [PATCH rh7 5/6] cgroup: use cgroup_path_ve helper in cgroup_show_path

Vladimir Davydov vdavydov at virtuozzo.com
Mon Jun 20 09:40:15 PDT 2016


Presently, it basically duplicates the code used for mangling cgroup
path shown inside ve, which is already present in cgroup_path_ve. Let's
reuse it.

Signed-off-by: Vladimir Davydov <vdavydov at virtuozzo.com>
---
 kernel/cgroup.c | 39 +++++++++------------------------------
 1 file changed, 9 insertions(+), 30 deletions(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 5c012f6e94e5..dd548853e2eb 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1373,41 +1373,20 @@ static int cgroup_remount(struct super_block *sb, int *flags, char *data)
 }
 
 #ifdef CONFIG_VE
-int cgroup_show_path(struct seq_file *m, struct dentry *dentry)
+static int cgroup_show_path(struct seq_file *m, struct dentry *dentry)
 {
-	char *buf;
+	struct cgroup *cgrp = __d_cgrp(dentry);
+	char *buf, *end;
 	size_t size = seq_get_buf(m, &buf);
-	int res = -1, err = 0;
-
-	if (size) {
-		char *p = dentry_path(dentry, buf, size);
-		if (!IS_ERR(p)) {
-			char *end;
-			if (!ve_is_super(get_exec_env())) {
-				while (*++p != '/') {
-					/*
-					 * Mangle one level when showing
-					 * cgroup mount source in container
-					 * e.g.: "/111" -> "/",
-					 * "/111/test.slice/test.scope" ->
-					 * "/test.slice/test.scope"
-					 */
-					if (*p == '\0') {
-						*--p = '/';
-						break;
-					}
-				}
-			}
-			end = mangle_path(buf, p, " \t\n\\");
-			if (end)
-				res = end - buf;
-		} else {
-			err = PTR_ERR(p);
-		}
+	int res = -1;
+
+	if (size > 0 && cgroup_path_ve(cgrp, buf, size) == 0) {
+		end = mangle_path(buf, buf, " \t\n\\");
+		res = end - buf;
 	}
 	seq_commit(m, res);
 
-	return err;
+	return 0;
 }
 #endif
 
-- 
2.1.4



More information about the Devel mailing list