chiark / gitweb /
libsystemd-bus: make sd_bus_list_names return all connections, including unique names
authorDaniel Mack <zonque@gmail.com>
Tue, 19 Nov 2013 15:33:05 +0000 (16:33 +0100)
committerDaniel Mack <zonque@gmail.com>
Fri, 29 Nov 2013 13:06:50 +0000 (14:06 +0100)
src/libsystemd-bus/bus-control.c

index f988cc7c59e6dda8eec049a3950b40c4f6dbbc22..eeeb77b5913f3d093759712d089265aff51991cc 100644 (file)
@@ -195,6 +195,7 @@ _public_ int sd_bus_list_names(sd_bus *bus, char ***l) {
                                 return -ENOMEM;
 
                         names->size = size;
                                 return -ENOMEM;
 
                         names->size = size;
+                        names->flags = KDBUS_NAME_LIST_UNIQUE_NAMES;
 
                         r = ioctl(sd_bus_get_fd(bus), KDBUS_CMD_NAME_LIST, names);
                         if (r < 0) {
 
                         r = ioctl(sd_bus_get_fd(bus), KDBUS_CMD_NAME_LIST, names);
                         if (r < 0) {
@@ -210,7 +211,14 @@ _public_ int sd_bus_list_names(sd_bus *bus, char ***l) {
                 }
 
                 KDBUS_PART_FOREACH(name, names, names) {
                 }
 
                 KDBUS_PART_FOREACH(name, names, names) {
-                        r = strv_extend(&x, name->name);
+                        char *n;
+
+                        if (name->size > sizeof(*name))
+                                n = name->name;
+                        else
+                                asprintf(&n, ":1.%llu", (unsigned long long) name->id);
+
+                        r = strv_extend(&x, n);
                         if (r < 0)
                                 return -ENOMEM;
                 }
                         if (r < 0)
                                 return -ENOMEM;
                 }