kdbus.h: factor out name info struct (ABI break)
authorDaniel Mack <daniel@zonque.org>
Tue, 21 Oct 2014 16:59:23 +0000 (18:59 +0200)
committerDaniel Mack <daniel@zonque.org>
Tue, 21 Oct 2014 17:04:23 +0000 (19:04 +0200)
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 <daniel@zonque.org>
kdbus.h
names.c
test/kdbus-util.c
test/test-names.c

diff --git a/kdbus.h b/kdbus.h
index e1fa21dee0d9b1fa11e33cff1d7d5ea1f760b8a9..b255f37b86e5b5b15efdb36e24b2b7d4821fe441 100644 (file)
--- 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 e0a7760c992c0241da70cdcb994148e61325ffa4..02efef39fddbcd105da7e608cab253c636800788 100644 (file)
--- 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;
index 52b4c47d81ce2c209ca2b25ba9f51c5e73108f0f..f3a21444b81608abbd3ccb12b8a1058e7b461d9f 100644 (file)
@@ -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;
index 24eda14471d3184410ba49f9a3c30da967138eab..fb7e90b82933b3a2749601480c667b6cf8f16e52 100644 (file)
@@ -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;