[PATCH] cgtop: useful error messages when bootup fails

Shawn Landden shawnlandden at gmail.com
Mon May 21 22:54:41 PDT 2012


cgtop quits on startup if all the cgroup mounts it expects are not ready.
Provide user with some indication of why cgtop failed.
---
 src/cgtop/cgtop.c |   22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c
index ddb5709..493687e 100644
--- a/src/cgtop/cgtop.c
+++ b/src/cgtop/cgtop.c
@@ -340,18 +340,30 @@ static int refresh(Hashmap *a, Hashmap *b, unsigned iteration) {
         assert(a);
 
         r = refresh_one("name=systemd", "/", a, b, iteration, 0);
-        if (r < 0)
+        if (r < 0) {
+                if (r == -ENOENT)
+                    log_error("Is /sys/fs/cgroup/systemd mounted?: %s", strerror(-r));
                 return r;
-
+        }
         r = refresh_one("cpuacct", "/", a, b, iteration, 0);
-        if (r < 0)
+        if (r < 0) {
+                if (r == -ENOENT)
+                    log_error("Is /sys/fs/cgroup/cpu,cpuacct mounted?: %s", strerror(-r));
                 return r;
-
+        }
         r = refresh_one("memory", "/", a, b, iteration, 0);
         if (r < 0)
+                if (r == -ENOENT)
+                    log_error("Is /sys/fs/cgroup/memory mounted?: %s", strerror(-r));
                 return r;
 
-        return refresh_one("blkio", "/", a, b, iteration, 0);
+        r = refresh_one("blkio", "/", a, b, iteration, 0);
+        if (r < 0) {
+                if (r == -ENOENT)
+                    log_error("Is /sys/fs/cgroup/blkio mounted?: %s", strerror(-r));
+                return r;
+        }
+        return 0;
 }
 
 static int group_compare(const void*a, const void *b) {
-- 
1.7.9.5


--=-22ygYVRIgv5IRXCCZEHt--



More information about the systemd-devel mailing list