summaryrefslogtreecommitdiff
path: root/src/kernel/arch/amd64/driver/serial.c
diff options
context:
space:
mode:
authordzwdz2023-01-25 01:02:04 +0100
committerdzwdz2023-01-25 01:04:49 +0100
commit2a2fc4dffe0117ce874a6cf1dcc34321ed8add77 (patch)
treeaf1e24f72241dbbff97797b9e186f7d27b5b54b4 /src/kernel/arch/amd64/driver/serial.c
parent52e7fe3c679469032e77a5ca4adf19618ba1201b (diff)
kernel/virt: replace the virt_cpy api with a more foolproof one
Diffstat (limited to 'src/kernel/arch/amd64/driver/serial.c')
-rw-r--r--src/kernel/arch/amd64/driver/serial.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/kernel/arch/amd64/driver/serial.c b/src/kernel/arch/amd64/driver/serial.c
index 295f9b8..12c4151 100644
--- a/src/kernel/arch/amd64/driver/serial.c
+++ b/src/kernel/arch/amd64/driver/serial.c
@@ -73,13 +73,14 @@ static void accept(struct vfs_request *req) {
break;
case VFSOP_WRITE:
if (req->caller && !req->flags) {
- struct virt_iter iter;
- virt_iter_new(&iter, req->input.buf, req->input.len,
- req->caller->pages, true, false);
- while (virt_iter_next(&iter))
- serial_write(iter.frag, iter.frag_len);
- ret = iter.prior;
- } else ret = -1;
+ char buf[4096];
+ size_t len = min(sizeof buf, req->input.len);
+ len = pcpy_from(req->caller, buf, req->input.buf, len);
+ serial_write(buf, len);
+ ret = len;
+ } else {
+ ret = -1;
+ }
vfsreq_finish_short(req, ret);
break;
default: