From 0253ddccbb60918d177c13aa6a70c5e1fc9a7e78 Mon Sep 17 00:00:00 2001 From: Daniel Mack <zonque@gmail.com> Date: Tue, 26 Nov 2013 16:45:50 +0100 Subject: libsystemd-bus: kernel: add sd_bus_kernel_translate_request_name_flags Flags used to request a name from kdbus are not identical to what DBus and sd_bus use internally. Introduce a simple function to do the translation for us. It's factored out to a separate function so the dbus-driver instance can make use of it as well. --- src/libsystemd-bus/bus-kernel.c | 18 ++++++++++++++++++ src/libsystemd-bus/bus-kernel.h | 2 ++ 2 files changed, 20 insertions(+) (limited to 'src/libsystemd-bus') diff --git a/src/libsystemd-bus/bus-kernel.c b/src/libsystemd-bus/bus-kernel.c index 9d4b6cf721..08f1851b96 100644 --- a/src/libsystemd-bus/bus-kernel.c +++ b/src/libsystemd-bus/bus-kernel.c @@ -806,3 +806,21 @@ void bus_kernel_flush_memfd(sd_bus *b) { for (i = 0; i < b->n_memfd_cache; i++) close_and_munmap(b->memfd_cache[i].fd, b->memfd_cache[i].address, b->memfd_cache[i].size); } + +int sd_bus_kernel_translate_request_name_flags(uint64_t sd_bus_flags, uint64_t *kdbus_flags) { + + assert_return(kdbus_flags != NULL, -EINVAL); + + *kdbus_flags = 0; + + if (sd_bus_flags & SD_BUS_NAME_ALLOW_REPLACEMENT) + *kdbus_flags |= KDBUS_NAME_ALLOW_REPLACEMENT; + + if (sd_bus_flags & SD_BUS_NAME_REPLACE_EXISTING) + *kdbus_flags |= KDBUS_NAME_REPLACE_EXISTING; + + if (!(sd_bus_flags & SD_BUS_NAME_DO_NOT_QUEUE)) + *kdbus_flags |= KDBUS_NAME_QUEUE; + + return 0; +} diff --git a/src/libsystemd-bus/bus-kernel.h b/src/libsystemd-bus/bus-kernel.h index 69df4f4e9e..779a7de2eb 100644 --- a/src/libsystemd-bus/bus-kernel.h +++ b/src/libsystemd-bus/bus-kernel.h @@ -68,3 +68,5 @@ void bus_kernel_push_memfd(sd_bus *bus, int fd, void *address, size_t size); void bus_kernel_flush_memfd(sd_bus *bus); int bus_kernel_parse_unique_name(const char *s, uint64_t *id); + +int sd_bus_kernel_translate_request_name_flags(uint64_t sd_bus_flags, uint64_t *kdbus_flags); -- cgit v1.2.3-54-g00ecf