summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus
diff options
context:
space:
mode:
authorDaniel Mack <zonque@gmail.com>2013-11-26 17:24:18 +0100
committerDaniel Mack <zonque@gmail.com>2013-11-29 14:06:50 +0100
commited99569df8e568c1998c3b47bea33ec24b89d787 (patch)
tree9814937872c3d831faa7f0fc7b80cf99dfacb28c /src/libsystemd-bus
parent0253ddccbb60918d177c13aa6a70c5e1fc9a7e78 (diff)
libsystemd-bus: sd_bus_request_name: fix return value for kdbus
kdbus returns -EALREADY if the requesting connection is already the owner of a name, and -EEXIST if the name already exists and the connection is not able to take it over. Also, n->flags needs a translation as well to match the SD_BUS_* enum values.
Diffstat (limited to 'src/libsystemd-bus')
-rw-r--r--src/libsystemd-bus/bus-control.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/libsystemd-bus/bus-control.c b/src/libsystemd-bus/bus-control.c
index eeeb77b591..b222175148 100644
--- a/src/libsystemd-bus/bus-control.c
+++ b/src/libsystemd-bus/bus-control.c
@@ -84,10 +84,20 @@ _public_ int sd_bus_request_name(sd_bus *bus, const char *name, int flags) {
#endif
r = ioctl(bus->input_fd, KDBUS_CMD_NAME_ACQUIRE, n);
- if (r < 0)
+ if (r < 0) {
+ if (errno == -EALREADY)
+ return SD_BUS_NAME_ALREADY_OWNER;
+
+ if (errno == -EEXIST)
+ return SD_BUS_NAME_EXISTS;
+
return -errno;
+ }
- return n->flags;
+ if (n->flags & KDBUS_NAME_IN_QUEUE)
+ return SD_BUS_NAME_IN_QUEUE;
+
+ return SD_BUS_NAME_PRIMARY_OWNER;
} else {
r = sd_bus_call_method(
bus,