#include <9pm/u.h>
#include <9pm/libc.h>
#include <9pm/fcall.h>
#include <9pm/thread.h>
#include <9pm/9p.h>

long
readbuf(vlong off, void *dst, long dlen, void *src, long slen)
{
	if(off >= slen)
		return 0;
	if(off+dlen > slen)
		dlen = slen-off;
	memmove(dst, (char*)src+off, dlen);
	return dlen;
}

long
readstr(vlong off, void *dst, long dlen, char *src)
{
	return readbuf(off, dst, dlen, src, strlen(src));
}
