diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-07-31 18:13:03 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-07-31 18:13:03 +0200 |
commit | 9f39404c86ea20d164b08b9639ca800c1d88724b (patch) | |
tree | eeb3d7784f5906cba7f944273b0180b2630edd09 /src/dbus-unit.c | |
parent | 92f30b3f05e9139c36611f6df19e87c018415eda (diff) |
dbus: export load error on unit objects
Diffstat (limited to 'src/dbus-unit.c')
-rw-r--r-- | src/dbus-unit.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/dbus-unit.c b/src/dbus-unit.c index 266fb39be2..bf240f97d4 100644 --- a/src/dbus-unit.c +++ b/src/dbus-unit.c @@ -330,6 +330,30 @@ int bus_unit_append_need_daemon_reload(DBusMessageIter *i, const char *property, return 0; } +int bus_unit_append_load_error(DBusMessageIter *i, const char *property, void *data) { + Unit *u = data; + const char *name, *message; + DBusMessageIter sub; + + assert(i); + assert(property); + assert(u); + + if (u->meta.load_error != 0) { + name = bus_errno_to_dbus(u->meta.load_error); + message = strempty(strerror(-u->meta.load_error)); + } else + name = message = ""; + + if (!dbus_message_iter_open_container(i, DBUS_TYPE_STRUCT, NULL, &sub) || + !dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &name) || + !dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &message) || + !dbus_message_iter_close_container(i, &sub)) + return -ENOMEM; + + return 0; +} + static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusConnection *connection, DBusMessage *message) { DBusMessage *reply = NULL; Manager *m = u->meta.manager; |