#include <sys/types.h>
#include <dirent.h>
#include <sys/time.h> 
#include <unistd.h>
#include <sys/stat.h>
#include <errno.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <sys/socket.h>

#define NODEFINE
#include <u.h>
#include <libc.h>
#include <fcall.h>
#include "fd.h"

long
pm_write(int fd, void *a, long n)
{
	File *f;
	
	if((f = pm_lockfile(fd, 0)) == nil)
		return -1;

	switch(f->type){
	default:
		pm_werrstr("cannot happen in pm_write");
		pm_qunlock(&f->lk);
		return -1;
	case Tfile:
	case Tpipe:
		pm_qunlock(&f->lk);
		return write(f->ufd, a, n);
	}
}
