]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
cgroups: make use of ERRNO_IS_NOT_SUPPORTED()
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 24 Feb 2021 08:37:13 +0000 (09:37 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 24 Feb 2021 08:37:13 +0000 (09:37 +0100)
This will hopefully prevent backwards compatibility fallback errors.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/attach.c
src/lxc/cgroups/cgfsng.c

index f1700da4f434960a501dfffa66c99ed0d812466d..f21fb86da88e045e9b41151005c077f3e8a70470 100644 (file)
@@ -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;
                        }
index fd7c825614ef76b2326129085cb1d9da7f5cec45..a27c89ad96e7d9c2c05ebcbed39580de982f8748 100644 (file)
@@ -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;