#include #include #include #include #include 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); }