Rather than passing a pointer to a u64 with these ioctls, use a struct.
That also allows us to pass (currently unused) flags around.
Signed-off-by: Daniel Mack <daniel@zonque.org>
}
case KDBUS_CMD_MSG_CANCEL: {
- u64 cookie;
+ struct kdbus_cmd_cancel cmd_cancel;
if (!kdbus_conn_is_connected(conn)) {
ret = -EOPNOTSUPP;
}
/* cancel sync message send requests by cookie */
- if (copy_from_user(&cookie, buf, sizeof(cookie))) {
+ if (copy_from_user(&cmd_cancel, buf, sizeof(cmd_cancel))) {
ret = -EFAULT;
break;
}
- ret = kdbus_cmd_msg_cancel(conn, cookie);
+ ret = kdbus_cmd_msg_cancel(conn, cmd_cancel.cookie);
break;
}
case KDBUS_CMD_FREE: {
- u64 off;
+ struct kdbus_cmd_free cmd_free;
if (!kdbus_conn_is_connected(conn) &&
!kdbus_conn_is_monitor(conn)) {
}
/* free the memory used in the receiver's pool */
- if (copy_from_user(&off, buf, sizeof(off))) {
+ if (copy_from_user(&cmd_free, buf, sizeof(cmd_free))) {
ret = -EFAULT;
break;
}
- ret = kdbus_pool_release_offset(conn->pool, off);
+ ret = kdbus_pool_release_offset(conn->pool, cmd_free.offset);
break;
}
__u64 offset;
} __attribute__((aligned(8)));
+/**
+ * struct kdbus_cmd_cancel - struct to cancel a synchronously pending message
+ * @cookie The cookie of the pending message
+ * @flags Flags for the free command. Currently unused.
+ *
+ * This struct is used with the KDBUS_CMD_CANCEL ioctl.
+ */
+struct kdbus_cmd_cancel {
+ __u64 cookie;
+ __u64 flags;
+} __attribute__((aligned(8)));
+
+/**
+ * struct kdbus_cmd_free - struct to free a slice of memory in the pool
+ * @offset The offset of the memory slice, as returned by other
+ * ioctls
+ * @flags Flags for the free command. Currently unused.
+ *
+ * This struct is used with the KDBUS_CMD_FREE ioctl.
+ */
+struct kdbus_cmd_free {
+ __u64 offset;
+ __u64 flags;
+} __attribute__((aligned(8)));
+
/**
* enum kdbus_policy_access_type - permissions of a policy record
* @_KDBUS_POLICY_ACCESS_NULL: Uninitialized/invalid
*/
struct kdbus_cmd_update {
__u64 size;
+ __u64 flags;
struct kdbus_item items[0];
} __attribute__((aligned(8)));
struct kdbus_msg),
KDBUS_CMD_MSG_RECV = _IOWR(KDBUS_IOCTL_MAGIC, 0x41,
struct kdbus_cmd_recv),
- KDBUS_CMD_MSG_CANCEL = _IOW(KDBUS_IOCTL_MAGIC, 0x42, __u64 *),
- KDBUS_CMD_FREE = _IOW(KDBUS_IOCTL_MAGIC, 0x43, __u64 *),
+ KDBUS_CMD_MSG_CANCEL = _IOW(KDBUS_IOCTL_MAGIC, 0x42,
+ struct kdbus_cmd_cancel),
+ KDBUS_CMD_FREE = _IOW(KDBUS_IOCTL_MAGIC, 0x43,
+ struct kdbus_cmd_free),
KDBUS_CMD_NAME_ACQUIRE = _IOWR(KDBUS_IOCTL_MAGIC, 0x50,
struct kdbus_cmd_name),
int kdbus_free(const struct kdbus_conn *conn, uint64_t offset)
{
+ struct kdbus_cmd_free cmd_free;
int ret;
- ret = ioctl(conn->fd, KDBUS_CMD_FREE, &offset);
+ cmd_free.offset = offset;
+ cmd_free.flags = 0;
+
+ ret = ioctl(conn->fd, KDBUS_CMD_FREE, &cmd_free);
if (ret < 0) {
kdbus_printf("KDBUS_CMD_FREE failed: %d (%m)\n", ret);
return -errno;
int kdbus_test_free(struct kdbus_test_env *env)
{
int ret;
- uint64_t off = 0;
+ struct kdbus_cmd_free cmd_free;
+
+ cmd_free.flags = 0;
+ cmd_free.offset = 0;
/* free an unallocated buffer */
- ret = ioctl(env->conn->fd, KDBUS_CMD_FREE, &off);
+ ret = ioctl(env->conn->fd, KDBUS_CMD_FREE, &cmd_free);
ASSERT_RETURN(ret == -1 && errno == ENXIO);
/* free a buffer out of the pool's bounds */
- off = POOL_SIZE + 1;
- ret = ioctl(env->conn->fd, KDBUS_CMD_FREE, &off);
+ cmd_free.offset = POOL_SIZE + 1;
+ ret = ioctl(env->conn->fd, KDBUS_CMD_FREE, &cmd_free);
ASSERT_RETURN(ret == -1 && errno == ENXIO);
return TEST_OK;