chiark / gitweb /
console: rework automatic getty on kernel console logic again
[elogind.git] / src / cgroup-util.c
index 828b30414a67a004eaf83243ea286b5daf462ac5..6abb6b549a04706336a3baa1613bce4b840c9714 100644 (file)
@@ -1,4 +1,4 @@
-/*-*- Mode: C; c-basic-offset: 8 -*-*/
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
 
 /***
   This file is part of systemd.
@@ -25,6 +25,8 @@
 #include <string.h>
 #include <stdlib.h>
 #include <dirent.h>
+#include <sys/stat.h>
+#include <sys/types.h>
 
 #include "cgroup-util.h"
 #include "log.h"
@@ -479,7 +481,7 @@ int cg_get_path(const char *controller, const char *path, const char *suffix, ch
         else
                 p = controller;
 
-        if (asprintf(&mp, "/cgroup/%s", p) < 0)
+        if (asprintf(&mp, "/sys/fs/cgroup/%s", p) < 0)
                 return -ENOMEM;
 
         if ((r = path_is_mount_point(mp)) <= 0) {
@@ -546,7 +548,17 @@ int cg_create(const char *controller, const char *path) {
         if ((r = cg_get_path(controller, path, NULL, &fs)) < 0)
                 return r;
 
-        r = mkdir_p(fs, 0755);
+        r = mkdir_parents(fs, 0755);
+
+        if (r >= 0) {
+                if (mkdir(fs, 0755) >= 0)
+                        r = 1;
+                else if (errno == EEXIST)
+                        r = 0;
+                else
+                        r = -errno;
+        }
+
         free(fs);
 
         return r;
@@ -577,7 +589,7 @@ int cg_attach(const char *controller, const char *path, pid_t pid) {
 }
 
 int cg_create_and_attach(const char *controller, const char *path, pid_t pid) {
-        int r;
+        int r, q;
 
         assert(controller);
         assert(path);
@@ -586,8 +598,8 @@ int cg_create_and_attach(const char *controller, const char *path, pid_t pid) {
         if ((r = cg_create(controller, path)) < 0)
                 return r;
 
-        if ((r = cg_attach(controller, path, pid)) < 0)
-                return r;
+        if ((q = cg_attach(controller, path, pid)) < 0)
+                return q;
 
         /* This does not remove the cgroup on failure */
 
@@ -725,10 +737,8 @@ int cg_install_release_agent(const char *controller, const char *agent) {
 
         free(fs);
         fs = NULL;
-        if ((r = cg_get_path(controller, NULL, "notify_on_release", &fs)) < 0) {
-                r = -ENOMEM;
+        if ((r = cg_get_path(controller, NULL, "notify_on_release", &fs)) < 0)
                 goto finish;
-        }
 
         free(contents);
         contents = NULL;
@@ -917,7 +927,7 @@ int cg_fix_path(const char *path, char **result) {
 
         /* First check if it already is a filesystem path */
         if (path_is_absolute(path) &&
-            path_startswith(path, "/cgroup") &&
+            path_startswith(path, "/sys/fs/cgroup") &&
             access(path, F_OK) >= 0) {
 
                 if (!(t = strdup(path)))