diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-07-04 20:38:14 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-07-04 20:38:14 +0200 |
commit | fe68089df69f3580ebc9bbaf2483bdcda40a6933 (patch) | |
tree | d2e5e2e248190abe60546401ab99e704169a8989 /src/dbus-execute.c | |
parent | b58b41160fde88a82cba1ddec4be7dfb08825e35 (diff) |
dbus: complete exec command coverage
Diffstat (limited to 'src/dbus-execute.c')
-rw-r--r-- | src/dbus-execute.c | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/src/dbus-execute.c b/src/dbus-execute.c index a41b63992b..529f72dfa0 100644 --- a/src/dbus-execute.c +++ b/src/dbus-execute.c @@ -26,6 +26,7 @@ #include "dbus-execute.h" #include "missing.h" #include "ioprio.h" +#include "strv.h" DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_execute_append_input, exec_input, ExecInput); DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_execute_append_output, exec_output, ExecOutput); @@ -153,7 +154,7 @@ int bus_execute_append_affinity(Manager *m, DBusMessageIter *i, const char *prop assert(property); assert(c); - if (!(dbus_message_iter_open_container(i, DBUS_TYPE_ARRAY, "y", &sub))) + if (!dbus_message_iter_open_container(i, DBUS_TYPE_ARRAY, "y", &sub)) return -ENOMEM; if (c->cpuset) @@ -246,3 +247,53 @@ int bus_execute_append_rlimits(Manager *m, DBusMessageIter *i, const char *prope return 0; } + +int bus_execute_append_command(Manager *m, DBusMessageIter *i, const char *property, void *data) { + ExecCommand *c = data; + DBusMessageIter sub, sub2, sub3; + + assert(m); + assert(i); + assert(property); + + if (!dbus_message_iter_open_container(i, DBUS_TYPE_ARRAY, "(sasttuii)", &sub)) + return -ENOMEM; + + LIST_FOREACH(command, c, c) { + char **l; + uint32_t pid; + int32_t code, status; + + if (!c->path) + continue; + + if (!dbus_message_iter_open_container(&sub, DBUS_TYPE_STRUCT, NULL, &sub2) || + !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &c->path) || + !dbus_message_iter_open_container(&sub2, DBUS_TYPE_ARRAY, "s", &sub3)) + return -ENOMEM; + + STRV_FOREACH(l, c->argv) + if (!dbus_message_iter_append_basic(&sub3, DBUS_TYPE_STRING, l)) + return -ENOMEM; + + pid = (uint32_t) c->exec_status.pid; + code = (int32_t) c->exec_status.code; + status = (int32_t) c->exec_status.status; + + if (!dbus_message_iter_close_container(&sub2, &sub3) || + !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_UINT64, &c->exec_status.start_timestamp.realtime) || + !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_UINT64, &c->exec_status.exit_timestamp.realtime) || + !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_UINT32, &c->exec_status.pid) || + !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_INT32, &c->exec_status.code) || + !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_INT32, &c->exec_status.status)) + return -ENOMEM; + + if (!dbus_message_iter_close_container(&sub, &sub2)) + return -ENOMEM; + } + + if (!dbus_message_iter_close_container(i, &sub)) + return -ENOMEM; + + return 0; +} |