Commit da8bc3c8 authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe
Browse files

io_uring: add helper for *REGISTER_SEND_MSG_RING



Move handling of IORING_REGISTER_SEND_MSG_RING into a separate function
in preparation to growing io_uring_register_blind().

Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent c2685729
Loading
Loading
Loading
Loading
+19 −14
Original line number Diff line number Diff line
@@ -874,15 +874,8 @@ struct file *io_uring_register_get_file(unsigned int fd, bool registered)
	return ERR_PTR(-EOPNOTSUPP);
}

/*
 * "blind" registration opcodes are ones where there's no ring given, and
 * hence the source fd must be -1.
 */
static int io_uring_register_blind(unsigned int opcode, void __user *arg,
				   unsigned int nr_args)
static int io_uring_register_send_msg_ring(void __user *arg, unsigned int nr_args)
{
	switch (opcode) {
	case IORING_REGISTER_SEND_MSG_RING: {
	struct io_uring_sqe sqe;

	if (!arg || nr_args != 1)
@@ -892,11 +885,23 @@ static int io_uring_register_blind(unsigned int opcode, void __user *arg,
	/* no flags supported */
	if (sqe.flags)
		return -EINVAL;
		if (sqe.opcode == IORING_OP_MSG_RING)
	if (sqe.opcode != IORING_OP_MSG_RING)
		return -EINVAL;

	return io_uring_sync_msg_ring(&sqe);
}
	}

/*
 * "blind" registration opcodes are ones where there's no ring given, and
 * hence the source fd must be -1.
 */
static int io_uring_register_blind(unsigned int opcode, void __user *arg,
				   unsigned int nr_args)
{
	switch (opcode) {
	case IORING_REGISTER_SEND_MSG_RING:
		return io_uring_register_send_msg_ring(arg, nr_args);
	}
	return -EINVAL;
}