diff --git a/src/vol/ntops.c b/src/vol/ntops.c index 715480d5ee..645be227ea 100644 --- a/src/vol/ntops.c +++ b/src/vol/ntops.c @@ -322,15 +322,30 @@ nt_fsync(FD_t fd) int -nt_seek(FD_t fd, afs_foff_t off, int where) +nt_seek(FD_t fd, afs_foff_t off, int whence) { int code; LARGE_INTEGER offset; + int where; + if (SEEK_SET == whence) { + where = FILE_BEGIN; + } else if (SEEK_END == whence) { + where = FILE_END; + } else if (SEEK_CUR == whence) { + where = FILE_CURRENT; + } else { + errno = EINVAL; + return -1; + } offset.QuadPart = off; code = SetFilePointerEx(fd, offset, NULL, where); - return code; + if (0 == code) { + errno = nterr_nt2unix(GetLastError(), EBADF); + return -1; + } + return 0; } /* nt_DevToDrive diff --git a/src/vol/ntops.h b/src/vol/ntops.h index 6661979106..e50b2e0fdc 100644 --- a/src/vol/ntops.h +++ b/src/vol/ntops.h @@ -34,7 +34,7 @@ extern int nt_setFileCreationTime(FD_t fd, FILETIME * ftime); extern int nt_sync(int cdrive); extern int nt_ftruncate(FD_t fd, afs_foff_t len); extern int nt_fsync(FD_t fd); -extern int nt_seek(FD_t fd, afs_foff_t off, int where); +extern int nt_seek(FD_t fd, afs_foff_t off, int whence); extern FILE *nt_fdopen(IHandle_t * h, char *fdperms); extern int nt_unlink(char *name);