1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#include <camellia/fsutil.h>
#include <kernel/arch/amd64/driver/util.h>
#include <kernel/panic.h>
#include <kernel/proc.h>
#include <kernel/vfs/request.h>
int req_readcopy(VfsReq *req, const void *buf, size_t len) {
if (!req->caller) return -1;
assert(req->type == VFSOP_READ);
fs_normslice(&req->offset, &req->outlen, len, false);
/* read errors are ignored. TODO write a spec */
pcpy_to(req->caller, req->out, buf + req->offset, req->outlen);
return req->outlen;
}
size_t ring_to_virt(ring_t *r, Proc *proc, void __user *ubuf, size_t max) {
char tmp[32];
if (max > sizeof tmp) max = sizeof tmp;
max = ring_get(r, tmp, max);
return pcpy_to(proc, ubuf, tmp, max);
}
|