Skip to content

Commit

Permalink
cgroups: make use of ERRNO_IS_NOT_SUPPORTED()
Browse files Browse the repository at this point in the history
This will hopefully prevent backwards compatibility fallback errors.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Feb 24, 2021
1 parent 7924f36 commit f740bc6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/lxc/attach.c
Expand Up @@ -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;
}
Expand Down
6 changes: 4 additions & 2 deletions src/lxc/cgroups/cgfsng.c
Expand Up @@ -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);
}
Expand All @@ -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;
Expand Down

0 comments on commit f740bc6

Please sign in to comment.