diff options
author | Jens Axboe <axboe@kernel.dk> | 2019-10-04 13:23:48 -0600 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2019-10-04 13:23:48 -0600 |
commit | 62cab776274862842d21984b583ed54cee5cd0f2 (patch) | |
tree | b3b29ba09a627907aa9c8d46fbb8cb0cc3005221 /src/setup.c | |
parent | d21cb864b5ae136c8d3de6fd56897f148d3bdf50 (diff) | |
download | liburing-62cab776274862842d21984b583ed54cee5cd0f2.tar.gz liburing-62cab776274862842d21984b583ed54cee5cd0f2.tar.bz2 |
Add io_uring_queue_init_params()
Like io_uring_queue_init(), but allows passing in the whole parameter
structure, not just the flags.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'src/setup.c')
-rw-r--r-- | src/setup.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/setup.c b/src/setup.c index dda4d1c..a52071b 100644 --- a/src/setup.c +++ b/src/setup.c @@ -94,6 +94,22 @@ int io_uring_queue_mmap(int fd, struct io_uring_params *p, struct io_uring *ring return ret; } +int io_uring_queue_init_params(unsigned entries, struct io_uring *ring, + struct io_uring_params *p) +{ + int fd, ret; + + fd = io_uring_setup(entries, p); + if (fd < 0) + return -errno; + + ret = io_uring_queue_mmap(fd, p, ring); + if (ret) + close(fd); + + return ret; +} + /* * Returns -1 on error, or zero on success. On success, 'ring' * contains the necessary information to read/write to the rings. @@ -101,20 +117,11 @@ int io_uring_queue_mmap(int fd, struct io_uring_params *p, struct io_uring *ring int io_uring_queue_init(unsigned entries, struct io_uring *ring, unsigned flags) { struct io_uring_params p; - int fd, ret; memset(&p, 0, sizeof(p)); p.flags = flags; - fd = io_uring_setup(entries, &p); - if (fd < 0) - return -errno; - - ret = io_uring_queue_mmap(fd, &p, ring); - if (ret) - close(fd); - - return ret; + return io_uring_queue_init_params(entries, ring, &p); } void io_uring_queue_exit(struct io_uring *ring) |