io_uring: make io_kiocb_to_cmd() typesafe
[linux-block.git] / io_uring / openclose.c
index d1818ec9169ba2690526061637ecbb771d2688a0..67178e4bb282d541a69d096241fa7065a4c8a7c6 100644 (file)
@@ -33,7 +33,7 @@ struct io_close {
 
 static int __io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 {
-       struct io_open *open = io_kiocb_to_cmd(req);
+       struct io_open *open = io_kiocb_to_cmd(req, struct io_open);
        const char __user *fname;
        int ret;
 
@@ -66,7 +66,7 @@ static int __io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe
 
 int io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 {
-       struct io_open *open = io_kiocb_to_cmd(req);
+       struct io_open *open = io_kiocb_to_cmd(req, struct io_open);
        u64 mode = READ_ONCE(sqe->len);
        u64 flags = READ_ONCE(sqe->open_flags);
 
@@ -76,7 +76,7 @@ int io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 
 int io_openat2_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 {
-       struct io_open *open = io_kiocb_to_cmd(req);
+       struct io_open *open = io_kiocb_to_cmd(req, struct io_open);
        struct open_how __user *how;
        size_t len;
        int ret;
@@ -95,7 +95,7 @@ int io_openat2_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 
 int io_openat2(struct io_kiocb *req, unsigned int issue_flags)
 {
-       struct io_open *open = io_kiocb_to_cmd(req);
+       struct io_open *open = io_kiocb_to_cmd(req, struct io_open);
        struct open_flags op;
        struct file *file;
        bool resolve_nonblock, nonblock_set;
@@ -167,7 +167,7 @@ int io_openat(struct io_kiocb *req, unsigned int issue_flags)
 
 void io_open_cleanup(struct io_kiocb *req)
 {
-       struct io_open *open = io_kiocb_to_cmd(req);
+       struct io_open *open = io_kiocb_to_cmd(req, struct io_open);
 
        if (open->filename)
                putname(open->filename);
@@ -187,14 +187,14 @@ int __io_close_fixed(struct io_ring_ctx *ctx, unsigned int issue_flags,
 
 static inline int io_close_fixed(struct io_kiocb *req, unsigned int issue_flags)
 {
-       struct io_close *close = io_kiocb_to_cmd(req);
+       struct io_close *close = io_kiocb_to_cmd(req, struct io_close);
 
        return __io_close_fixed(req->ctx, issue_flags, close->file_slot - 1);
 }
 
 int io_close_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 {
-       struct io_close *close = io_kiocb_to_cmd(req);
+       struct io_close *close = io_kiocb_to_cmd(req, struct io_close);
 
        if (sqe->off || sqe->addr || sqe->len || sqe->rw_flags || sqe->buf_index)
                return -EINVAL;
@@ -212,7 +212,7 @@ int io_close_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 int io_close(struct io_kiocb *req, unsigned int issue_flags)
 {
        struct files_struct *files = current->files;
-       struct io_close *close = io_kiocb_to_cmd(req);
+       struct io_close *close = io_kiocb_to_cmd(req, struct io_close);
        struct fdtable *fdt;
        struct file *file;
        int ret = -EBADF;