]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
vol: Make ntops functions 64-bit capable
authorJeffrey Altman <jaltman@your-file-system.com>
Thu, 20 Jan 2011 07:09:44 +0000 (02:09 -0500)
committerDerrick Brashear <shadow@dementia.org>
Fri, 4 Feb 2011 21:52:19 +0000 (13:52 -0800)
Add 64-bit offset and length support to ntops functions.

Reviewed-on: http://gerrit.openafs.org/3708
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
(cherry picked from commit 3c25ae062a30c83f6dfb388f31878555d6cb63d7)

Change-Id: I5a39e1c255cf5a28e53e9f96d4faf8a6a7e7ebf6
Reviewed-on: http://gerrit.openafs.org/3843
Tested-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
src/vol/ntops.c
src/vol/ntops.h

index 471307d55c3e08b1d1b2cef06738aab67f578c0c..79f7c5bacb9973c39d316fb7fb546d54f6bd91ef 100644 (file)
@@ -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;
 }
 
index 784dbbae9d6ff9b63e4c7c4ba73083765b2bf874..e19dfd61dd747930b848486705d236a869a2460d 100644 (file)
@@ -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);