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: Pavel Begunkov <asml.silence@gmail.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>pull/1354/merge
parent
c2685729fa
commit
da8bc3c81c
|
|
@ -874,6 +874,23 @@ struct file *io_uring_register_get_file(unsigned int fd, bool registered)
|
||||||
return ERR_PTR(-EOPNOTSUPP);
|
return ERR_PTR(-EOPNOTSUPP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int io_uring_register_send_msg_ring(void __user *arg, unsigned int nr_args)
|
||||||
|
{
|
||||||
|
struct io_uring_sqe sqe;
|
||||||
|
|
||||||
|
if (!arg || nr_args != 1)
|
||||||
|
return -EINVAL;
|
||||||
|
if (copy_from_user(&sqe, arg, sizeof(sqe)))
|
||||||
|
return -EFAULT;
|
||||||
|
/* no flags supported */
|
||||||
|
if (sqe.flags)
|
||||||
|
return -EINVAL;
|
||||||
|
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
|
* "blind" registration opcodes are ones where there's no ring given, and
|
||||||
* hence the source fd must be -1.
|
* hence the source fd must be -1.
|
||||||
|
|
@ -882,21 +899,9 @@ static int io_uring_register_blind(unsigned int opcode, void __user *arg,
|
||||||
unsigned int nr_args)
|
unsigned int nr_args)
|
||||||
{
|
{
|
||||||
switch (opcode) {
|
switch (opcode) {
|
||||||
case IORING_REGISTER_SEND_MSG_RING: {
|
case IORING_REGISTER_SEND_MSG_RING:
|
||||||
struct io_uring_sqe sqe;
|
return io_uring_register_send_msg_ring(arg, nr_args);
|
||||||
|
|
||||||
if (!arg || nr_args != 1)
|
|
||||||
return -EINVAL;
|
|
||||||
if (copy_from_user(&sqe, arg, sizeof(sqe)))
|
|
||||||
return -EFAULT;
|
|
||||||
/* no flags supported */
|
|
||||||
if (sqe.flags)
|
|
||||||
return -EINVAL;
|
|
||||||
if (sqe.opcode == IORING_OP_MSG_RING)
|
|
||||||
return io_uring_sync_msg_ring(&sqe);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue