summaryrefslogtreecommitdiff
path: root/src/bus-driverd
diff options
context:
space:
mode:
authorLukasz Skalski <l.skalski@partner.samsung.com>2013-12-17 17:31:46 +0100
committerLennart Poettering <lennart@poettering.net>2013-12-17 20:37:24 +0100
commit3263ef39b89080cacccaf9b7b36675490a282f2d (patch)
tree6fc5f4834e54f66c69183e3059fbccaa2f9bea76 /src/bus-driverd
parenta69f4254a82765cd0c7f155d5dc86e0768ea0ef3 (diff)
bus-driverd: Fix return code in driver_request_name
RequestName return codes should be consistent with Dbus Specification. VALUE - DESCRIPTION 1-The caller is now the primary owner of the name, replacing any previous owner, 2-The name already had an owner (QUEUE flag was not specified), 3-The name already has an owner (QUEUE flag was specified), 4-Application trying to request ownership of a name is already the owner of it.
Diffstat (limited to 'src/bus-driverd')
-rw-r--r--src/bus-driverd/bus-driverd.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/bus-driverd/bus-driverd.c b/src/bus-driverd/bus-driverd.c
index 11bd2f932b..a1ad0504c3 100644
--- a/src/bus-driverd/bus-driverd.c
+++ b/src/bus-driverd/bus-driverd.c
@@ -348,10 +348,19 @@ static int driver_request_name(sd_bus *bus, sd_bus_message *m, void *userdata, s
cmd_name->id = id;
r = ioctl(sd_bus_get_fd(bus), KDBUS_CMD_NAME_ACQUIRE, cmd_name);
- if (r < 0)
- return r;
+ if (r < 0) {
+ if (errno == EEXIST)
+ return sd_bus_reply_method_return(m, "u", BUS_NAME_EXISTS);
+ else if (errno == EALREADY)
+ return sd_bus_reply_method_return(m, "u", BUS_NAME_ALREADY_OWNER);
+ else
+ return sd_bus_reply_method_return(m, "u", -errno);
+ }
+
+ if (cmd_name->flags & KDBUS_NAME_IN_QUEUE)
+ return sd_bus_reply_method_return(m, "u", BUS_NAME_IN_QUEUE);
- return sd_bus_reply_method_return(m, "u", 0);
+ return sd_bus_reply_method_return(m, "u", BUS_NAME_PRIMARY_OWNER);
}
static int driver_start_service_by_name(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) {