ref: 7c833a3c106a59a08c33cff86c8239670e9055a6
parent: dc6dce6c9a255ba6a5c587798295374e5a4e2ac4
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Mar 9 22:49:21 EDT 2024
freplay: allow reading from vlong-sized buffers
--- a/test/freplay.c
+++ b/test/freplay.c
@@ -56,12 +56,25 @@
}
void
+readmembuf(Req *r, void *s, vlong n)
+{
+ r->ofcall.count = r->ifcall.count;
+ if(r->ifcall.offset >= n){
+ r->ofcall.count = 0;
+ return;
+ }
+ if(r->ifcall.offset+r->ofcall.count > n)
+ r->ofcall.count = n - r->ifcall.offset;
+ memmove(r->ofcall.data, (char*)s+r->ifcall.offset, r->ofcall.count);
+}
+
+void
fsread(Req *r)
{
char buf[128];
if(r->fid->file == datfile){
- readbuf(r, membuf, membufsz);
+ readmembuf(r, membuf, membufsz);
respond(r, nil);
}else if(r->fid->file == ctlfile){
snprint(buf, sizeof(buf), "writes %lld\n", nwrites);