summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-12-12 00:35:23 +0100
committerLennart Poettering <lennart@poettering.net>2013-12-12 00:35:23 +0100
commit7f7030e23ea82b9576472c95680dfbb59d842a54 (patch)
tree8bfb6e79c098a9228cc24da395d04ae55e5b1813
parent6a4abbc87721b1323ef2a2b1eab3b4b333a5c006 (diff)
bus: update name listing logic to current kernel interface
-rw-r--r--src/libsystemd-bus/bus-control.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/libsystemd-bus/bus-control.c b/src/libsystemd-bus/bus-control.c
index 47e91118a4..b9700068b6 100644
--- a/src/libsystemd-bus/bus-control.c
+++ b/src/libsystemd-bus/bus-control.c
@@ -203,6 +203,7 @@ static int kernel_get_list(sd_bus *bus, uint64_t flags, char ***x) {
struct kdbus_cmd_name_list cmd = {};
struct kdbus_name_list *name_list;
struct kdbus_cmd_name *name;
+ uint64_t previous_id = 0;
int r;
/* Caller will free half-constructed list on failure... */
@@ -217,11 +218,7 @@ static int kernel_get_list(sd_bus *bus, uint64_t flags, char ***x) {
KDBUS_ITEM_FOREACH(name, name_list, names) {
- if (name->size > sizeof(*name)) {
- r = strv_extend(x, name->name);
- if (r < 0)
- return -ENOMEM;
- } else {
+ if ((flags & KDBUS_NAME_LIST_UNIQUE) && name->id != previous_id) {
char *n;
if (asprintf(&n, ":1.%llu", (unsigned long long) name->id) < 0)
@@ -232,8 +229,15 @@ static int kernel_get_list(sd_bus *bus, uint64_t flags, char ***x) {
free(n);
return -ENOMEM;
}
+
+ previous_id = name->id;
}
+ if (name->size > sizeof(*name)) {
+ r = strv_extend(x, name->name);
+ if (r < 0)
+ return -ENOMEM;
+ }
}
r = ioctl(sd_bus_get_fd(bus), KDBUS_CMD_FREE, &cmd.offset);