chiark / gitweb /
dbus: add Dump() D-Bus call
authorLennart Poettering <lennart@poettering.net>
Sat, 10 Apr 2010 15:37:56 +0000 (17:37 +0200)
committerLennart Poettering <lennart@poettering.net>
Sat, 10 Apr 2010 16:00:22 +0000 (18:00 +0200)
dbus-manager.c
systemctl.vala
systemd-interfaces.vala

index 754916482936fc48277fda7728cd1191f1f01211..2323260dbb65d11bbd9be505cae197d118e48059 100644 (file)
@@ -49,6 +49,7 @@
         "  </method>"                                                   \
         "  <method name=\"Subscribe\"/>"                                \
         "  <method name=\"Unsubscribe\"/>"                              \
+        "  <method name=\"Dump\"/>"                                     \
         "  <signal name=\"UnitNew\">"                                   \
         "   <arg name=\"id\" type=\"s\"/>"                              \
         "   <arg name=\"unit\" type=\"o\"/>"                            \
@@ -330,6 +331,35 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection  *connection
                 if (!(reply = dbus_message_new_method_return(message)))
                         goto oom;
 
+        } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1", "Dump")) {
+                FILE *f;
+                char *dump = NULL;
+                size_t size;
+
+                if (!(reply = dbus_message_new_method_return(message)))
+                        goto oom;
+
+                if (!(f = open_memstream(&dump, &size)))
+                        goto oom;
+
+                manager_dump_units(m, f, NULL);
+                manager_dump_jobs(m, f, NULL);
+
+                if (ferror(f)) {
+                        fclose(f);
+                        free(dump);
+                        goto oom;
+                }
+
+                fclose(f);
+
+                if (!dbus_message_append_args(reply, DBUS_TYPE_STRING, &dump, DBUS_TYPE_INVALID)) {
+                        free(dump);
+                        goto oom;
+                }
+
+                free(dump);
+
         } else if (dbus_message_is_method_call(message, "org.freedesktop.DBus.Introspectable", "Introspect")) {
                 char *introspection = NULL;
                 FILE *f;
index 22a971cc82071950f6a45be4f319f8ef7a5309e4..6c01ad1263bd14ece5e17ef39a2ab0b30f53d721 100644 (file)
@@ -222,7 +222,9 @@ int main (string[] args) {
                         MainLoop l = new MainLoop();
                         l.run();
 
-                } else {
+                } else if (args[1] == "dump")
+                        stdout.puts(manager.dump());
+                else {
                         stderr.printf("Unknown command %s.\n", args[1]);
                         return 1;
                 }
index 9947df54a73a2c45d9e75a91ce75883faad433f1..0323c0dbcb11cd898a4975fbec532394bf422594 100644 (file)
@@ -54,6 +54,8 @@ public interface Manager : DBus.Object {
         public abstract void subscribe() throws DBus.Error;
         public abstract void unsubscribe() throws DBus.Error;
 
+        public abstract string dump() throws DBus.Error;
+
         public abstract signal void unit_new(string id, ObjectPath path);
         public abstract signal void unit_removed(string id, ObjectPath path);
         public abstract signal void job_new(uint32 id, ObjectPath path);