#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"

vlong
pm_seek(int fd, vlong offset, int whence)
{
	File *f;
	off_t off;
	
	off = offset;
	if((vlong)off != offset){
		pm_werrstr("pm_seek offset does not fit in off_t");
		return -1;
	}
	if((f = pm_lockfile(fd, 0)) == nil)
		return -1;
	offset = lseek(f->ufd, offset, whence);
	pm_qunlock(&f->lk);
	if(offset < 0)
		pm_oserror();
	return offset;
}
