summaryrefslogtreecommitdiff
path: root/src/kernel/arch/amd64/driver/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/arch/amd64/driver/util.c')
-rw-r--r--src/kernel/arch/amd64/driver/util.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/kernel/arch/amd64/driver/util.c b/src/kernel/arch/amd64/driver/util.c
new file mode 100644
index 0000000..b03e582
--- /dev/null
+++ b/src/kernel/arch/amd64/driver/util.c
@@ -0,0 +1,16 @@
+#include <camellia/fsutil.h>
+#include <kernel/arch/amd64/driver/util.h>
+#include <kernel/mem/virt.h>
+#include <kernel/panic.h>
+#include <kernel/vfs/request.h>
+
+int req_readcopy(struct vfs_request *req, const void *buf, size_t len) {
+ if (!req->caller) return -1;
+ assert(req->type == VFSOP_READ);
+ fs_normslice(&req->offset, &req->output.len, len, false);
+ virt_cpy_to(
+ req->caller->pages, req->output.buf,
+ buf + req->offset, req->output.len);
+ /* read errors are ignored. TODO write a spec */
+ return req->output.len;
+}