summaryrefslogtreecommitdiff
path: root/src/dbus-unit.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-08-20 00:42:50 +0200
committerLennart Poettering <lennart@poettering.net>2011-08-21 20:07:08 +0200
commitd8bbda9141f03c3a2877639e7d43b5f35767840f (patch)
tree726e20e8deaeed328a7586eeb42d4b81957cd869 /src/dbus-unit.c
parent14e639ae7a1dbf156273ce697d30fbc6c6594209 (diff)
cgroup: expose cgroup attributes as unit properties on the bus
Diffstat (limited to 'src/dbus-unit.c')
-rw-r--r--src/dbus-unit.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/dbus-unit.c b/src/dbus-unit.c
index b110e33174..611a1202f4 100644
--- a/src/dbus-unit.c
+++ b/src/dbus-unit.c
@@ -330,6 +330,40 @@ int bus_unit_append_cgroups(DBusMessageIter *i, const char *property, void *data
return 0;
}
+int bus_unit_append_cgroup_attrs(DBusMessageIter *i, const char *property, void *data) {
+ Unit *u = data;
+ CGroupAttribute *a;
+ DBusMessageIter sub, sub2;
+
+ if (!dbus_message_iter_open_container(i, DBUS_TYPE_ARRAY, "(sss)", &sub))
+ return -ENOMEM;
+
+ LIST_FOREACH(by_unit, a, u->meta.cgroup_attributes) {
+ char *v = NULL;
+ bool success;
+
+ if (a->map_callback)
+ a->map_callback(a->controller, a->name, a->value, &v);
+
+ success =
+ dbus_message_iter_open_container(&sub, DBUS_TYPE_STRUCT, NULL, &sub2) &&
+ dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &a->controller) &&
+ dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &a->name) &&
+ dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, v ? &v : &a->value) &&
+ dbus_message_iter_close_container(&sub, &sub2);
+
+ free(v);
+
+ if (!success)
+ return -ENOMEM;
+ }
+
+ if (!dbus_message_iter_close_container(i, &sub))
+ return -ENOMEM;
+
+ return 0;
+}
+
int bus_unit_append_need_daemon_reload(DBusMessageIter *i, const char *property, void *data) {
Unit *u = data;
dbus_bool_t b;