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

int
wstat(char *file, uchar *edir, int nedir)
{
	char *path;
	volatile long m;
	Mnt *mnt;
	Dir dir;

	if(convM2D(edir, nedir, &dir, (char*)edir) < 0)
		return -1;
	if((path = nsassign(file, &mnt, nil)) == nil)
		return -1;
	checkerrstack();
	m = -1;
	if(!waserror()){
		(*mnt->dev->_wstat)(mnt, path, &dir);
		m = 0;
		poperror();
	}
	mntclose(mnt);
	free(path);
	checkerrstack();
	return m;
}
