From 3c25ae062a30c83f6dfb388f31878555d6cb63d7 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Thu, 20 Jan 2011 02:09:44 -0500 Subject: [PATCH] vol: Make ntops functions 64-bit capable Add 64-bit offset and length support to ntops functions. Change-Id: I1804d49df344839598c39084b7763cec4100c8c7 Reviewed-on: http://gerrit.openafs.org/3708 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/vol/ntops.c | 34 +++++++++++++++++++++++----------- src/vol/ntops.h | 14 +++++++------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/vol/ntops.c b/src/vol/ntops.c index 905c4e7c54..651ba29419 100644 --- a/src/vol/ntops.c +++ b/src/vol/ntops.c @@ -172,7 +172,7 @@ nt_close(FD_t fd) } int -nt_write(FD_t fd, char *buf, size_t size) +nt_write(FD_t fd, char *buf, afs_sfsize_t size) { BOOL code; DWORD nbytes; @@ -187,7 +187,7 @@ nt_write(FD_t fd, char *buf, size_t size) } int -nt_pwrite(FD_t fd, const void * buf, size_t count, afs_foff_t offset) +nt_pwrite(FD_t fd, const void * buf, afs_sfsize_t count, afs_foff_t offset) { /* * same comment as read @@ -212,7 +212,7 @@ nt_pwrite(FD_t fd, const void * buf, size_t count, afs_foff_t offset) } int -nt_read(FD_t fd, char *buf, size_t size) +nt_read(FD_t fd, char *buf, afs_sfsize_t size) { BOOL code; DWORD nbytes; @@ -230,7 +230,7 @@ nt_read(FD_t fd, char *buf, size_t size) } int -nt_pread(FD_t fd, void * buf, size_t count, afs_foff_t offset) +nt_pread(FD_t fd, void * buf, afs_sfsize_t count, afs_foff_t offset) { /* * This really ought to call NtReadFile @@ -259,15 +259,18 @@ nt_pread(FD_t fd, void * buf, size_t count, afs_foff_t offset) return (ssize_t)nbytes; } -int +afs_sfsize_t nt_size(FD_t fd) { BY_HANDLE_FILE_INFORMATION finfo; + LARGE_INTEGER FileSize; if (!GetFileInformationByHandle(fd, &finfo)) return -1; - return finfo.nFileSizeLow; + FileSize.HighPart = finfo.nFileSizeHigh; + FileSize.LowPart = finfo.nFileSizeLow; + return FileSize.QuadPart; } @@ -322,10 +325,14 @@ nt_sync(int cdrive) /* Currently nt_ftruncate only tested to shrink a file. */ int -nt_ftruncate(FD_t fd, int len) +nt_ftruncate(FD_t fd, afs_foff_t len) { - if (SetFilePointer(fd, (LONG) len, NULL, FILE_BEGIN) - == 0xffffffff) { + LARGE_INTEGER length; + + length.QuadPart = len; + + if (SetFilePointerEx(fd, length, NULL, FILE_BEGIN) + == 0xffffffff) { errno = nterr_nt2unix(GetLastError(), EBADF); return -1; } @@ -346,9 +353,14 @@ nt_fsync(FD_t fd) int -nt_seek(FD_t fd, int off, int where) +nt_seek(FD_t fd, afs_foff_t off, int where) { - int code = SetFilePointer(fd, off, NULL, where); + int code; + LARGE_INTEGER offset; + + offset.QuadPart = off; + + code = SetFilePointerEx(fd, offset, NULL, where); return code; } diff --git a/src/vol/ntops.h b/src/vol/ntops.h index 784dbbae9d..e19dfd61dd 100644 --- a/src/vol/ntops.h +++ b/src/vol/ntops.h @@ -24,17 +24,17 @@ extern char *PrintInode(char *, Inode); /* Basic file operations */ extern FD_t nt_open(char *name, int flags, int mode); extern int nt_close(FD_t fd); -extern int nt_write(FD_t fd, char *buf, size_t size); -extern int nt_read(FD_t fd, char *buf, size_t size); -extern int nt_pread(FD_t fd, void * buf, size_t count, afs_foff_t offset); -extern int nt_pwrite(FD_t fd, const void * buf, size_t count, afs_foff_t offset); -extern int nt_size(FD_t fd); +extern int nt_write(FD_t fd, char *buf, afs_sfsize_t size); +extern int nt_read(FD_t fd, char *buf, afs_sfsize_t size); +extern int nt_pread(FD_t fd, void * buf, afs_sfsize_t count, afs_foff_t offset); +extern int nt_pwrite(FD_t fd, const void * buf, afs_sfsize_t count, afs_foff_t offset); +extern afs_sfsize_t nt_size(FD_t fd); extern int nt_getFileCreationTime(FD_t fd, FILETIME * ftime); extern int nt_setFileCreationTime(FD_t fd, FILETIME * ftime); extern int nt_sync(int cdrive); -extern int nt_ftruncate(FD_t fd, int len); +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, int off, int where); +extern int nt_seek(FD_t fd, afs_foff_t off, int where); extern FILE *nt_fdopen(IHandle_t * h, char *fdperms); extern int nt_unlink(char *name);