chiark / gitweb /
libsystemd-bus: copy over kdbus provided 128-bit bus id
[elogind.git] / src / libsystemd-bus / bus-kernel.c
index 9d4b6cf72100e58733f1a23a34d72f47f3557d3b..d2fcfd7f928e38780053e31be826f408d002eeb0 100644 (file)
@@ -326,6 +326,7 @@ int bus_kernel_take_fd(sd_bus *b) {
         zero(hello);
         hello.size = sizeof(hello);
         hello.conn_flags = b->hello_flags;
+        hello.attach_flags = b->attach_flags;
         hello.pool_size = KDBUS_POOL_SIZE;
 
         r = ioctl(b->input_fd, KDBUS_CMD_HELLO, &hello);
@@ -356,6 +357,9 @@ int bus_kernel_take_fd(sd_bus *b) {
         b->bus_client = true;
         b->can_fds = !!(hello.conn_flags & KDBUS_HELLO_ACCEPT_FD);
 
+        /* the kernel told us the UUID of the underlying bus */
+        memcpy(b->server_id.bytes, hello.id128, sizeof(b->server_id.bytes));
+
         r = bus_start_running(b);
         if (r < 0)
                 return r;
@@ -806,3 +810,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;
+}