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

int
fstat(int fd, uchar *edir, int nedir)
{
	volatile long m;
	volatile Chan *c;

	c = nil;
	checkerrstack();
	m = -1;
	if(!waserror()){
		c = fd2chan(fd, -1);
		m = (*c->mnt->dev->_fstat)(c, edir, nedir);
		validstat(edir, m);
		mntdirfix(edir, c->mnt);
		poperror();
	}
	if(c)
		cclose(c);
	checkerrstack();
	return m;
}
