diff options
author | Jens Axboe <axboe@kernel.dk> | 2019-06-04 20:35:44 -0600 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2019-06-04 20:35:44 -0600 |
commit | 9f44fb0e64e68c304d71c1cc21ddb1de7772c1c4 (patch) | |
tree | d77e6e9ec070f76b26d2766e6e8c6ff2e7ae82ac /src/register.c | |
parent | b4b3d8c97b2de68e2bbac5f5a37988677c44302a (diff) | |
download | liburing-9f44fb0e64e68c304d71c1cc21ddb1de7772c1c4.tar.gz liburing-9f44fb0e64e68c304d71c1cc21ddb1de7772c1c4.tar.bz2 |
Add basic helpers for file/buffer registration
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'src/register.c')
-rw-r--r-- | src/register.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/register.c b/src/register.c new file mode 100644 index 0000000..e352291 --- /dev/null +++ b/src/register.c @@ -0,0 +1,60 @@ +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/mman.h> +#include <unistd.h> +#include <errno.h> +#include <string.h> + +#include "compat.h" +#include "io_uring.h" +#include "liburing.h" + +int io_uring_register_buffers(struct io_uring *ring, struct iovec *iovecs, + unsigned nr_iovecs) +{ + int ret; + + ret = io_uring_register(ring->ring_fd, IORING_REGISTER_BUFFERS, + iovecs, nr_iovecs); + if (ret < 0) + return -errno; + + return 0; +} + +int io_uring_unregister_buffers(struct io_uring *ring) +{ + int ret; + + ret = io_uring_register(ring->ring_fd, IORING_UNREGISTER_BUFFERS, NULL, + 0); + if (ret < 0) + return -errno; + + return 0; +} + +int io_uring_register_files(struct io_uring *ring, __s32 *files, + unsigned nr_files) +{ + int ret; + + ret = io_uring_register(ring->ring_fd, IORING_REGISTER_FILES, files, + nr_files); + if (ret < 0) + return -errno; + + return 0; +} + +int io_uring_unregister_files(struct io_uring *ring) +{ + int ret; + + ret = io_uring_register(ring->ring_fd, IORING_UNREGISTER_FILES, NULL, + 0); + if (ret < 0) + return -errno; + + return 0; +} |