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);
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;
off = (uint8_t *)k - (uint8_t *)bus->kdbus_buffer;
ioctl(bus->input_fd, KDBUS_CMD_MSG_RELEASE, &off);
- KDBUS_ITEM_FOREACH(d, k) {
+ KDBUS_PART_FOREACH(d, k, items) {
if (d->type == KDBUS_MSG_FDS)
close_many(d->fds, (d->size - offsetof(struct kdbus_item, fds)) / sizeof(int));
if (k->payload_type != KDBUS_PAYLOAD_DBUS1)
return 0;
- KDBUS_ITEM_FOREACH(d, k) {
+ KDBUS_PART_FOREACH(d, k, items) {
size_t l;
l = d->size - offsetof(struct kdbus_item, data);
if (r < 0)
return r;
- KDBUS_ITEM_FOREACH(d, k) {
+ KDBUS_PART_FOREACH(d, k, items) {
size_t l;
l = d->size - offsetof(struct kdbus_item, data);
l = strlen(name);
make = alloca0(offsetof(struct kdbus_cmd_bus_make, items) +
- KDBUS_ITEM_HEADER_SIZE + sizeof(uint64_t) +
- KDBUS_ITEM_HEADER_SIZE + DECIMAL_STR_MAX(uid_t) + 1 + l + 1);
+ KDBUS_PART_HEADER_SIZE + sizeof(uint64_t) +
+ KDBUS_PART_HEADER_SIZE + DECIMAL_STR_MAX(uid_t) + 1 + l + 1);
n = make->items;
n->type = KDBUS_MAKE_NAME;
sprintf(n->str, "%lu-%s", (unsigned long) getuid(), name);
- n->size = KDBUS_ITEM_HEADER_SIZE + strlen(n->str) + 1;
+ n->size = KDBUS_PART_HEADER_SIZE + strlen(n->str) + 1;
make->size = offsetof(struct kdbus_cmd_bus_make, items) + n->size;
make->flags = KDBUS_MAKE_POLICY_OPEN;
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;
+}