chiark / gitweb /
extend CODING_STYLE document a bit
[elogind.git] / src / libsystemd-bus / bus-kernel.c
index ca36eb86384f70b7a084ab415c5b3867bf2698c5..495d7e57dc596b97ac5cf77b2ed9384ea8329f93 100644 (file)
@@ -28,6 +28,7 @@
 #include <sys/mman.h>
 
 #include "util.h"
+#include "strv.h"
 
 #include "bus-internal.h"
 #include "bus-message.h"
@@ -248,8 +249,8 @@ static int bus_message_setup_kmsg(sd_bus *b, sd_bus_message *m) {
         memset(m->kdbus, 0, sz);
 
         m->kdbus->flags =
-                ((m->header->flags & SD_BUS_MESSAGE_NO_REPLY_EXPECTED) ? 0 : KDBUS_MSG_FLAGS_EXPECT_REPLY) |
-                ((m->header->flags & SD_BUS_MESSAGE_NO_AUTO_START) ? KDBUS_MSG_FLAGS_NO_AUTO_START : 0);
+                ((m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED) ? 0 : KDBUS_MSG_FLAGS_EXPECT_REPLY) |
+                ((m->header->flags & BUS_MESSAGE_NO_AUTO_START) ? KDBUS_MSG_FLAGS_NO_AUTO_START : 0);
         m->kdbus->dst_id =
                 well_known ? 0 :
                 m->destination ? unique : KDBUS_DST_ID_BROADCAST;
@@ -461,7 +462,7 @@ static void close_kdbus_msg(sd_bus *bus, struct kdbus_msg *k) {
         off = (uint8_t *)k - (uint8_t *)bus->kdbus_buffer;
         ioctl(bus->input_fd, KDBUS_CMD_FREE, &off);
 
-        KDBUS_PART_FOREACH(d, k, items) {
+        KDBUS_ITEM_FOREACH(d, k, items) {
 
                 if (d->type == KDBUS_ITEM_FDS)
                         close_many(d->fds, (d->size - offsetof(struct kdbus_item, fds)) / sizeof(int));
@@ -588,7 +589,7 @@ static int bus_kernel_translate_message(sd_bus *bus, struct kdbus_msg *k) {
         assert(k);
         assert(k->payload_type == KDBUS_PAYLOAD_KERNEL);
 
-        KDBUS_PART_FOREACH(d, k, items) {
+        KDBUS_ITEM_FOREACH(d, k, items) {
                 if (d->type >= _KDBUS_ITEM_KERNEL_BASE && d->type < _KDBUS_ITEM_KERNEL_BASE + ELEMENTSOF(translate)) {
                         if (found)
                                 return -EBADMSG;
@@ -619,7 +620,7 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k) {
         assert(k);
         assert(k->payload_type == KDBUS_PAYLOAD_DBUS1);
 
-        KDBUS_PART_FOREACH(d, k, items) {
+        KDBUS_ITEM_FOREACH(d, k, items) {
                 size_t l;
 
                 l = d->size - offsetof(struct kdbus_item, data);
@@ -679,7 +680,7 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k) {
         if (r < 0)
                 return r;
 
-        KDBUS_PART_FOREACH(d, k, items) {
+        KDBUS_ITEM_FOREACH(d, k, items) {
                 size_t l;
 
                 l = d->size - offsetof(struct kdbus_item, data);
@@ -800,9 +801,10 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k) {
                         destination = d->str;
                         break;
 
-                case KDBUS_ITEM_NAMES:
-                        m->creds.well_known_names = d->str;
-                        m->creds.well_known_names_size = l;
+                case KDBUS_ITEM_NAME:
+                        r = strv_extend(&m->creds.well_known_names, d->name.name);
+                        if (r < 0)
+                                goto fail;
                         m->creds.mask |= SD_BUS_CREDS_WELL_KNOWN_NAMES & bus->creds_mask;
                         break;
 
@@ -1061,11 +1063,10 @@ int bus_kernel_create_bus(const char *name, char **s) {
         n = make->items;
         sprintf(n->str, "%lu-%s", (unsigned long) getuid(), name);
         n->size = offsetof(struct kdbus_item, str) + strlen(n->str) + 1;
-        n->type = KDBUS_MAKE_NAME;
+        n->type = KDBUS_ITEM_MAKE_NAME;
 
         make->size = ALIGN8(offsetof(struct kdbus_cmd_bus_make, items) + n->size);
         make->flags = KDBUS_MAKE_POLICY_OPEN;
-        make->bus_flags = 0;
         make->bloom_size = BLOOM_SIZE;
         assert_cc(BLOOM_SIZE % 8 == 0);
 
@@ -1165,7 +1166,7 @@ int bus_kernel_create_namespace(const char *name, char **s) {
         n = make->items;
         strcpy(n->str, name);
         n->size = offsetof(struct kdbus_item, str) + strlen(n->str) + 1;
-        n->type = KDBUS_MAKE_NAME;
+        n->type = KDBUS_ITEM_MAKE_NAME;
 
         make->size = ALIGN8(offsetof(struct kdbus_cmd_ns_make, items) + n->size);
         make->flags = KDBUS_MAKE_POLICY_OPEN | KDBUS_MAKE_ACCESS_WORLD;