From: Christian Brauner Date: Sat, 7 Dec 2019 23:35:19 +0000 (+0100) Subject: cgroups/cgfsng: rework cgfsng_attach() X-Git-Tag: lxc-4.0.0~78^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ab9a452ddbac831a6559e4988dec1c1b17fe0d1f;p=thirdparty%2Flxc.git cgroups/cgfsng: rework cgfsng_attach() Signed-off-by: Christian Brauner --- diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c index 836b89f68..db458c682 100644 --- a/src/lxc/cgroups/cgfsng.c +++ b/src/lxc/cgroups/cgfsng.c @@ -2303,6 +2303,9 @@ __cgfsng_ops static bool cgfsng_attach(struct cgroup_ops *ops, const char *name, int len, ret; char pidstr[INTTYPE_TO_STRLEN(pid_t)]; + if (!ops) + return ret_set_errno(false, ENOENT); + if (!ops->hierarchies) return true; @@ -2330,10 +2333,10 @@ __cgfsng_ops static bool cgfsng_attach(struct cgroup_ops *ops, const char *name, fullpath = build_full_cgpath_from_monitorpath(h, path, "cgroup.procs"); ret = lxc_write_to_file(fullpath, pidstr, len, false, 0666); - if (ret < 0) { - SYSERROR("Failed to attach %d to %s", (int)pid, fullpath); - return false; - } + if (ret < 0) + return log_error_errno(false, errno, + "Failed to attach %d to %s", + (int)pid, fullpath); } return true;