bus: sync with kdbus.git

Sync up with recent kdbus changed:
 * several ioctls gained .size and .items members (but still unused)
 * CMD_SEND gained its own ioctl structure
 * several members of kdbus_msg were dropped as they were only used during
   SEND, not during RECV etc.
 * CMD_RECV and CMD_SEND now share a kdbus_reply member which contains the
   offset and size of the returned message.
This commit is contained in:
David Herrmann
2014-12-11 13:19:41 +01:00
parent 055b27f294
commit 94e15fdc4d
4 changed files with 191 additions and 112 deletions
+6 -5
View File
@@ -727,6 +727,7 @@ _pure_ static const char *busname_sub_state_to_string(Unit *u) {
static int busname_peek_message(BusName *n) {
struct kdbus_cmd_recv cmd_recv = {
.size = sizeof(cmd_recv),
.flags = KDBUS_RECV_PEEK,
};
struct kdbus_cmd_free cmd_free = {};
@@ -750,7 +751,7 @@ static int busname_peek_message(BusName *n) {
if (log_get_max_level() < LOG_DEBUG)
return 0;
r = ioctl(n->starter_fd, KDBUS_CMD_MSG_RECV, &cmd_recv);
r = ioctl(n->starter_fd, KDBUS_CMD_RECV, &cmd_recv);
if (r < 0) {
if (errno == EINTR || errno == EAGAIN)
return 0;
@@ -766,9 +767,9 @@ static int busname_peek_message(BusName *n) {
* longer than necessary. */
ps = page_size();
start = (cmd_recv.offset / ps) * ps;
delta = cmd_recv.offset - start;
sz = PAGE_ALIGN(delta + cmd_recv.msg_size);
start = (cmd_recv.reply.offset / ps) * ps;
delta = cmd_recv.reply.offset - start;
sz = PAGE_ALIGN(delta + cmd_recv.reply.msg_size);
p = mmap(NULL, sz, PROT_READ, MAP_SHARED, n->starter_fd, start);
if (p == MAP_FAILED) {
@@ -800,7 +801,7 @@ finish:
if (p)
(void) munmap(p, sz);
cmd_free.offset = cmd_recv.offset;
cmd_free.offset = cmd_recv.reply.offset;
if (ioctl(n->starter_fd, KDBUS_CMD_FREE, &cmd_free) < 0)
log_unit_warning(UNIT(n)->id, "Failed to free peeked message, ignoring: %m");