[systemd-devel] [PATCH 3/7] libsystemd-bus: add kdbus support for sd_bus_list_names()

Daniel Mack daniel at zonque.org
Wed Nov 27 08:08:10 PST 2013


On 11/27/2013 04:59 PM, Lukasz Skalski wrote:
> My 2 cents inline.
> 
> On 11/15/2013 07:32 PM, Daniel Mack wrote:
>> kdbus will tell us the minimum buffer size it needs in case the default
>> 8kb buffer doesn't suffice.
>> ---
>>   src/libsystemd-bus/bus-control.c | 100 ++++++++++++++++++++++++++-------------
>>   1 file changed, 68 insertions(+), 32 deletions(-)
>>
>> diff --git a/src/libsystemd-bus/bus-control.c b/src/libsystemd-bus/bus-control.c
>> index 5c9e746..562513b 100644
>> --- a/src/libsystemd-bus/bus-control.c
>> +++ b/src/libsystemd-bus/bus-control.c
>> @@ -180,43 +180,79 @@ _public_ int sd_bus_list_names(sd_bus *bus, char ***l) {
>>           if (bus_pid_changed(bus))
>>                   return -ECHILD;
>>
>> -        r = sd_bus_call_method(
>> -                        bus,
>> -                        "org.freedesktop.DBus",
>> -                        "/",
>> -                        "org.freedesktop.DBus",
>> -                        "ListNames",
>> -                        NULL,
>> -                        &reply1,
>> -                        NULL);
>> -        if (r < 0)
>> -                return r;
>> +        if (bus->is_kernel) {
>> +                _cleanup_free_ struct kdbus_cmd_names *names = NULL;
>> +                struct kdbus_cmd_name *name;
>> +                size_t size;
>> +
>> +                /* assume 8k size first. If that doesn't suffice, kdbus will tell us
>> +                 * how big the buffer needs to be.  */
>> +                size = 8192;
>> +
>> +retry:
>> +                names = realloc(names, size);
>> +                if (!names)
>> +                        return log_oom();
>> +
>> +                names->size = size;
> 
> + names->flags=KDBUS_NAME_LIST_UNIQUE_NAMES;
> 
> "ListNames" should returns a list of all (both well-known and unique 
> names) currently-owned names on the bus.

Jup, I added the KDBUS_NAME_LIST_UNIQUE_NAMES kdbus feature *after* I
sent out the first version of this patch. It's already fixed in my local
tree :)


Thanks,
Daniel



More information about the systemd-devel mailing list