mirror of
https://github.com/systemd/systemd.git
synced 2026-08-03 06:30:30 +00:00
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.
This commit is contained in:
@@ -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)
|
||||
return -errno;
|
||||
if (r < 0) {
|
||||
if (errno == -EALREADY)
|
||||
return SD_BUS_NAME_ALREADY_OWNER;
|
||||
|
||||
return n->flags;
|
||||
if (errno == -EEXIST)
|
||||
return SD_BUS_NAME_EXISTS;
|
||||
|
||||
return -errno;
|
||||
}
|
||||
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user