diff options
author | Daniel Mack <zonque@gmail.com> | 2014-01-22 13:24:58 +0100 |
---|---|---|
committer | Daniel Mack <zonque@gmail.com> | 2014-01-22 13:25:00 +0100 |
commit | ad03f64012a5b0422c9f4ca859d212fcfd452b8d (patch) | |
tree | 9837db5e52902677c4a45ca7d31336b3e4e14030 | |
parent | 0c37438cecbdee483ec51eedb3cf00a19325ccda (diff) | |
download | kdbus-bus-ad03f64012a5b0422c9f4ca859d212fcfd452b8d.tar.gz kdbus-bus-ad03f64012a5b0422c9f4ca859d212fcfd452b8d.tar.bz2 kdbus-bus-ad03f64012a5b0422c9f4ca859d212fcfd452b8d.zip |
Add KDBUS_CMD_CONN_UPDATE
Implement a method to update the connection's attach_flags at runtime.
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | connection.c | 20 | ||||
-rw-r--r-- | connection.h | 2 | ||||
-rw-r--r-- | handle.c | 10 | ||||
-rw-r--r-- | kdbus.h | 12 |
5 files changed, 44 insertions, 2 deletions
@@ -29,8 +29,6 @@ Features: for another connection, like a connection can have a maximum of 100 messages in-flight, but only 10 of them for the same connection - - allow to update the metadata subscription bit mask - - support the creation of anonymous buses - actually return compatible/incompatible flags to users diff --git a/connection.c b/connection.c index dfac9435abc..49f3d4651a4 100644 --- a/connection.c +++ b/connection.c @@ -1646,6 +1646,26 @@ exit: } /** + * kdbus_conn_update() - update flags for a connection + * @conn: Connection + * @buf: The struct containing the new flags + * + * Return: 0 on success, negative errno on failure. + */ +int kdbus_cmd_conn_update(struct kdbus_conn *conn, + void __user *buf) +{ + struct kdbus_cmd_conn_update cmd_update; + + if (copy_from_user(&cmd_update, buf, sizeof(cmd_update))) + return -EFAULT; + + conn->attach_flags = cmd_update.attach_flags; + + return 0; +} + +/** * kdbus_conn_new() - create a new connection * @ep: The endpoint the connection is connected to * @hello: The kdbus_cmd_hello as passed in by the user diff --git a/connection.h b/connection.h index 624cbd0de4e..c50d4266bee 100644 --- a/connection.h +++ b/connection.h @@ -97,6 +97,8 @@ int kdbus_conn_recv_msg_user(struct kdbus_conn *conn, struct kdbus_cmd_recv __user *recv); int kdbus_cmd_conn_info(struct kdbus_conn *conn, void __user *buf); +int kdbus_cmd_conn_update(struct kdbus_conn *conn, + void __user *buf); int kdbus_conn_kmsg_send(struct kdbus_ep *ep, struct kdbus_conn *conn_src, struct kdbus_kmsg *kmsg); @@ -577,6 +577,16 @@ static long kdbus_handle_ioctl_ep_connected(struct file *file, unsigned int cmd, ret = kdbus_cmd_conn_info(conn, buf); break; + case KDBUS_CMD_CONN_UPDATE: + /* update flags for a connection */ + if (!KDBUS_IS_ALIGNED8((uintptr_t)buf)) { + ret = -EFAULT; + break; + } + + ret = kdbus_cmd_conn_update(conn, buf); + break; + case KDBUS_CMD_MATCH_ADD: /* subscribe to/filter for broadcast messages */ if (!KDBUS_IS_ALIGNED8((uintptr_t)buf)) { @@ -692,6 +692,16 @@ struct kdbus_conn_info { }; /** + * struct kdbus_cmd_conn_update - update flags of a connection + * @attach_flags: The new attach flags + * + * This struct is used with the KDBUS_CMD_CONN_UPDATE ioctl. + */ +struct kdbus_cmd_conn_update { + __u64 attach_flags; +} __attribute__((aligned(8))); + +/** * struct kdbus_cmd_match - struct to add or remove matches * @size: The total size of the struct * @owner_id: Privileged users may (de)register matches on behalf @@ -767,6 +777,7 @@ struct kdbus_cmd_memfd_make { * stored at registration time and does not * necessarily represent the connected process or * the actual state of the process. + * @KDBUS_CMD_CONN_UPDATE: Update flags for a connection. * @KDBUS_CMD_MATCH_ADD: Install a match which broadcast messages should * be delivered to the connection. * @KDBUS_CMD_MATCH_REMOVE: Remove a current match for broadcast messages. @@ -817,6 +828,7 @@ enum kdbus_ioctl_type { KDBUS_CMD_NAME_LIST = _IOWR(KDBUS_IOC_MAGIC, 0x52, struct kdbus_cmd_name_list), KDBUS_CMD_CONN_INFO = _IOWR(KDBUS_IOC_MAGIC, 0x60, struct kdbus_cmd_conn_info), + KDBUS_CMD_CONN_UPDATE = _IOW (KDBUS_IOC_MAGIC, 0x61, struct kdbus_cmd_conn_update), KDBUS_CMD_MATCH_ADD = _IOW (KDBUS_IOC_MAGIC, 0x70, struct kdbus_cmd_match), KDBUS_CMD_MATCH_REMOVE = _IOW (KDBUS_IOC_MAGIC, 0x71, struct kdbus_cmd_match), |