summaryrefslogtreecommitdiff
path: root/uring.c
diff options
context:
space:
mode:
Diffstat (limited to 'uring.c')
-rw-r--r--uring.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/uring.c b/uring.c
index c43a8fb..96e3a67 100644
--- a/uring.c
+++ b/uring.c
@@ -142,6 +142,25 @@ uring_close(struct cfg *cfg, struct uring_task *task, int fd, callback_t callbac
}
void
+uring_write(struct cfg *cfg, struct uring_task *task, void *buf, size_t len, callback_t callback)
+{
+ struct io_uring_sqe *sqe = io_uring_get_sqe(&cfg->uev->uring);
+
+ if (!sqe)
+ perrordie("io_uring_sqe");
+
+ if (task->fd < 0) {
+ error("uring_write called with no fd set\n");
+ return;
+ }
+
+ uring_task_get(cfg, task);
+ task->callback = callback;
+ io_uring_prep_write(sqe, task->fd, buf, len, 0);
+ io_uring_sqe_set_data(sqe, task);
+}
+
+void
uring_read(struct cfg *cfg, struct uring_task *task, void *buf, size_t len, off_t offset, callback_t callback)
{
struct io_uring_sqe *sqe = io_uring_get_sqe(&cfg->uev->uring);