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

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

	if(convM2D(edir, nedir, &d, (char*)edir) < 0)
		return -1;
	checkerrstack();
	m = -1;
	c = nil;
	if(!waserror()){
		c = fd2chan(fd, -1);
		(*c->mnt->dev->_fwstat)(c, &d);
		m = 0;
		poperror();
	}
	if(c)
		cclose(c);
	checkerrstack();
	return m;
}
