chiark / gitweb /
systemctl: don't show cgroup field for a unit if cgroup is empty
[elogind.git] / src / shared / cgroup-util.c
index b0d378de5ade1e577a0c7f86cd7b294b3e0ec709..18cbf0412ab823ec5d9045c1b0ef2f8238857e71 100644 (file)
@@ -934,6 +934,20 @@ int cg_is_empty(const char *controller, const char *path, bool ignore_self) {
         return !found;
 }
 
+int cg_is_empty_by_spec(const char *spec, bool ignore_self) {
+        int r;
+        _cleanup_free_ char *controller = NULL, *path = NULL;
+
+        assert(spec);
+
+        r = cg_split_spec(spec, &controller, &path);
+        if (r < 0)
+                return r;
+
+        return cg_is_empty(controller, path, ignore_self);
+}
+
+
 int cg_is_empty_recursive(const char *controller, const char *path, bool ignore_self) {
         int r;
         DIR *d = NULL;