From 45d029f04e21c549a1a1c98bc5cd3b88a700d706 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Wed, 16 Jul 2014 19:49:28 +0400 Subject: [PATCH] cg: Keep "/" in cgroup root paths The ftw trims tail "/" from path argument. Signed-off-by: Pavel Emelyanov Acked-by: Tycho Andersen --- cgroup.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cgroup.c b/cgroup.c index fcd57fc3d..46dd4b4b2 100644 --- a/cgroup.c +++ b/cgroup.c @@ -244,7 +244,11 @@ static int add_cgroup(const char *fpath, const struct stat *sb, int typeflag) } /* chop off the first "/proc/self/fd/N" str */ - ncd->path = xstrdup(fpath + path_pref_len); + if (fpath[path_pref_len] == '\0') + ncd->path = xstrdup("/"); + else + ncd->path = xstrdup(fpath + path_pref_len); + if (!ncd->path) { ret = -1; goto out;