From: Lennart Poettering Date: Mon, 17 Jun 2013 23:00:13 +0000 (+0200) Subject: core: expose a "Slice" property on Unit objects on the bus X-Git-Tag: v205~114 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=4ec9a8a48d61266638524a7cbc2c4763a9c92e2c;hp=f2561e85982ed25b610cad6253599a051f9ec8e2;ds=sidebyside core: expose a "Slice" property on Unit objects on the bus --- diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c index 575f8eb36..b7391b550 100644 --- a/src/core/dbus-unit.c +++ b/src/core/dbus-unit.c @@ -81,6 +81,25 @@ static int bus_unit_append_following(DBusMessageIter *i, const char *property, v return 0; } +static int bus_unit_append_slice(DBusMessageIter *i, const char *property, void *data) { + Unit *u = data; + const char *d; + + assert(i); + assert(property); + assert(u); + + if (UNIT_DEREF(u->slice)) + d = UNIT_DEREF(u->slice)->id; + else + d = ""; + + if (!dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &d)) + return -ENOMEM; + + return 0; +} + static int bus_unit_append_dependencies(DBusMessageIter *i, const char *property, void *data) { Unit *u; Iterator j; @@ -1255,6 +1274,7 @@ const BusProperty bus_unit_properties[] = { { "Id", bus_property_append_string, "s", offsetof(Unit, id), true }, { "Names", bus_unit_append_names, "as", 0 }, { "Following", bus_unit_append_following, "s", 0 }, + { "Slice", bus_unit_append_slice, "s", 0 }, { "Requires", bus_unit_append_dependencies, "as", offsetof(Unit, dependencies[UNIT_REQUIRES]), true }, { "RequiresOverridable", bus_unit_append_dependencies, "as", offsetof(Unit, dependencies[UNIT_REQUIRES_OVERRIDABLE]), true }, { "Requisite", bus_unit_append_dependencies, "as", offsetof(Unit, dependencies[UNIT_REQUISITE]), true }, diff --git a/src/core/dbus-unit.h b/src/core/dbus-unit.h index acd1ddbe7..83932c5a6 100644 --- a/src/core/dbus-unit.h +++ b/src/core/dbus-unit.h @@ -64,6 +64,7 @@ " \n" \ " \n" \ " \n" \ + " \n" \ " \n" \ " \n" \ " \n" \