From 7c5e66068a7ceaeaf2f2bc1ae34a347c0fb80253 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. Reviewed-on: http://gerrit.openafs.org/3708 Tested-by: BuildBot Reviewed-by: Derrick Brashear (cherry picked from commit 3c25ae062a30c83f6dfb388f31878555d6cb63d7) Change-Id: I5a39e1c255cf5a28e53e9f96d4faf8a6a7e7ebf6 Reviewed-on: http://gerrit.openafs.org/3843 Tested-by: Derrick Brashear 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 471307d55..79f7c5bac 100644 --- a/src/vol/ntops.c +++ b/src/vol/ntops.c @@ -171,7 +171,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; @@ -186,7 +186,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 @@ -211,7 +211,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; @@ -229,7 +229,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 @@ -258,15 +258,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; } @@ -321,10 +324,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; } @@ -345,9 +352,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 784dbbae9..e19dfd61d 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); -- 2.39.5