summaryrefslogtreecommitdiffstats
path: root/src/libsystemd/sd-bus/bus-control.c
diff options
context:
space:
mode:
authorDaniel Mack <daniel@zonque.org>2014-09-22 18:20:14 +0200
committerDaniel Mack <daniel@zonque.org>2014-09-22 18:22:53 +0200
commitf8c2425287c8362ae3a3c9acfb9e23a16862b38a (patch)
treebc2b8580f79fc0aacf3d02881af9c913f9be07d7 /src/libsystemd/sd-bus/bus-control.c
parentutil: avoid non-portable __WORDSIZE (diff)
downloadsystemd-f8c2425287c8362ae3a3c9acfb9e23a16862b38a.tar.xz
systemd-f8c2425287c8362ae3a3c9acfb9e23a16862b38a.zip
sd-bus: sync kdbus.h (API+ABI break)
The kdbus logic name registry logic was changed to transport the actual name to acquire, release or report in a kdbus item. This brings the name API a little more in line with other calls, and allows for later augmentation. Follow that change on the systemd side.
Diffstat (limited to 'src/libsystemd/sd-bus/bus-control.c')
-rw-r--r--src/libsystemd/sd-bus/bus-control.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/libsystemd/sd-bus/bus-control.c b/src/libsystemd/sd-bus/bus-control.c
index 5ac48c081f..50b662f85d 100644
--- a/src/libsystemd/sd-bus/bus-control.c
+++ b/src/libsystemd/sd-bus/bus-control.c
@@ -59,11 +59,14 @@ static int bus_request_name_kernel(sd_bus *bus, const char *name, uint64_t flags
assert(name);
l = strlen(name);
- size = offsetof(struct kdbus_cmd_name, name) + l + 1;
+ size = offsetof(struct kdbus_cmd_name, items) + KDBUS_ITEM_SIZE(l + 1);
n = alloca0_align(size, 8);
n->size = size;
kdbus_translate_request_name_flags(flags, (uint64_t *) &n->flags);
- memcpy(n->name, name, l+1);
+
+ n->items[0].size = KDBUS_ITEM_HEADER_SIZE + l + 1;
+ n->items[0].type = KDBUS_ITEM_NAME;
+ memcpy(n->items[0].str, name, l+1);
#ifdef HAVE_VALGRIND_MEMCHECK_H
VALGRIND_MAKE_MEM_DEFINED(n, n->size);
@@ -144,16 +147,20 @@ _public_ int sd_bus_request_name(sd_bus *bus, const char *name, uint64_t flags)
static int bus_release_name_kernel(sd_bus *bus, const char *name) {
struct kdbus_cmd_name *n;
- size_t l;
+ size_t size, l;
int r;
assert(bus);
assert(name);
l = strlen(name);
- n = alloca0_align(offsetof(struct kdbus_cmd_name, name) + l + 1, 8);
- n->size = offsetof(struct kdbus_cmd_name, name) + l + 1;
- memcpy(n->name, name, l+1);
+ size = offsetof(struct kdbus_cmd_name, items) + KDBUS_ITEM_SIZE(l + 1);
+ n = alloca0_align(size, 8);
+ n->size = size;
+
+ n->items[0].size = KDBUS_ITEM_HEADER_SIZE + l + 1;
+ n->items[0].type = KDBUS_ITEM_NAME;
+ memcpy(n->items[0].str, name, l+1);
#ifdef HAVE_VALGRIND_MEMCHECK_H
VALGRIND_MAKE_MEM_DEFINED(n, n->size);
@@ -235,6 +242,9 @@ static int kernel_get_list(sd_bus *bus, uint64_t flags, char ***x) {
KDBUS_ITEM_FOREACH(name, name_list, names) {
+ struct kdbus_item *item;
+ const char *entry_name = NULL;
+
if ((flags & KDBUS_NAME_LIST_UNIQUE) && name->owner_id != previous_id) {
char *n;
@@ -248,8 +258,12 @@ static int kernel_get_list(sd_bus *bus, uint64_t flags, char ***x) {
previous_id = name->owner_id;
}
- if (name->size > sizeof(*name) && service_name_is_valid(name->name)) {
- r = strv_extend(x, name->name);
+ KDBUS_ITEM_FOREACH(item, name, items)
+ if (item->type == KDBUS_ITEM_NAME)
+ entry_name = item->str;
+
+ if (entry_name && service_name_is_valid(entry_name)) {
+ r = strv_extend(x, entry_name);
if (r < 0)
return -ENOMEM;
}