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

long
pread(int fd, void *a, long n, vlong o)
{
	volatile Chan *c;
	volatile long m;

	checkerrstack();
	m = -1;
	c = nil;
	if(!waserror()){
		c = fd2chan(fd, OREAD);
		m = (*c->mnt->dev->_pread)(c, a, n, o);
		poperror();
	}
	if(c)
		cclose(c);
	checkerrstack();
	return m;
}
