From 622372a53c2b08ba53425dddc55cdf66b71b5b05 Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Tue, 21 Oct 2014 18:59:23 +0200 Subject: [PATCH] kdbus.h: factor out name info struct (ABI break) Introduce struct kdbus_name_info and report information on name lists with it, instead of (ab)using struct kdbus_cmd_name for it. That way, we can get rid of two fields in the latter. Signed-off-by: Daniel Mack --- kdbus.h | 23 +++++++++++++++++++---- names.c | 8 ++++---- test/kdbus-util.c | 2 +- test/test-names.c | 2 +- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/kdbus.h b/kdbus.h index e1fa21d..b255f37 100644 --- a/kdbus.h +++ b/kdbus.h @@ -631,8 +631,6 @@ enum kdbus_name_flags { * struct kdbus_cmd_name - struct to describe a well-known name * @size: The total size of the struct * @flags: Flags for a name entry (KDBUS_NAME_*) - * @owner_id: The current owner of the name - * @conn_flags: The flags of the owning connection (KDBUS_HELLO_*) * @items: Item list, containing the well-known name as * KDBUS_ITEM_NAME * @@ -641,8 +639,25 @@ enum kdbus_name_flags { struct kdbus_cmd_name { __u64 size; __u64 flags; - __u64 owner_id; + struct kdbus_item items[0]; +} __attribute__((aligned(8))); + +/** + * struct kdbus_name_info - struct to describe a well-known name + * @size: The total size of the struct + * @flags: Flags for a name entry (KDBUS_NAME_*), + * @conn_flags: The flags of the owning connection (KDBUS_HELLO_*) + * @owner_id: The current owner of the name + * @items: Item list, containing the well-known name as + * KDBUS_ITEM_NAME + * + * This structure is used as return struct for the KDBUS_CMD_NAME_LIST ioctl. + */ +struct kdbus_name_info { + __u64 size; + __u64 flags; __u64 conn_flags; + __u64 owner_id; struct kdbus_item items[0]; } __attribute__((aligned(8))); @@ -684,7 +699,7 @@ struct kdbus_cmd_name_list { */ struct kdbus_name_list { __u64 size; - struct kdbus_cmd_name names[0]; + struct kdbus_name_info names[0]; }; /** diff --git a/names.c b/names.c index e0a7760..02efef3 100644 --- a/names.c +++ b/names.c @@ -705,7 +705,7 @@ static int kdbus_name_list_write(struct kdbus_conn *conn, struct kdbus_name_entry *e, bool write) { - const size_t len = sizeof(struct kdbus_cmd_name); + const size_t len = sizeof(struct kdbus_name_info); size_t p = *pos; size_t nlen = 0; @@ -719,7 +719,7 @@ static int kdbus_name_list_write(struct kdbus_conn *conn, if (write) { int ret; - struct kdbus_cmd_name n = { + struct kdbus_name_info info = { .size = len, .owner_id = c->id, .flags = e ? e->flags : 0, @@ -727,10 +727,10 @@ static int kdbus_name_list_write(struct kdbus_conn *conn, }; if (nlen) - n.size += KDBUS_ITEM_SIZE(nlen); + info.size += KDBUS_ITEM_SIZE(nlen); /* write record */ - ret = kdbus_pool_slice_copy(slice, p, &n, len); + ret = kdbus_pool_slice_copy(slice, p, &info, len); if (ret < 0) return ret; p += len; diff --git a/test/kdbus-util.c b/test/kdbus-util.c index 52b4c47..f3a2144 100644 --- a/test/kdbus-util.c +++ b/test/kdbus-util.c @@ -875,7 +875,7 @@ int kdbus_name_list(struct kdbus_conn *conn, uint64_t flags) { struct kdbus_cmd_name_list cmd_list; struct kdbus_name_list *list; - struct kdbus_cmd_name *name; + struct kdbus_name_info *name; int ret; cmd_list.flags = flags; diff --git a/test/test-names.c b/test/test-names.c index 24eda14..fb7e90b 100644 --- a/test/test-names.c +++ b/test/test-names.c @@ -22,7 +22,7 @@ static int conn_is_name_owner(const struct kdbus_conn *conn, { struct kdbus_cmd_name_list cmd_list; struct kdbus_name_list *list; - struct kdbus_cmd_name *name; + struct kdbus_name_info *name; bool found = false; int ret; -- 2.34.1