]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
cgroups/cgfsng: rework cgfsng_attach()
authorChristian Brauner <christian.brauner@ubuntu.com>
Sat, 7 Dec 2019 23:35:19 +0000 (00:35 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sun, 8 Dec 2019 01:37:33 +0000 (02:37 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/cgroups/cgfsng.c

index 2f6c3e2fd7d3c362094597ec6e5a0e3bb62a8cb9..ec826c19e4bc738b1f43ed262d85859228b81175 100644 (file)
@@ -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;