From: Christian Brauner Date: Wed, 24 Feb 2021 08:37:13 +0000 (+0100) Subject: cgroups: make use of ERRNO_IS_NOT_SUPPORTED() X-Git-Tag: lxc-5.0.0~269^2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f740bc634347adaca6d31e3f4b6327ad93cfe8af;p=thirdparty%2Flxc.git cgroups: make use of ERRNO_IS_NOT_SUPPORTED() This will hopefully prevent backwards compatibility fallback errors. Signed-off-by: Christian Brauner --- diff --git a/src/lxc/attach.c b/src/lxc/attach.c index f1700da4f..f21fb86da 100644 --- a/src/lxc/attach.c +++ b/src/lxc/attach.c @@ -1641,7 +1641,7 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function, ret = cgroup_attach(conf, name, lxcpath, pid); if (ret) { call_cleaner(cgroup_exit) struct cgroup_ops *cgroup_ops = NULL; - if (ret != -ENOCGROUP2 && ret != -ENOSYS) { + if (!ERRNO_IS_NOT_SUPPORTED(ret)) { SYSERROR("Failed to attach cgroup"); goto on_error; } diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c index fd7c82561..a27c89ad9 100644 --- a/src/lxc/cgroups/cgfsng.c +++ b/src/lxc/cgroups/cgfsng.c @@ -3421,7 +3421,7 @@ static int __cgroup_attach_unified(const struct lxc_conf *conf, const char *name dfd_unified = lxc_cmd_get_cgroup2_fd(name, lxcpath); if (dfd_unified < 0) - return ret_errno(ENOCGROUP2); + return ret_errno(ENOSYS); return __unified_attach_fd(conf, dfd_unified, pid); } @@ -3433,10 +3433,12 @@ int cgroup_attach(const struct lxc_conf *conf, const char *name, ret = __cgroup_attach_many(conf, name, lxcpath, pid); if (ret < 0) { - if (ret != -ENOSYS) + if (!ERRNO_IS_NOT_SUPPORTED(ret)) return ret; ret = __cgroup_attach_unified(conf, name, lxcpath, pid); + if (ret < 0 && ERRNO_IS_NOT_SUPPORTED(ret)) + return ret_errno(ENOSYS); } return ret;